summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-08-27 14:33:14 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2013-09-05 16:11:08 +0100
commitbdccf4fe51bca785f73205ccd26c4d020669e312 (patch)
tree157d03ad09c2a96aed3fd0ac0722c393fecfa1cb
parent5f70148467ff2767dc3c6d45f4af1223d7daa301 (diff)
surface: Opencode create_similar
We copy the _cairo_surface_create_similar_solid code into cairo_surface_create_similar so that we can separate these later as one wants to use backend sizes and one not.
-rw-r--r--src/cairo-surface.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index f07a0f6ca..9caacbb13 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -518,6 +518,8 @@ cairo_surface_create_similar (cairo_surface_t *other,
int height)
{
cairo_surface_t *surface;
+ cairo_status_t status;
+ cairo_solid_pattern_t pattern;
if (unlikely (other->status))
return _cairo_surface_create_in_error (other->status);
@@ -529,9 +531,34 @@ cairo_surface_create_similar (cairo_surface_t *other,
if (unlikely (! CAIRO_CONTENT_VALID (content)))
return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_CONTENT);
- surface = _cairo_surface_create_similar_solid (other,
- content, width, height,
- CAIRO_COLOR_TRANSPARENT);
+ if (unlikely (other->status))
+ return _cairo_surface_create_in_error (other->status);
+
+ surface = NULL;
+ if (other->backend->create_similar)
+ surface = other->backend->create_similar (other, content, width, height);
+ if (surface == NULL)
+ surface = cairo_surface_create_similar_image (other,
+ _cairo_format_from_content (content),
+ width, height);
+
+ if (unlikely (surface->status))
+ return surface;
+
+ _cairo_surface_copy_similar_properties (surface, other);
+
+ if (unlikely (surface->status))
+ return surface;
+
+ _cairo_pattern_init_solid (&pattern, CAIRO_COLOR_TRANSPARENT);
+ status = _cairo_surface_paint (surface,
+ CAIRO_OPERATOR_CLEAR,
+ &pattern.base, NULL);
+ if (unlikely (status)) {
+ cairo_surface_destroy (surface);
+ surface = _cairo_surface_create_in_error (status);
+ }
+
assert (surface->is_clear);
return surface;