2005-12-29 07:17:01 +00:00
|
|
|
/*
|
|
|
|
|
Test were run with the following script
|
|
|
|
|
target can be directfb_bitmap or directfb
|
|
|
|
|
|
|
|
|
|
export CAIRO_TEST_TARGET=directfb_bitmap
|
|
|
|
|
export DFBARGS=quiet,no-banner,no-debug,log-file=dfblog,system=x11
|
|
|
|
|
cd cairo/test
|
|
|
|
|
make check
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2006-10-12 20:39:16 -07:00
|
|
|
#include "cairo-boilerplate.h"
|
2007-04-19 19:39:58 -04:00
|
|
|
#include "cairo-boilerplate-directfb-private.h"
|
2005-12-29 07:17:01 +00:00
|
|
|
|
2007-04-20 00:13:25 -04:00
|
|
|
#include <cairo-directfb.h>
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2005-12-29 07:17:01 +00:00
|
|
|
/* macro for a safe call to DirectFB functions */
|
|
|
|
|
#define DFBCHECK(x...) \
|
|
|
|
|
{ \
|
|
|
|
|
err = x; \
|
|
|
|
|
if (err != DFB_OK) { \
|
|
|
|
|
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
|
|
|
|
|
DirectFBErrorFatal( #x, err ); \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct _DFBInfo {
|
|
|
|
|
IDirectFB *dfb;
|
|
|
|
|
IDirectFBDisplayLayer *layer;
|
|
|
|
|
IDirectFBWindow *window;
|
|
|
|
|
IDirectFBSurface *surface;
|
|
|
|
|
} DFBInfo ;
|
|
|
|
|
|
|
|
|
|
static DFBInfo *init(void) {
|
|
|
|
|
DFBDisplayLayerConfig layer_config;
|
|
|
|
|
DFBGraphicsDeviceDescription desc;
|
|
|
|
|
int err;
|
2006-10-12 20:39:16 -07:00
|
|
|
DFBInfo *info = calloc(1,sizeof(DFBInfo));
|
2006-06-06 15:41:31 -07:00
|
|
|
if( !info )
|
2005-12-29 07:17:01 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
DFBCHECK(DirectFBInit( NULL,NULL));
|
|
|
|
|
DFBCHECK(DirectFBCreate( &info->dfb ));
|
|
|
|
|
info->dfb->GetDeviceDescription(info->dfb, &desc );
|
|
|
|
|
|
|
|
|
|
DFBCHECK(info->dfb->GetDisplayLayer( info->dfb, DLID_PRIMARY, &info->layer ));
|
|
|
|
|
info->layer->SetCooperativeLevel( info->layer, DLSCL_ADMINISTRATIVE );
|
|
|
|
|
|
|
|
|
|
if (!((desc.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
|
|
|
|
|
(desc.blitting_flags & DSBLIT_BLEND_COLORALPHA )))
|
|
|
|
|
{
|
|
|
|
|
layer_config.flags = DLCONF_BUFFERMODE;
|
|
|
|
|
layer_config.buffermode = DLBM_BACKSYSTEM;
|
|
|
|
|
info->layer->SetConfiguration( info->layer, &layer_config );
|
|
|
|
|
}
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-12 20:39:16 -07:00
|
|
|
static cairo_surface_t *
|
2007-04-19 20:17:26 -04:00
|
|
|
_cairo_boilerplate_directfb_window_create_surface (DFBInfo *info,
|
|
|
|
|
cairo_content_t content,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
2005-12-29 07:17:01 +00:00
|
|
|
DFBWindowDescription desc;
|
|
|
|
|
int err;
|
|
|
|
|
desc.flags = ( DWDESC_POSX | DWDESC_POSY |
|
2006-10-12 20:39:16 -07:00
|
|
|
DWDESC_WIDTH | DWDESC_HEIGHT /*| DWDESC_CAPS|DSDESC_PIXELFORMAT*/ );
|
2005-12-29 07:17:01 +00:00
|
|
|
desc.posx = 0;
|
|
|
|
|
desc.posy = 0;
|
2006-10-12 20:39:16 -07:00
|
|
|
desc.width = width;
|
|
|
|
|
desc.height = height;
|
|
|
|
|
#if 0 /*Test using native format by default*/
|
2005-12-29 07:17:01 +00:00
|
|
|
desc.caps = DWCAPS_DOUBLEBUFFER;
|
|
|
|
|
desc.caps |= DWCAPS_ALPHACHANNEL;
|
|
|
|
|
desc.pixelformat = DSPF_ARGB;
|
2006-10-12 20:39:16 -07:00
|
|
|
#endif
|
2005-12-29 07:17:01 +00:00
|
|
|
|
|
|
|
|
DFBCHECK(info->layer->CreateWindow( info->layer, &desc, &info->window ) );
|
|
|
|
|
info->window->SetOpacity( info->window, 0xFF );
|
|
|
|
|
info->window->GetSurface( info->window, &info->surface );
|
|
|
|
|
info->surface->SetColor( info->surface, 0xFF, 0xFF, 0xFF, 0xFF );
|
|
|
|
|
info->surface->FillRectangle( info->surface,0, 0, desc.width, desc.height );
|
|
|
|
|
info->surface->Flip( info->surface, NULL, 0 );
|
2006-10-12 20:39:16 -07:00
|
|
|
return cairo_directfb_surface_create(info->dfb,info->surface);
|
2005-12-29 07:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-12 20:39:16 -07:00
|
|
|
static cairo_surface_t *
|
2007-04-19 20:17:26 -04:00
|
|
|
_cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo *info,
|
|
|
|
|
cairo_content_t content,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
2005-12-29 07:17:01 +00:00
|
|
|
int err;
|
|
|
|
|
DFBSurfaceDescription desc;
|
|
|
|
|
|
2006-06-06 15:41:31 -07:00
|
|
|
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
|
2005-12-29 07:17:01 +00:00
|
|
|
desc.caps = DSCAPS_NONE;
|
2006-10-12 20:39:16 -07:00
|
|
|
desc.width = width;
|
|
|
|
|
desc.height = height;
|
2005-12-29 07:17:01 +00:00
|
|
|
desc.pixelformat = DSPF_ARGB;
|
|
|
|
|
DFBCHECK(info->dfb->CreateSurface (info->dfb, &desc,&info->surface));
|
2006-10-12 20:39:16 -07:00
|
|
|
return cairo_directfb_surface_create(info->dfb,info->surface);
|
2005-12-29 07:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2007-04-19 19:39:58 -04:00
|
|
|
_cairo_boilerplate_directfb_cleanup (void* closure) {
|
2005-12-29 07:17:01 +00:00
|
|
|
DFBInfo *info = (DFBInfo *)closure;
|
|
|
|
|
if( info->surface )
|
|
|
|
|
info->surface->Release( info->surface );
|
2006-06-06 15:41:31 -07:00
|
|
|
if( info->window )
|
2005-12-29 07:17:01 +00:00
|
|
|
info->window->Release( info->window );
|
2006-06-06 15:41:31 -07:00
|
|
|
if( info->layer )
|
2005-12-29 07:17:01 +00:00
|
|
|
info->layer->Release( info->layer );
|
2006-06-06 15:41:31 -07:00
|
|
|
if( info->dfb )
|
2005-12-29 07:17:01 +00:00
|
|
|
info->dfb->Release( info->dfb );
|
|
|
|
|
}
|
2006-10-12 20:39:16 -07:00
|
|
|
|
|
|
|
|
cairo_surface_t *
|
2007-04-19 19:39:58 -04:00
|
|
|
_cairo_boilerplate_directfb_create_surface (const char *name,
|
2007-04-19 20:17:26 -04:00
|
|
|
cairo_content_t content,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
cairo_boilerplate_mode_t mode,
|
|
|
|
|
void **closure)
|
|
|
|
|
{
|
2007-04-19 19:39:58 -04:00
|
|
|
|
2006-10-12 20:39:16 -07:00
|
|
|
DFBInfo* info= init();
|
|
|
|
|
*closure = info;
|
2007-04-19 19:39:58 -04:00
|
|
|
if( !info ) {
|
2006-10-12 20:39:16 -07:00
|
|
|
CAIRO_BOILERPLATE_LOG ("Failed to init directfb:\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (width == 0)
|
|
|
|
|
width = 1;
|
|
|
|
|
if (height == 0)
|
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
|
|
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
|
2007-04-19 20:17:26 -04:00
|
|
|
return _cairo_boilerplate_directfb_bitmap_create_surface (info, content, width, height);
|
2006-10-12 20:39:16 -07:00
|
|
|
else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
|
2007-04-19 20:17:26 -04:00
|
|
|
return _cairo_boilerplate_directfb_window_create_surface (info, content, width, height);
|
2006-10-12 20:39:16 -07:00
|
|
|
}
|