From dea40e61babe608315b6d365094cf518814b134e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 18 Dec 2008 11:50:00 +0000 Subject: [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. --- src/cairo-clip.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/cairo-clip.c') 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; } -- cgit v1.2.3