cairo and directfb
Alex Vazquez <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAOTEMUR6f+=mo05vLVLDb86BKP1EfeDj+iUuA6TQo5CN9bekPQ@mail.gmail.com> |
Hi all! I am using cairo and directFB to create a application. I have the next problem. When I want to paint the window with DirectFB, I can not paint if I have not destroyed before the element cairo_t. My problem is I do not want to destroy it because I want to modify more times but if I destroy the object it can not modify more. If not destroy the object cairo_t I get an error that the resource is locked. I do not know if I'm explaining well. I add the code if you can help me. Thanks! Regards! Alex -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo
test1cairo.c
(text/x-csrc, 2 KB)
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>
#include <directfb.h>
#include <cairo-directfb.h>
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width = 0;
static int screen_height = 0;
cairo_surface_t *image;
cairo_t *cr;
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
static void draw_simple( IDirectFB *dfb,IDirectFBSurface *surface )
{
cairo_surface_t *csurface=cairo_directfb_surface_create(dfb,surface);
cr = cairo_create(csurface);
cairo_surface_destroy(csurface);
cairo_set_source_rgba (cr, 1, 0, 0, 0.80);
cairo_rectangle (cr, 0, 0,100, 100);
cairo_stroke (cr);
}
static void draw_simple_2()
{
cairo_set_source_rgba (cr, 0, 1, 0, 1);
cairo_rectangle (cr, 100, 100,100, 100);
cairo_stroke (cr);
}
int main(int argc, char *argv[])
{
DFBSurfaceDescription dsc;
DFBCHECK (DirectFBInit (&argc, &argv));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING | DWCAPS_ALPHACHANNEL;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
draw_simple(dfb,primary);
cairo_destroy(cr);
DFBCHECK (primary->Flip (primary, NULL, 0));
sleep(5);
draw_simple_2();
DFBCHECK (primary->Flip (primary, NULL, 0));
sleep(5);
primary->Release(primary);
dfb->Release( dfb );
return 0;
}
Makefile
(application/octet-stream, 383 B) - not displayed