summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-03 08:45:40 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-03 10:07:34 +0100
commitdf067be863bf714f22db0392ab29926edfa8e917 (patch)
tree5ee1d0a53d5485111ecef207410acc377cce29f3
parenta1bac73f24069990842fa8f31e776b4d2c72546e (diff)
[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.
-rw-r--r--src/cairo-polygon.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 904b33d3..9cb76e55 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;
+ }
}
}