summaryrefslogtreecommitdiff
path: root/src/cairo-image-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-10-16 08:43:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-10-16 10:13:57 +0100
commit6a19a82efd3afe8fb8bd30e5362b247de8efe159 (patch)
tree4cf209c727831cca266066a336f06ccaa8863d6c /src/cairo-image-surface.c
parented94d7caad6b851f6f80fa4d67441ad0387a8cd4 (diff)
[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.
Diffstat (limited to 'src/cairo-image-surface.c')
-rw-r--r--src/cairo-image-surface.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 9310a517..05b0edbb 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);