[cairo-commit] 5 commits - perf/cairo-perf-diff src/cairoint.h src/cairo-path-stroke.c src/cairo-traps.c

Carl Worth cworth at kemper.freedesktop.org
Mon Nov 13 17:02:02 PST 2006


 perf/cairo-perf-diff    |   16 ++-
 src/cairo-path-stroke.c |   51 ++-------
 src/cairo-traps.c       |  251 +++++++++++++++++++++++++++++++-----------------
 src/cairoint.h          |    4 
 4 files changed, 193 insertions(+), 129 deletions(-)

New commits:
diff-tree 29b01f93ca9b29699420700ea9e2817898afa3ca (from 3d53f623faed4aed2517e207d77a6da7e3b74fbd)
Author: Carl Worth <cworth at cworth.org>
Date:   Sat Nov 11 10:43:11 2006 -0800

    Make miter join code use tessellate_convex_quad rather than tessellate_polygon
    
    This provides an additional 22-29% speedup on top of the previous
    fix for stroking paths with many miter joins:
    
    image-rgba  world_map-800  459.73 0.27% -> 356.80 0.32%:  1.29x speedup
    â–Ž
    image-rgb   world_map-800  458.83 0.37% -> 358.08 0.41%:  1.28x speedup
    â–Ž
     xlib-rgba  world_map-800  566.57 0.23% -> 463.84 0.31%:  1.22x speedup
    â–Ž
     xlib-rgb   world_map-800  562.31 0.64% -> 460.51 0.83%:  1.22x speedup
    â–Ž

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index d6f5588..86dd074 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -201,7 +201,6 @@ _cairo_stroker_face_clockwise (cairo_str
 static cairo_status_t
 _cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_stroke_face_t *out)
 {
-    cairo_status_t	status;
     int			clockwise = _cairo_stroker_face_clockwise (out, in);
     cairo_point_t	*inpt, *outpt;
 
@@ -296,8 +295,8 @@ _cairo_stroker_join (cairo_stroker_t *st
 	    double		x1, y1, x2, y2;
 	    double		mx, my;
 	    double		dx1, dx2, dy1, dy2;
-	    cairo_polygon_t	polygon;
 	    cairo_point_t	outer;
+	    cairo_point_t	quad[4];
 
 	    /*
 	     * we've got the points already transformed to device
@@ -339,18 +338,13 @@ _cairo_stroker_join (cairo_stroker_t *st
 	     */
 	    outer.x = _cairo_fixed_from_double (mx);
 	    outer.y = _cairo_fixed_from_double (my);
-	    _cairo_polygon_init (&polygon);
-	    _cairo_polygon_move_to (&polygon, &in->point);
-	    _cairo_polygon_line_to (&polygon, inpt);
-	    _cairo_polygon_line_to (&polygon, &outer);
-	    _cairo_polygon_line_to (&polygon, outpt);
-	    _cairo_polygon_close (&polygon);
-	    status = _cairo_traps_tessellate_polygon (stroker->traps,
-						      &polygon,
-						      CAIRO_FILL_RULE_WINDING);
-	    _cairo_polygon_fini (&polygon);
 
-	    return status;
+	    quad[0] = in->point;
+	    quad[1] = *inpt;
+	    quad[2] = outer;
+	    quad[3] = *outpt;
+
+	    return _cairo_traps_tessellate_convex_quad (stroker->traps, quad);
 	}
 	/* fall through ... */
     }
diff-tree 3d53f623faed4aed2517e207d77a6da7e3b74fbd (from fefa7d9b993b1fc0759cfe1f8faff8dec9dc5c85)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Nov 10 12:56:32 2006 -0800

    Make _cairo_stroker_add_sub_edge use tessellate_convex_quad rather than tessellate_polygon
    
    This gives a 17-20% speedup for stroking polygons with many
    straight line segments as seen in the world_map test case:
    
    Speedups
    ========
    image-rgba  world_map-800  555.41 0.17% -> 460.69 0.20%:  1.21x speedup
    â–Ž
    image-rgb   world_map-800  554.91 0.25% -> 460.73 0.26%:  1.20x speedup
    â–Ž
     xlib-rgb   world_map-800  669.85 3.70% -> 570.31 0.24%:  1.17x speedup
    ▏
     xlib-rgba  world_map-800  663.71 0.46% -> 567.74 0.19%:  1.17x speedup
    ▏

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 792fbfa..d6f5588 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -573,8 +573,7 @@ _cairo_stroker_add_sub_edge (cairo_strok
 			     cairo_slope_t *slope, cairo_stroke_face_t *start,
 			     cairo_stroke_face_t *end)
 {
-    cairo_status_t status;
-    cairo_polygon_t polygon;
+    cairo_point_t rectangle[4];
 
     _compute_face (p1, slope, stroker, start);
 
@@ -586,30 +585,12 @@ _cairo_stroker_add_sub_edge (cairo_strok
     if (p1->x == p2->x && p1->y == p2->y)
 	return CAIRO_STATUS_SUCCESS;
 
-    /* XXX: I should really check the return value of the
-       move_to/line_to functions here to catch out of memory
-       conditions. But since that would be ugly, I'd prefer to add a
-       status flag to the polygon object that I could check only once
-       at then end of this sequence, (like we do with cairo_t
-       already). */
-    _cairo_polygon_init (&polygon);
-    _cairo_polygon_move_to (&polygon, &start->cw);
-    _cairo_polygon_line_to (&polygon, &start->ccw);
-    _cairo_polygon_line_to (&polygon, &end->ccw);
-    _cairo_polygon_line_to (&polygon, &end->cw);
-    _cairo_polygon_close (&polygon);
-
-    /* XXX: We can't use tessellate_rectangle as the matrix may have
-       skewed this into a non-rectangular shape. Perhaps it would be
-       worth checking the matrix for skew so that the common case
-       could use the faster tessellate_rectangle rather than
-       tessellate_polygon? */
-    status = _cairo_traps_tessellate_polygon (stroker->traps,
-					      &polygon, CAIRO_FILL_RULE_WINDING);
-
-    _cairo_polygon_fini (&polygon);
+    rectangle[0] = start->cw;
+    rectangle[1] = start->ccw;
+    rectangle[2] = end->ccw;
+    rectangle[3] = end->cw;
 
-    return status;
+    return _cairo_traps_tessellate_convex_quad (stroker->traps, rectangle);
 }
 
 static cairo_status_t
diff-tree fefa7d9b993b1fc0759cfe1f8faff8dec9dc5c85 (from e324bbcbc6ca86a714aa91fe5cd010a4ce4f1753)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Nov 10 12:53:33 2006 -0800

    Rewrite tessellate_rectangle as tessellate_convex_quad to make it more useful
    
    Currently there aren't even any users of this code, (they had
    stopped using it when they realized what they really wanted
    was tessellate_convex_quad).

diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 6aea868..0f0d333 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -367,26 +367,121 @@ _cairo_traps_tessellate_triangle (cairo_
     return traps->status;
 }
 
-/* Warning: This function reorders the elements of the array provided. */
 cairo_status_t
-_cairo_traps_tessellate_rectangle (cairo_traps_t *traps, cairo_point_t q[4])
+_cairo_traps_tessellate_convex_quad (cairo_traps_t *traps, cairo_point_t q[4])
 {
-    qsort (q, 4, sizeof (cairo_point_t), _compare_point_fixed_by_y);
+    int a, b, c, d;
+    int i;
+
+    /* Choose a as a point with minimal y */
+    a = 0;
+    for (i = 1; i < 4; i++)
+	if (_compare_point_fixed_by_y (&q[i], &q[a]) < 0)
+	    a = i;
+
+    /* b and c are adjacent to a, while c is opposite */
+    b = (a + 1) % 4;
+    c = (a + 2) % 4;
+    d = (a + 3) % 4;
+
+    /* Choose between b and d so that b.y is less than d.y */
+    if (_compare_point_fixed_by_y (&q[d], &q[b]) < 0) {
+	b = (a + 3) % 4;
+	d = (a + 1) % 4;
+    }
 
-    if (q[1].x > q[2].x) {
-	_cairo_traps_add_trap_from_points (traps,
-					   q[0].y, q[1].y, q[0], q[2], q[0], q[1]);
-	_cairo_traps_add_trap_from_points (traps,
-					   q[1].y, q[2].y, q[0], q[2], q[1], q[3]);
-	_cairo_traps_add_trap_from_points (traps,
-					   q[2].y, q[3].y, q[2], q[3], q[1], q[3]);
+    /* Without freedom left to choose anything else, we have four
+     * cases to tessellate which we can distinguish by comparing c.y
+     * to d.y and then by comparing b.x to d.x. And then for any of
+     * these cases there is a trivial way to emit three
+     * trapezoids. The 4 cases and their trapezoids are described and
+     * implemented below:
+     */
+    if (q[c].y < q[d].y) {
+	if (q[b].x < q[d].x) {
+	    /* c.y < d.y && b.x < d.x
+	     *
+	     *           top bot left right
+	     *   a
+	     *  / |      a.y b.y  ab   ad
+	     * b  |
+	     * |  |      b.y c.y  bc   ad
+	     * c  |
+	     *  \ |      c.y d.y  cd   ad
+	     *   d
+	     */
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[a].y, q[b].y,
+					       q[a], q[b], q[a], q[d]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[b].y, q[c].y,
+					       q[b], q[c], q[a], q[d]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[c].y, q[d].y,
+					       q[c], q[d], q[a], q[d]);
+	} else {
+	    /* c.y < d.y && b.x >= d.x
+	     *
+	     *  a
+	     * | \       a.y b.y  ad  ab
+	     * |  b
+	     * |  |      b.y c.y  ad  bc
+	     * |  c
+	     * | /       c.y d.y  ad  cd
+	     *  d
+	     */
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[a].y, q[b].y,
+					       q[a], q[d], q[a], q[b]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[b].y, q[c].y,
+					       q[a], q[d], q[b], q[c]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[c].y, q[d].y,
+					       q[a], q[d], q[c], q[d]);
+	}
     } else {
-	_cairo_traps_add_trap_from_points (traps,
-					   q[0].y, q[1].y, q[0], q[1], q[0], q[2]);
-	_cairo_traps_add_trap_from_points (traps,
-					   q[1].y, q[2].y, q[1], q[3], q[0], q[2]);
-	_cairo_traps_add_trap_from_points (traps,
-					   q[2].y, q[3].y, q[1], q[3], q[2], q[3]);
+	if (q[b].x < q[d].x) {
+	    /* c.y >= d.y && b.x < d.x
+	     *
+	     *   a
+	     *  / \      a.y b.y  ab  ad
+	     * b   \
+	     *  \   \    b.y d.y  bc  ad
+	     *   \   d
+	     *    \ /    d.y c.y  bc  dc
+	     *     c
+	     */
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[a].y, q[b].y,
+					       q[a], q[b], q[a], q[d]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[b].y, q[d].y,
+					       q[b], q[c], q[a], q[d]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[d].y, q[c].y,
+					       q[b], q[c], q[d], q[c]);
+	} else {
+	    /* c.y >= d.y && b.x >= d.x
+	     *
+	     *     a
+	     *    / \    a.y b.y  ad  ab
+	     *   /   b
+	     *  /   /    b.y d.y  ad  bc
+	     * d   /
+	     *  \ /      d.y c.y  dc  bc
+	     *   c
+	     */
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[a].y, q[b].y,
+					       q[a], q[d], q[a], q[b]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[b].y, q[d].y,
+					       q[a], q[d], q[b], q[c]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       q[d].y, q[c].y,
+					       q[d], q[c], q[b], q[c]);
+	}
     }
 
     return traps->status;
diff --git a/src/cairoint.h b/src/cairoint.h
index 7c4caf2..1f86fba 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2223,7 +2223,7 @@ cairo_private cairo_status_t
 _cairo_traps_tessellate_triangle (cairo_traps_t *traps, cairo_point_t t[3]);
 
 cairo_private cairo_status_t
-_cairo_traps_tessellate_rectangle (cairo_traps_t *traps, cairo_point_t q[4]);
+_cairo_traps_tessellate_convex_quad (cairo_traps_t *traps, cairo_point_t q[4]);
 
 cairo_private cairo_status_t
 _cairo_traps_tessellate_polygon (cairo_traps_t *traps,
diff-tree e324bbcbc6ca86a714aa91fe5cd010a4ce4f1753 (from 74f5fe241e6ce424a7d56a0ae48ddad202b82248)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Nov 10 12:37:01 2006 -0800

    Add a status field to cairo_traps_t to enable less error checking

diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 107276c..6aea868 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -69,6 +69,8 @@ _line_segs_intersect_ceil (cairo_line_t 
 void
 _cairo_traps_init (cairo_traps_t *traps)
 {
+    traps->status = CAIRO_STATUS_SUCCESS;
+
     traps->num_traps = 0;
 
     traps->traps_size = 0;
@@ -101,13 +103,11 @@ cairo_status_t
 _cairo_traps_init_box (cairo_traps_t *traps,
 		       cairo_box_t   *box)
 {
-  cairo_status_t status;
-
   _cairo_traps_init (traps);
 
-  status = _cairo_traps_grow_by (traps, 1);
-  if (status)
-    return status;
+  traps->status = _cairo_traps_grow_by (traps, 1);
+  if (traps->status)
+    return traps->status;
 
   traps->num_traps = 1;
 
@@ -122,25 +122,27 @@ _cairo_traps_init_box (cairo_traps_t *tr
 
   traps->extents = *box;
 
-  return CAIRO_STATUS_SUCCESS;
+  return traps->status;
 }
 
 static cairo_status_t
 _cairo_traps_add_trap (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
 		       cairo_line_t *left, cairo_line_t *right)
 {
-    cairo_status_t status;
     cairo_trapezoid_t *trap;
 
+    if (traps->status)
+	return traps->status;
+
     if (top == bottom) {
 	return CAIRO_STATUS_SUCCESS;
     }
 
     if (traps->num_traps >= traps->traps_size) {
 	int inc = traps->traps_size ? traps->traps_size : 32;
-	status = _cairo_traps_grow_by (traps, inc);
-	if (status)
-	    return status;
+	traps->status = _cairo_traps_grow_by (traps, inc);
+	if (traps->status)
+	    return traps->status;
     }
 
     trap = &traps->traps[traps->num_traps];
@@ -173,7 +175,7 @@ _cairo_traps_add_trap (cairo_traps_t *tr
 
     traps->num_traps++;
 
-    return CAIRO_STATUS_SUCCESS;
+    return traps->status;
 }
 
 static cairo_status_t
@@ -184,6 +186,9 @@ _cairo_traps_add_trap_from_points (cairo
     cairo_line_t left;
     cairo_line_t right;
 
+    if (traps->status)
+	return traps->status;
+
     left.p1 = left_p1;
     left.p2 = left_p2;
 
@@ -200,21 +205,24 @@ _cairo_traps_grow_by (cairo_traps_t *tra
     int old_size = traps->traps_size;
     int new_size = traps->num_traps + additional;
 
-    if (new_size <= traps->traps_size) {
-	return CAIRO_STATUS_SUCCESS;
-    }
+    if (traps->status)
+	return traps->status;
+
+    if (new_size <= traps->traps_size)
+	return traps->status;
 
     traps->traps_size = new_size;
     new_traps = realloc (traps->traps, traps->traps_size * sizeof (cairo_trapezoid_t));
 
     if (new_traps == NULL) {
 	traps->traps_size = old_size;
-	return CAIRO_STATUS_NO_MEMORY;
+	traps->status = CAIRO_STATUS_NO_MEMORY;
+	return traps->status;
     }
 
     traps->traps = new_traps;
 
-    return CAIRO_STATUS_SUCCESS;
+    return traps->status;
 }
 
 static int
@@ -309,7 +317,6 @@ _cairo_trapezoid_array_translate_and_sca
 cairo_status_t
 _cairo_traps_tessellate_triangle (cairo_traps_t *traps, cairo_point_t t[3])
 {
-    cairo_status_t status;
     cairo_line_t line;
     cairo_fixed_16_16_t intersect;
     cairo_point_t tsort[3];
@@ -320,16 +327,16 @@ _cairo_traps_tessellate_triangle (cairo_
     /* horizontal top edge requires special handling */
     if (tsort[0].y == tsort[1].y) {
 	if (tsort[0].x < tsort[1].x)
-	    status = _cairo_traps_add_trap_from_points (traps,
-							tsort[1].y, tsort[2].y,
-							tsort[0], tsort[2],
-							tsort[1], tsort[2]);
+	    _cairo_traps_add_trap_from_points (traps,
+					       tsort[1].y, tsort[2].y,
+					       tsort[0], tsort[2],
+					       tsort[1], tsort[2]);
 	else
-	    status = _cairo_traps_add_trap_from_points (traps,
-							tsort[1].y, tsort[2].y,
-							tsort[1], tsort[2],
-							tsort[0], tsort[2]);
-	return status;
+	    _cairo_traps_add_trap_from_points (traps,
+					       tsort[1].y, tsort[2].y,
+					       tsort[1], tsort[2],
+					       tsort[0], tsort[2]);
+	return traps->status;
     }
 
     line.p1 = tsort[0];
@@ -338,73 +345,51 @@ _cairo_traps_tessellate_triangle (cairo_
     intersect = _compute_x (&line, tsort[2].y);
 
     if (intersect < tsort[2].x) {
-	status = _cairo_traps_add_trap_from_points (traps,
-						    tsort[0].y, tsort[1].y,
-						    tsort[0], tsort[1],
-						    tsort[0], tsort[2]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    tsort[1].y, tsort[2].y,
-						    tsort[1], tsort[2],
-						    tsort[0], tsort[2]);
-	if (status)
-	    return status;
+	_cairo_traps_add_trap_from_points (traps,
+					   tsort[0].y, tsort[1].y,
+					   tsort[0], tsort[1],
+					   tsort[0], tsort[2]);
+	_cairo_traps_add_trap_from_points (traps,
+					   tsort[1].y, tsort[2].y,
+					   tsort[1], tsort[2],
+					   tsort[0], tsort[2]);
     } else {
-	status = _cairo_traps_add_trap_from_points (traps,
-						    tsort[0].y, tsort[1].y,
-						    tsort[0], tsort[2],
-						    tsort[0], tsort[1]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    tsort[1].y, tsort[2].y,
-						    tsort[0], tsort[2],
-						    tsort[1], tsort[2]);
-	if (status)
-	    return status;
+	_cairo_traps_add_trap_from_points (traps,
+					   tsort[0].y, tsort[1].y,
+					   tsort[0], tsort[2],
+					   tsort[0], tsort[1]);
+	_cairo_traps_add_trap_from_points (traps,
+					   tsort[1].y, tsort[2].y,
+					   tsort[0], tsort[2],
+					   tsort[1], tsort[2]);
     }
 
-    return CAIRO_STATUS_SUCCESS;
+    return traps->status;
 }
 
 /* Warning: This function reorders the elements of the array provided. */
 cairo_status_t
 _cairo_traps_tessellate_rectangle (cairo_traps_t *traps, cairo_point_t q[4])
 {
-    cairo_status_t status;
-
     qsort (q, 4, sizeof (cairo_point_t), _compare_point_fixed_by_y);
 
     if (q[1].x > q[2].x) {
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[0].y, q[1].y, q[0], q[2], q[0], q[1]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[1].y, q[2].y, q[0], q[2], q[1], q[3]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[2].y, q[3].y, q[2], q[3], q[1], q[3]);
-	if (status)
-	    return status;
+	_cairo_traps_add_trap_from_points (traps,
+					   q[0].y, q[1].y, q[0], q[2], q[0], q[1]);
+	_cairo_traps_add_trap_from_points (traps,
+					   q[1].y, q[2].y, q[0], q[2], q[1], q[3]);
+	_cairo_traps_add_trap_from_points (traps,
+					   q[2].y, q[3].y, q[2], q[3], q[1], q[3]);
     } else {
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[0].y, q[1].y, q[0], q[1], q[0], q[2]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[1].y, q[2].y, q[1], q[3], q[0], q[2]);
-	if (status)
-	    return status;
-	status = _cairo_traps_add_trap_from_points (traps,
-						    q[2].y, q[3].y, q[1], q[3], q[2], q[3]);
-	if (status)
-	    return status;
+	_cairo_traps_add_trap_from_points (traps,
+					   q[0].y, q[1].y, q[0], q[1], q[0], q[2]);
+	_cairo_traps_add_trap_from_points (traps,
+					   q[1].y, q[2].y, q[1], q[3], q[0], q[2]);
+	_cairo_traps_add_trap_from_points (traps,
+					   q[2].y, q[3].y, q[1], q[3], q[2], q[3]);
     }
 
-    return CAIRO_STATUS_SUCCESS;
+    return traps->status;
 }
 
 static int
@@ -730,7 +715,6 @@ _cairo_traps_tessellate_polygon (cairo_t
 				 cairo_polygon_t	*poly,
 				 cairo_fill_rule_t	fill_rule)
 {
-    cairo_status_t	status;
     int 		i, active, inactive;
     cairo_fixed_t	y, y_next, intersect;
     int			in_out, num_edges = poly->num_edges;
@@ -786,9 +770,7 @@ _cairo_traps_tessellate_polygon (cairo_t
 		if ((in_out & 1) == 0)
 		    continue;
 	    }
-	    status = _cairo_traps_add_trap (traps, y, y_next, &edges[i].edge, &edges[i+1].edge);
-	    if (status)
-		return status;
+	    _cairo_traps_add_trap (traps, y, y_next, &edges[i].edge, &edges[i+1].edge);
 	}
 
 	/* delete inactive edges */
@@ -801,7 +783,7 @@ _cairo_traps_tessellate_polygon (cairo_t
 
 	y = y_next;
     }
-    return CAIRO_STATUS_SUCCESS;
+    return traps->status;
 }
 
 static cairo_bool_t
diff --git a/src/cairoint.h b/src/cairoint.h
index d15064d..7c4caf2 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1098,6 +1098,8 @@ typedef struct _cairo_surface_attributes
 } cairo_surface_attributes_t;
 
 typedef struct _cairo_traps {
+    cairo_status_t status;
+
     cairo_trapezoid_t *traps;
     int num_traps;
     int traps_size;
diff-tree 74f5fe241e6ce424a7d56a0ae48ddad202b82248 (from 26b74049e79a6137e8556e1b3e5c3aedd780abb0)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Nov 13 14:44:07 2006 -0800

    cairo-perf-diff: rsync only git-managed files from boilerplate/perf
    
    Previously, we were using rsync to recursively copy all files
    from boilerplate and perf when doing the performance tests. This
    had the fatal flaw that pre-built binaries would be hard coded to
    link against the cairo library from $CAIRO_DIR with an absolute
    path, (due to libtool rpath stuff).
    
    By only copying git-managed files, we only get source and the compiled
    binaries (or libtool wrappers) will now be hard-coded to link against
    the library under test.

diff --git a/perf/cairo-perf-diff b/perf/cairo-perf-diff
index 0ef32eb..1f2089e 100755
--- a/perf/cairo-perf-diff
+++ b/perf/cairo-perf-diff
@@ -116,20 +116,30 @@ run_cairo_perf_if_not_cached() {
 	echo "Creating new perf cache in $CAIRO_PERF_DIR"
 	mkdir $CAIRO_PERF_DIR
     fi
+
+    boilerplate_files=$(git ls-tree --name-only HEAD boilerplate/*)
+    perf_files=$(git ls-tree --name-only HEAD perf/*)
     cd $CAIRO_PERF_DIR
 
     if [ ! -d $build_dir ]; then
 	git clone -s $CAIRO_DIR $build_dir
-	(cd $build_dir; git checkout -b tmp-cairo-perf-diff $sha; CFLAGS="-O2" ./autogen.sh)
+	(cd $build_dir; git checkout -b tmp-cairo-perf-diff $sha)
     fi
     cd $build_dir
 
     git checkout tmp-cairo-perf-diff
     git reset --hard $sha
+    if [ ! -e Makefile ]; then
+	CFLAGS="-O2" ./autogen.sh
+    fi
     make CFLAGS="-O2" || (rm config.cache && make CFLAGS="-O2")
-    rsync -rl $CAIRO_DIR/boilerplate .
+    for file in $boilerplate_files; do
+	rsync $CAIRO_DIR/$file boilerplate
+    done
     (cd boilerplate; make)
-    rsync -rl $CAIRO_DIR/perf .
+    for file in $perf_files; do
+	rsync $CAIRO_DIR/$file perf
+    done
     cd perf;
     make || exit 1
     echo "Running \"cairo-perf $CAIRO_PERF_OPTIONS\" against $rev. Results will be cached in:"


More information about the cairo-commit mailing list