[cairo] [PATCH] stroke_extents: Use a polygon instead of traps

Uli Schlachter psychon at znc.in
Fri Jun 14 06:18:10 PDT 2013


Instead of calculating the extents of a cairo_path_fixed_t by converting it into
traps and getting the traps' extents, this patch implements this operation via
converting to a polygon and using the polygon's extents.

This fixes the "get-path-extents" test without breaking anything else. IMHO this
commit papers over a bug from commit 3cf6551ac7 (see bugzilla), but I am not
really sure and can only guess.

Patch was originally written by Chris Wilson.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62375
Signed-off-by: Uli Schlachter <psychon at znc.in>
---
Hi everyone,

this patch has been sitting in bugzilla for almost two months now. Since I don't
see anything wrong with this, I would like to get this into git. However, I
don't feel like I know what I am doing here, so please speak up now and make me
stop.

@Chris: It would be even better if you committed this to git (under your own
name), because you wrote the patch and I didn't.

If no one objects, I will push this to fdo in about a week.

Cheers,
Uli

 src/cairo-gstate.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 6319471..b8caa63 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1462,19 +1462,19 @@ _cairo_gstate_stroke_extents (cairo_gstate_t	 *gstate,
     }

     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-	cairo_traps_t traps;
-
-	_cairo_traps_init (&traps);
-	status = _cairo_path_fixed_stroke_polygon_to_traps (path,
-							    &gstate->stroke_style,
-							    &gstate->ctm,
-							    &gstate->ctm_inverse,
-							    gstate->tolerance,
-							    &traps);
-	empty = traps.num_traps == 0;
+	cairo_polygon_t polygon;
+
+	_cairo_polygon_init (&polygon, NULL, 0);
+	status = _cairo_path_fixed_stroke_to_polygon (path,
+						      &gstate->stroke_style,
+						      &gstate->ctm,
+						      &gstate->ctm_inverse,
+						      gstate->tolerance,
+						      &polygon);
+	empty = polygon.num_edges == 0;
 	if (! empty)
-	    _cairo_traps_extents (&traps, &extents);
-	_cairo_traps_fini (&traps);
+	    extents = polygon.extents;
+	_cairo_polygon_fini (&polygon);
     }
     if (! empty) {
 	_cairo_gstate_extents_to_user_rectangle (gstate, &extents,
-- 
1.7.10.4



More information about the cairo mailing list