Re: cairo surface from GdkPixmap
- From: Owen Taylor <otaylor redhat com>
- To: Alexander Larsson <alexl redhat com>
- Cc: "gtk-devel-list gnome org" <gtk-devel-list gnome org>
- Subject: Re: cairo surface from GdkPixmap
- Date: Mon, 26 Sep 2005 00:17:21 -0400
On Fri, 2005-09-23 at 14:21 +0200, Alexander Larsson wrote:
> I'm trying to draw a GdkPixmap to a window with a transformation. I can
> do this using:
> surface = cairo_xlib_surface_create (gdk_x11_drawable_get_xdisplay (widget->window),
> gdk_x11_drawable_get_xid (pixmap),
> gdk_x11_visual_get_xvisual (gdk_drawable_get_visual (widget->window)),
> width, height);
> cairo_set_source_surface (cr, surface, 0, 0);
> I see that we have:
> void gdk_cairo_set_source_pixbuf (cairo_t *cr,
> GdkPixbuf *pixbuf,
> double pixbuf_x,
> double pixbuf_y);
> But no gdk_cairo_set_source_drawable(). In fact,
> _gdk_drawable_ref_cairo_surface() which does exactly what I want is a
> private function. What is the reason for this?
The lack of gdk_cairo_set_source_drawable() is basically "I didn't
need it, so I didn't get around to adding it.". It makes sense and
there aren't any issues with it.
gdk_drawable_ref_cairo_surface() is a little more sticky. There
are two things about it that are tricky:
- It's ref_cairo_surface() not get_cairo_surface().
We don't have a lot of precedent for referencing accessors, but
you really want to keep this one referencing. Surfaces are
not necessarily lightweight ... they can cache pixel data,
and we don't want to keep them around when not needed.
From C, we have the established naming convention of ref()
for this, but what we haven't established yet is that language
bindings should rename such functions back to _get() [or should
- The behavior in begin_paint()/end_paint() is unexpected ...
if you _ref_cairo_surface() with that pair, you get a
surface pointing to the backing pixmap. If you draw to
it after the end_paint(), then it will be safe (the cairo
surface is finished) but nothing will appear.
Now that there is cairo_xlib_surface_set_drawable() this
could be fixed for X, but not for Win32. So it's probably
better to just document the current behavior.
Anyways, neither thing is a real stop-objection, but they made
me want to leave things private rather than rushing ref_cairo_surface()
out to the world when I was first adding the stuff.
and the hypothetical
have considerably less "gotcha" to them.
] [Thread Prev