Re: GTK+, Cairo, XLib integration for fast 2D graphics drawing

Chris Wilson <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Wed, 10 Oct 2012 15:08:01 +0300, Christos Sotiriou <[email protected]> wrote:
> Chris, thanks for you reply. I clearly understand now the distinction
> between images and X Drawables.
> 
> So, to summarise, could you please confirm that my following GTK/Cairo
> interface functions correctly and always use the XServer:
> 
> 1. In my expose_event function I do:
> 
> maincanvas_drawable = GTK_LAYOUT(maincanvas)->bin_window; // drawable
> layout window //
> maincanvas_cs = gdk_cairo_create(maincanvas_drawable); // corresponding
> cairo state//
> 
> to get the Cairo State maincanvas_cs
> 
> 2. Next, I draw to maincanvas_cs:
> 
> ...
> cairo_paint(maincanvas_cs);
> ...
> 
> or
> 
> 3.  I create a similar surface and draw to that, for double-buffering, like
> this:
> 
> parent_sf = cairo_get_target(maincanvas_cs); // get parent surface //
> drawbuffer_sf = cairo_surface_create_similar(parent_sf,
> CAIRO_CONTENT_COLOR_ALPHA, maincanvasWidth, maincanvasHeight);
> 
> All of the above exploit the GPU, correct?

Yes. I just feel a little nervous as GTK+ will also be doing some
double-buffering magic as well around expose events, so accessing the
GdkDrawables may be risky. But that looks like the right approach to
use accelerated rendering in a backend agnostic fashion.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.