[cairo-commit] src/cairo-polygon.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Sep 3 02:07:47 PDT 2009


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

New commits:
commit df067be863bf714f22db0392ab29926edfa8e917
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 3 08:45:40 2009 +0100

    [polygon] Compute the limit of the limits slightly more efficiently
    
    Initialize the bbox to the first limit, as frequently there will only be a
    single (or at least a small number) limit.

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 904b33d..9cb76e5 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -68,21 +68,21 @@ _cairo_polygon_limit (cairo_polygon_t	*polygon,
     polygon->limits = limits;
     polygon->num_limits = num_limits;
 
-    polygon->limit.p1.x = polygon->limit.p1.y = INT32_MAX;
-    polygon->limit.p2.x = polygon->limit.p2.y = INT32_MIN;
-
-    for (n = 0; n < num_limits; n++) {
-	if (limits[n].p1.x < polygon->limit.p1.x)
-	    polygon->limit.p1.x = limits[n].p1.x;
+    if (polygon->num_limits) {
+	polygon->limit = limits[0];
+	for (n = 1; n < num_limits; n++) {
+	    if (limits[n].p1.x < polygon->limit.p1.x)
+		polygon->limit.p1.x = limits[n].p1.x;
 
-	if (limits[n].p1.y < polygon->limit.p1.y)
-	    polygon->limit.p1.y = limits[n].p1.y;
+	    if (limits[n].p1.y < polygon->limit.p1.y)
+		polygon->limit.p1.y = limits[n].p1.y;
 
-	if (limits[n].p2.x > polygon->limit.p2.x)
-	    polygon->limit.p2.x = limits[n].p2.x;
+	    if (limits[n].p2.x > polygon->limit.p2.x)
+		polygon->limit.p2.x = limits[n].p2.x;
 
-	if (limits[n].p2.y > polygon->limit.p2.y)
-	    polygon->limit.p2.y = limits[n].p2.y;
+	    if (limits[n].p2.y > polygon->limit.p2.y)
+		polygon->limit.p2.y = limits[n].p2.y;
+	}
     }
 }
 


More information about the cairo-commit mailing list