diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-12-18 11:50:00 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-12-18 12:06:47 +0000 |
commit | dea40e61babe608315b6d365094cf518814b134e (patch) | |
tree | c4c5f05fdc0fa255ddb2a5f0da495bc70a939474 /src/cairo-clip.c | |
parent | 3a53e0261b1b5af21bf37e2a211eefd501bd5358 (diff) |
[path] Return the fixed-point bounds of the path
When analysing the stroke extents, we need the original fixed-point
extents so that we do not incur an OBO when we round-to-integer a second
time. We also need a more accurate estimate than simply using the control
points of the curve, so pass in tolerance and decompose until someone
discovers a cheaper algorithm to determine the precise aligned bounding
box of a bezier curve.
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r-- | src/cairo-clip.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index c679e9fb..cd369242 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -143,11 +143,13 @@ _cairo_clip_path_intersect_to_rectangle (cairo_clip_path_t *clip_path, cairo_rectangle_int_t *rectangle) { while (clip_path) { - cairo_rectangle_int_t extents; + cairo_box_t extents; - _cairo_path_fixed_approximate_extents (&clip_path->path, &extents); + _cairo_path_fixed_approximate_extents (&clip_path->path, + clip_path->tolerance, + &extents); - if (! _cairo_rectangle_intersect (rectangle, &extents)) + if (! _cairo_rectangle_intersect_box (rectangle, &extents)) return CAIRO_STATUS_SUCCESS; clip_path = clip_path->prev; @@ -568,20 +570,21 @@ _cairo_clip_intersect_mask_using_spans (cairo_clip_t *clip, goto BAIL; } + status = _cairo_surface_get_extents (target, &surface_rect); + if (status) + goto BAIL; + /* We'll create a new surface the size of the intersection of the * old mask surface and the extents of the new clip path. */ { - cairo_rectangle_int_t target_rect; + cairo_box_t extents; - _cairo_path_fixed_approximate_extents (path, &surface_rect); - - if (clip->surface != NULL && - !_cairo_rectangle_intersect (&surface_rect, &clip->surface_rect)) + _cairo_path_fixed_approximate_extents (path, tolerance, &extents); + if (! _cairo_rectangle_intersect_box (&surface_rect, &extents)) goto SUCCESS; - status = _cairo_surface_get_extents (target, &target_rect); - if (status != CAIRO_STATUS_SUCCESS && - !_cairo_rectangle_intersect (&surface_rect, &target_rect)) + if (clip->surface != NULL && + ! _cairo_rectangle_intersect (&surface_rect, &clip->surface_rect)) goto SUCCESS; } |