[cairo] basic question?

Charles سمير Doutriaux doutriaux1 at llnl.gov
Tue Aug 18 11:49:52 PDT 2009


Hi,

I went thru the example and I couldn't find an quick answer to my  
question, apologies in advance if this was already treated somewhere.

My problem is as follow:

I'm using cairo to draw on an X11 surface.

For speed reason I'm thinking it would be better to draw "in memory"  
on a cairo_image surface and then whenever I need to update copy the  
image back to my X11 window.

I would prefer not to use a cairo_X11_surface if possible

For now my failed attempt looks like this:

	connect_id->surface =  
cairo_image_surface_create(CAIRO_FORMAT_RGB24,x,y);
	connect_id->cr = cairo_create(connect_id->surface);

/* this works fine staus is OK */

/* bunch of cairo drawing calls here all works fine */

/* now my attempt at bringing it back to the X11 window */
	Pixmap tmppix;
	int screen_num;
	GC gc;
	screen_num = DefaultScreen(connect_id.display);

         gc = DefaultGC(connect_id.display,screen_num);

	XGetWindowAttributes(connect_id.display, connect_id.drawable, &xwa);
	printf("depth: %i\n",xwa.depth);
	tmppix = XCreatePixmapFromBitmapData(self->connect_id.display,self- 
 >connect_id.drawable,
					     cairo_image_surface_get_data(self->connect_id.surface),
					     cairo_image_surface_get_width(self->connect_id.surface),
					     cairo_image_surface_get_height(self->connect_id.surface),
					     1,1,
					     24);

         /*   XSync(connect_id.display,FALSE);
            XFlush(connect_id.display);*/
	XCopyArea(connect_id.display, tmppix,
		  connect_id.drawable, gc, 0,0, xwa.width, xwa.height, 0, 0);

	//XFreePixmap(connect_id.display,tmppix);


Should I use another format?

Thanks for any pointer.

C.



More information about the cairo mailing list