diff options
author | Alexander Larsson <alexl@redhat.com> | 2013-08-06 16:18:13 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2013-08-07 13:34:10 +0200 |
commit | 54f5e4af53f520fa621218e02110c40286975513 (patch) | |
tree | 90a18a9f8cdbf532814b26fa1f2660430352b2ed /gdk/gdkpixbuf-drawable.c | |
parent | 9bde6b10ef7b23918112eb37958867cfb2f812e6 (diff) | |
download | gtk+-54f5e4af53f520fa621218e02110c40286975513.tar.gz |
gdk_pixbuf_get_from_surface: Avoid copying if source is image surface
If the source surface is an image surface we don't need to coerce
it to one.
Diffstat (limited to 'gdk/gdkpixbuf-drawable.c')
-rw-r--r-- | gdk/gdkpixbuf-drawable.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index f8736bac7c..59698f8ac0 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -248,9 +248,16 @@ gdk_pixbuf_get_from_surface (cairo_surface_t *surface, 8, width, height); - surface = gdk_cairo_surface_coerce_to_image (surface, content, - src_x, src_y, - width, height); + if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE) + surface = cairo_surface_reference (surface); + else + { + surface = gdk_cairo_surface_coerce_to_image (surface, content, + src_x, src_y, + width, height); + src_x = 0; + src_y = 0; + } cairo_surface_flush (surface); if (cairo_surface_status (surface) || dest == NULL) { @@ -263,14 +270,14 @@ gdk_pixbuf_get_from_surface (cairo_surface_t *surface, gdk_pixbuf_get_rowstride (dest), cairo_image_surface_get_data (surface), cairo_image_surface_get_stride (surface), - 0, 0, + src_x, src_y, width, height); else convert_no_alpha (gdk_pixbuf_get_pixels (dest), gdk_pixbuf_get_rowstride (dest), cairo_image_surface_get_data (surface), cairo_image_surface_get_stride (surface), - 0, 0, + src_x, src_y, width, height); cairo_surface_destroy (surface); |