From 54f5e4af53f520fa621218e02110c40286975513 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 6 Aug 2013 16:18:13 +0200 Subject: 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. --- gdk/gdkpixbuf-drawable.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gdk/gdkpixbuf-drawable.c') 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); -- cgit v1.2.1