summaryrefslogtreecommitdiff
path: root/src/cairo-clip.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-29 12:08:12 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 17:10:05 +0100
commit21225a7163bc93d34d3e395c840faaba24046bb6 (patch)
tree0c95841ea3b47b20b0da4ecc307f42a6ce351653 /src/cairo-clip.c
parentac6c6fe1d39effd5b6b382f0f1199af824868ef4 (diff)
[clip] Pass in destination offset for combining with clip-mask
When combining a clip-mask with a subsurface, as when used to combine with the composite mask, we need to pass the destination surface offset to the clip so that the paths can be corrected for the new surface.
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r--src/cairo-clip.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 7f2c8be6..0f484424 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -1177,12 +1177,14 @@ _cairo_clip_get_surface (cairo_clip_t *clip, cairo_surface_t *target)
}
cairo_status_t
-_cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
+_cairo_clip_combine_with_surface (cairo_clip_t *clip,
+ cairo_surface_t *dst,
+ int dst_x,
+ int dst_y)
{
cairo_pattern_union_t pattern;
cairo_clip_path_t *clip_path = clip->path;
- const cairo_rectangle_int_t *clip_extents = &clip_path->extents;
- cairo_bool_t need_translate;
+ cairo_bool_t translate;
cairo_status_t status;
assert (clip_path != NULL);
@@ -1193,8 +1195,8 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
_cairo_pattern_init_for_surface (&pattern.surface,
clip_path->surface);
cairo_matrix_init_translate (&pattern.base.matrix,
- -clip_path->extents.x + clip_extents->x,
- -clip_path->extents.y + clip_extents->y);
+ dst_x - clip_path->extents.x,
+ dst_y - clip_path->extents.y);
status = _cairo_surface_paint (dst,
CAIRO_OPERATOR_IN,
&pattern.base,
@@ -1209,25 +1211,23 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
CAIRO_COLOR_WHITE,
CAIRO_CONTENT_COLOR);
- need_translate = clip_extents->x || clip_extents->y;
+ translate = dst_x | dst_y;
do {
status = _cairo_clip_path_to_region (clip_path);
if (unlikely (_cairo_status_is_error (status)))
return status;
if (status == CAIRO_STATUS_SUCCESS) {
- if (need_translate) {
- cairo_region_translate (clip_path->region,
- -clip_extents->x, -clip_extents->y);
- }
+ if (translate)
+ cairo_region_translate (clip_path->region, -dst_x, -dst_y);
+
status = _cairo_surface_fill_region (dst,
CAIRO_OPERATOR_IN,
CAIRO_COLOR_WHITE,
clip_path->region);
- if (need_translate) {
- cairo_region_translate (clip_path->region,
- clip_extents->x, clip_extents->y);
- }
+
+ if (translate)
+ cairo_region_translate (clip_path->region, dst_x, dst_y);
return status;
}
@@ -1238,8 +1238,8 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
_cairo_pattern_init_for_surface (&pattern.surface,
clip_path->surface);
cairo_matrix_init_translate (&pattern.base.matrix,
- -clip_path->extents.x + clip_extents->x,
- -clip_path->extents.y + clip_extents->y);
+ dst_x - clip_path->extents.x,
+ dst_y - clip_path->extents.y);
status = _cairo_surface_paint (dst,
CAIRO_OPERATOR_IN,
&pattern.base,
@@ -1250,10 +1250,10 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
return status;
}
- if (need_translate) {
+ if (translate) {
_cairo_path_fixed_translate (&clip_path->path,
- _cairo_fixed_from_int (-clip_extents->x),
- _cairo_fixed_from_int (-clip_extents->y));
+ _cairo_fixed_from_int (-dst_x),
+ _cairo_fixed_from_int (-dst_y));
}
status = _cairo_surface_fill (dst,
CAIRO_OPERATOR_IN,
@@ -1263,12 +1263,11 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, cairo_surface_t *dst)
clip_path->tolerance,
clip_path->antialias,
NULL);
- if (need_translate) {
+ if (translate) {
_cairo_path_fixed_translate (&clip_path->path,
- _cairo_fixed_from_int (clip_extents->x),
- _cairo_fixed_from_int (clip_extents->y));
+ _cairo_fixed_from_int (dst_x),
+ _cairo_fixed_from_int (dst_y));
}
-
if (unlikely (status))
return status;
} while ((clip_path = clip_path->prev) != NULL);