summaryrefslogtreecommitdiff
path: root/src/cairo-mask-compositor.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-02-22 11:42:15 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-02-22 12:32:44 +0000
commit9e640c7ae2cc968cbf4607efdf7f7ab26e5c0bb8 (patch)
tree9e7d57ed747b67a4b213dad9b09b4476b146d588 /src/cairo-mask-compositor.c
parent605f23d15562d28138ade7f0717cbcf3d01147bf (diff)
downloadcairo-9e640c7ae2cc968cbf4607efdf7f7ab26e5c0bb8.tar.gz
mask-compositor: Acquire the target surface when creating the composite mask
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-mask-compositor.c')
-rw-r--r--src/cairo-mask-compositor.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/cairo-mask-compositor.c b/src/cairo-mask-compositor.c
index 807ba996c..34e5fbbc3 100644
--- a/src/cairo-mask-compositor.c
+++ b/src/cairo-mask-compositor.c
@@ -162,21 +162,39 @@ create_composite_mask (const cairo_mask_compositor_t *compositor,
struct blt_in info;
int i;
- surface = _cairo_surface_create_similar_solid (dst,
- CAIRO_CONTENT_ALPHA,
- extents->bounded.width,
- extents->bounded.height,
- CAIRO_COLOR_TRANSPARENT);
+ surface = _cairo_surface_create_similar_scratch (dst, CAIRO_CONTENT_ALPHA,
+ extents->bounded.width,
+ extents->bounded.height);
if (unlikely (surface->status))
return surface;
+ status = compositor->acquire (surface);
+ if (unlikely (status)) {
+ cairo_surface_destroy (surface);
+ return _cairo_surface_create_in_error (status);
+ }
+
+ {
+ cairo_rectangle_int_t rect;
+
+ rect.x = rect.y = 0;
+ rect.width = extents->bounded.width;
+ rect.height = extents->bounded.height;
+
+ status = compositor->fill_rectangles (surface, CAIRO_OPERATOR_CLEAR,
+ CAIRO_COLOR_TRANSPARENT,
+ &rect, 1);
+ if (unlikely (status))
+ goto error;
+ }
+
if (mask_func) {
status = mask_func (compositor, surface, draw_closure,
CAIRO_OPERATOR_SOURCE, NULL, NULL,
extents->bounded.x, extents->bounded.y,
&extents->bounded, extents->clip);
if (likely (status != CAIRO_INT_STATUS_UNSUPPORTED))
- return surface;
+ goto out;
}
/* Is it worth setting the clip region here? */
@@ -184,10 +202,8 @@ create_composite_mask (const cairo_mask_compositor_t *compositor,
CAIRO_OPERATOR_ADD, NULL, NULL,
extents->bounded.x, extents->bounded.y,
&extents->bounded, NULL);
- if (unlikely (status)) {
- cairo_surface_destroy (surface);
- return _cairo_surface_create_in_error (status);
- }
+ if (unlikely (status))
+ goto error;
info.compositor = compositor;
info.dst = surface;
@@ -209,12 +225,20 @@ create_composite_mask (const cairo_mask_compositor_t *compositor,
status = _cairo_clip_combine_with_surface (extents->clip, surface,
extents->bounded.x,
extents->bounded.y);
- if (unlikely (status)) {
- cairo_surface_destroy (surface);
- return _cairo_surface_create_in_error (status);
- }
+ if (unlikely (status))
+ goto error;
}
+out:
+ compositor->release (surface);
+ return surface;
+
+error:
+ compositor->release (surface);
+ if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) {
+ cairo_surface_destroy (surface);
+ surface = _cairo_surface_create_in_error (status);
+ }
return surface;
}