summaryrefslogtreecommitdiff
path: root/gdk/gdkcairo.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-09-24 16:37:37 +0200
committerBenjamin Otte <otte@redhat.com>2013-09-24 16:42:48 +0200
commitb41787bc788d03aaf3dc3c734bc7e8161c1e713a (patch)
treec523af5aaf909e46d951d6ebfebcd750d670bae1 /gdk/gdkcairo.c
parent1959e36066908327aa8bfcb8112e31bed2986b5c (diff)
downloadgtk+-b41787bc788d03aaf3dc3c734bc7e8161c1e713a.tar.gz
gdkcairo: Don't require gtk_init() for set_source_pixbuf()
Instead of using the default display's root window's surface, use the target surface of the passed in cairo_t to create the similar image from. https://bugzilla.gnome.org/show_bug.cgi?id=708547
Diffstat (limited to 'gdk/gdkcairo.c')
-rw-r--r--gdk/gdkcairo.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index d16a619ebd..ae0c294b70 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -321,9 +321,19 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
gdouble pixbuf_x,
gdouble pixbuf_y)
{
+ cairo_format_t format;
cairo_surface_t *surface;
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
+ if (gdk_pixbuf_get_n_channels (pixbuf) == 3)
+ format = CAIRO_FORMAT_RGB24;
+ else
+ format = CAIRO_FORMAT_ARGB32;
+
+ surface = cairo_surface_create_similar_image (cairo_get_target (cr),
+ format,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
}