[cairo-commit] cairo/test Makefile.am, 1.106, 1.107 cairo-test-directfb.c, NONE, 1.1 cairo-test-directfb.h, NONE, 1.1 cairo-test.c, 1.72, 1.73

Michael Emmel commit at pdx.freedesktop.org
Thu Dec 29 07:17:04 PST 2005


Committed by: memmel

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv23776/test

Modified Files:
	Makefile.am cairo-test.c 
Added Files:
	cairo-test-directfb.c cairo-test-directfb.h 
Log Message:
New directfb backend for cairo includes test suite
and example to run the test is in the comment at the top of
cairo-test-directfb.c
enable with
--enable-directfb




Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- Makefile.am	19 Dec 2005 21:59:35 -0000	1.106
+++ Makefile.am	29 Dec 2005 15:17:01 -0000	1.107
@@ -258,6 +258,10 @@
 libcairotest_la_CXXFLAGS = -Wno-multichar
 endif
 
+if CAIRO_HAS_DIRECTFB_SURFACE
+libcairotest_la_SOURCES += cairo-test-directfb.c cairo-test-directfb.h
+endif
+
 LDADDS = libcairotest.la $(top_builddir)/src/libcairo.la
 
 if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE

--- NEW FILE: cairo-test-directfb.c ---

/*
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


*/

#include <stdio.h>
#include <stdlib.h>
#include "cairo-test.h"
#include "cairo-test-directfb.h"
#include <directfb.h>
#include "cairo-directfb.h"

/* 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;
	DFBInfo *info = malloc(sizeof(DFBInfo));	
	if( !info ) 
		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;
}


cairo_surface_t *
create_directfb_surface (cairo_test_t* test, cairo_format_t format,
                     void **closure) {
	DFBWindowDescription desc;
	int err;
	DFBInfo *info = init();
	if( !info ) 
		return NULL;
	*closure = info;

	desc.flags  = ( DWDESC_POSX | DWDESC_POSY |
			DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS|DSDESC_PIXELFORMAT );
	desc.posx   = 0;
	desc.posy   = 0;
	desc.width  = test->width;
	desc.height = test->height;
	desc.caps =  DWCAPS_DOUBLEBUFFER;
	desc.caps |= DWCAPS_ALPHACHANNEL;
	desc.pixelformat = DSPF_ARGB;

	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 );
	cairo_surface_t *csurface=cairo_directfb_surface_create(info->dfb,info->surface);
	return csurface;
}

cairo_surface_t *
create_directfb_bitmap_surface (cairo_test_t* test, cairo_format_t format,
                            void **closure) { 
	int  err;
	DFBInfo *info = init();
	if( !info ) return NULL;
	*closure = info;
	info->window= NULL; /* make sure window is null*/
	DFBSurfaceDescription  desc;

	desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; 
	desc.caps = DSCAPS_NONE;
	desc.width  = test->width;
	desc.height = test->height;
	desc.pixelformat = DSPF_ARGB;
	DFBCHECK(info->dfb->CreateSurface (info->dfb, &desc,&info->surface));
	cairo_surface_t *csurface=cairo_directfb_surface_create(info->dfb,
		info->surface);
	return csurface;
}

void
cleanup_directfb (void* closure) {
	DFBInfo *info = (DFBInfo *)closure;
	if( info->surface )
		info->surface->Release( info->surface );
	if( info->window ) 
		info->window->Release( info->window );
	if( info->layer ) 
		info->layer->Release( info->layer );
	if( info->dfb ) 
		info->dfb->Release( info->dfb );
}

--- NEW FILE: cairo-test-directfb.h ---
#ifndef CAIRO_TEST_DIRECTFB_H_
#define CAIRO_TEST_DIRECTFB_H_

/* Two functions: One for a real window, one for a bitmap */

#include <cairo.h>

CAIRO_BEGIN_DECLS

extern cairo_surface_t *
create_directfb_surface (cairo_test_t* test, cairo_format_t format,
                     void **closure);

extern void
cleanup_directfb (void* closure);

extern cairo_surface_t *
create_directfb_bitmap_surface (cairo_test_t* test, cairo_format_t format,
                            void **closure);

CAIRO_END_DECLS

#endif

Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- cairo-test.c	22 Dec 2005 00:46:45 -0000	1.72
+++ cairo-test.c	29 Dec 2005 15:17:01 -0000	1.73
@@ -1059,6 +1059,10 @@
 #include "cairo-test-beos.h"
 #endif
 
+#if CAIRO_HAS_DIRECTFB_SURFACE
+#include "cairo-test-directfb.h"
+#endif
+
 #if CAIRO_HAS_PS_SURFACE
 #include "cairo-ps.h"
 
@@ -1450,6 +1454,13 @@
 	    { "beos_bitmap", CAIRO_FORMAT_ARGB32,
 		create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
 #endif
+
+#if CAIRO_HAS_DIRECTFB_SURFACE
+	    { "directfb", CAIRO_FORMAT_RGB24,
+		create_directfb_surface, cairo_surface_write_to_png, cleanup_directfb},
+	    { "directfb_bitmap", CAIRO_FORMAT_ARGB32,
+		create_directfb_bitmap_surface, cairo_surface_write_to_png,cleanup_directfb},
+#endif
 	};
 
     if ((tname = getenv ("CAIRO_TEST_TARGET")) != NULL) {



More information about the cairo-commit mailing list