diff options
author | Taekyun Kim <tkq.kim@samsung.com> | 2011-09-02 13:18:33 +0900 |
---|---|---|
committer | Taekyun Kim <tkq.kim@samsung.com> | 2011-09-05 20:08:20 +0900 |
commit | 9d6f43fe81bd5581fb89a95ca94c156b2b86b121 (patch) | |
tree | 272130293068addec8f17d02b274f7eacdd62f19 | |
parent | 6ad63946d4374ad30ef7fbdad421d85bfd8da423 (diff) |
clip: Avoid using clip surface when constructing clip surfaceclip_surface
_cairo_clip_get_surface() might cause another internal clip mask
fallback when intersecting clip paths with unaligned clip boxes.
However, we know that we will use only CAIRO_OPERATOR_IN when we
intersecting clip paths onto the clip surface, so we can avoid
clip mask fallback by enlarging boxes to fit in pixel grid.
-rw-r--r-- | src/cairo-clip-surface.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cairo-clip-surface.c b/src/cairo-clip-surface.c index 79e6a627..c2c82ee0 100644 --- a/src/cairo-clip-surface.c +++ b/src/cairo-clip-surface.c @@ -49,6 +49,19 @@ #include "cairo-composite-rectangles-private.h" #include "cairo-region-private.h" +static void +_cairo_align_boxes (cairo_box_t *boxes, int num_boxes) +{ + int i; + + for (i = 0; i < num_boxes; i++) { + boxes[i].p1.x = _cairo_fixed_floor (boxes[i].p1.x); + boxes[i].p1.y = _cairo_fixed_floor (boxes[i].p1.y); + boxes[i].p2.x = _cairo_fixed_ceil (boxes[i].p2.x); + boxes[i].p2.y = _cairo_fixed_ceil (boxes[i].p2.y); + } +} + cairo_status_t _cairo_clip_combine_with_surface (const cairo_clip_t *clip, cairo_surface_t *dst, @@ -71,6 +84,9 @@ _cairo_clip_combine_with_surface (const cairo_clip_t *clip, copy); } + if (copy && !copy->is_region) + _cairo_align_boxes (copy->boxes, copy->num_boxes); + clip_path = copy_path; while (status == CAIRO_STATUS_SUCCESS && clip_path) { status = _cairo_surface_fill (dst, @@ -120,6 +136,9 @@ _cairo_clip_get_surface (const cairo_clip_t *clip, &_cairo_pattern_white.base, copy); + if (copy && !copy->is_region) + _cairo_align_boxes (copy->boxes, copy->num_boxes); + clip_path = copy_path; while (status == CAIRO_STATUS_SUCCESS && clip_path) { status = _cairo_surface_fill (surface, |