From 6a19a82efd3afe8fb8bd30e5362b247de8efe159 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Oct 2009 08:43:21 +0100 Subject: [PATCH] [image] Clone the format for a similar surface with identical content Honour the incoming surface format when we are asked to create a similar surface with identical content. The goal of cairo_surface_create_similar() is to create an intermediate with similar characteristics to the original that can be used in place of the original and be quick to copy to the original. Matching the format for the same content, ensures that the blits between the two need only be a memcpy. --- src/cairo-image-surface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 9310a5177..05b0edbb6 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -760,12 +760,19 @@ _cairo_format_bits_per_pixel (cairo_format_t format) } static cairo_surface_t * -_cairo_image_surface_create_similar (void *abstract_src, +_cairo_image_surface_create_similar (void *abstract_other, cairo_content_t content, int width, int height) { - assert (CAIRO_CONTENT_VALID (content)); + cairo_image_surface_t *other = abstract_other; + + if (content == other->base.content) { + return _cairo_image_surface_create_with_pixman_format (NULL, + other->pixman_format, + width, height, + 0); + } return _cairo_image_surface_create_with_content (content, width, height);