summaryrefslogtreecommitdiff
path: root/src/cairo-gstate.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2005-10-27 17:16:46 +0000
committerCarl Worth <cworth@cworth.org>2005-10-27 17:16:46 +0000
commit1540504bd66a75a2fed8352ebfe8b029b3f199dd (patch)
treebb24ce7e6be1d9441104d42e9b8858107f21757b /src/cairo-gstate.c
parentce7b19fc3434ff733fd6f00add017386ad4a7974 (diff)
Fix leak of pattern (missing _cairo_pattern_fini).
Move mask fallback from gstate to surface where it belongs. Temporarily export some previously private cairo_gstate functions, (soon to become private cairo_fallback functions).
Diffstat (limited to 'src/cairo-gstate.c')
-rw-r--r--src/cairo-gstate.c76
1 files changed, 9 insertions, 67 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 32b8bd32a..e28b7be0e 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -744,6 +744,8 @@ _cairo_gstate_paint (cairo_gstate_t *gstate)
&pattern.base,
gstate->target);
+ _cairo_pattern_fini (&pattern.base);
+
return status;
}
@@ -786,14 +788,6 @@ _cairo_operator_bounded (cairo_operator_t operator)
return FALSE;
}
-typedef cairo_status_t (*cairo_draw_func_t) (void *closure,
- cairo_operator_t operator,
- cairo_pattern_t *src,
- cairo_surface_t *dst,
- int dst_x,
- int dst_y,
- const cairo_rectangle_t *extents);
-
static cairo_status_t
_create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern,
cairo_clip_t *clip,
@@ -1034,7 +1028,7 @@ _cairo_rectangle_empty (const cairo_rectangle_t *rect)
*
* Return value: %CAIRO_STATUS_SUCCESS if the drawing succeeded.
**/
-static cairo_status_t
+cairo_status_t
_cairo_gstate_clip_and_composite (cairo_clip_t *clip,
cairo_operator_t operator,
cairo_pattern_t *src,
@@ -1087,62 +1081,13 @@ _cairo_gstate_clip_and_composite (cairo_clip_t *clip,
return status;
}
-
-
-static cairo_status_t
-_get_mask_extents (cairo_gstate_t *gstate,
- cairo_pattern_t *mask,
- cairo_rectangle_t *extents)
-{
- cairo_status_t status;
-
- /*
- * XXX should take mask extents into account, but
- * that involves checking the transform and
- * _cairo_operator_bounded (operator)... For now,
- * be lazy and just use the destination extents
- */
- status = _cairo_surface_get_extents (gstate->target, extents);
- if (status)
- return status;
-
- return _cairo_clip_intersect_to_rectangle (&gstate->clip, extents);
-}
-
-static cairo_status_t
-_cairo_gstate_mask_draw_func (void *closure,
- cairo_operator_t operator,
- cairo_pattern_t *src,
- cairo_surface_t *dst,
- int dst_x,
- int dst_y,
- const cairo_rectangle_t *extents)
-{
- cairo_pattern_t *mask = closure;
-
- if (src)
- return _cairo_surface_composite (operator,
- src, mask, dst,
- extents->x, extents->y,
- extents->x, extents->y,
- extents->x - dst_x, extents->y - dst_y,
- extents->width, extents->height);
- else
- return _cairo_surface_composite (operator,
- mask, NULL, dst,
- extents->x, extents->y,
- 0, 0, /* unused */
- extents->x - dst_x, extents->y - dst_y,
- extents->width, extents->height);
-}
cairo_status_t
_cairo_gstate_mask (cairo_gstate_t *gstate,
cairo_pattern_t *mask)
{
- cairo_rectangle_t extents;
- cairo_pattern_union_t source_pattern, mask_pattern;
cairo_status_t status;
+ cairo_pattern_union_t source_pattern, mask_pattern;
if (mask->status)
return mask->status;
@@ -1156,14 +1101,11 @@ _cairo_gstate_mask (cairo_gstate_t *gstate,
_cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
_cairo_gstate_copy_transformed_mask (gstate, &mask_pattern.base, mask);
-
- _get_mask_extents (gstate, &mask_pattern.base, &extents);
-
- status = _cairo_gstate_clip_and_composite (&gstate->clip, gstate->operator,
- &source_pattern.base,
- _cairo_gstate_mask_draw_func, &mask_pattern.base,
- gstate->target,
- &extents);
+
+ status = _cairo_surface_mask (gstate->operator,
+ &source_pattern.base,
+ &mask_pattern.base,
+ gstate->target);
_cairo_pattern_fini (&source_pattern.base);
_cairo_pattern_fini (&mask_pattern.base);