diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-11 10:59:17 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-11 10:59:17 +0100 |
commit | 290749bdb5c634c030db81722214661c34344403 (patch) | |
tree | b2c5f24f8eb9aa598938641bf6bdcb723ead7fc6 /src/cairo-polygon.c | |
parent | 55037bfb2454a671332d961e061c712ab5471580 (diff) | |
download | cairo-290749bdb5c634c030db81722214661c34344403.tar.gz |
polygon: Reorder conditionals based on likelihood.
The vast majority of edges will be unclipped, so process those first.
Diffstat (limited to 'src/cairo-polygon.c')
-rw-r--r-- | src/cairo-polygon.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c index 49ba7a33c..64fef47e1 100644 --- a/src/cairo-polygon.c +++ b/src/cairo-polygon.c @@ -140,7 +140,7 @@ _add_edge (cairo_polygon_t *polygon, assert (top < bottom); - if (polygon->num_edges == polygon->edges_size) { + if (unlikely (polygon->num_edges == polygon->edges_size)) { if (! _cairo_polygon_grow (polygon)) return; } @@ -197,7 +197,20 @@ _add_clipped_edge (cairo_polygon_t *polygon, if (bottom <= limits->p1.y) continue; - if (p1->x <= limits->p1.x && p2->x <= limits->p1.x) + if (p1->x >= limits->p1.x && p2->x >= limits->p1.x && + p1->x <= limits->p2.x && p2->x <= limits->p2.x) + { + top_y = top; + if (top_y < limits->p1.y) + top_y = limits->p1.y; + + bot_y = bottom; + if (bot_y > limits->p2.y) + bot_y = limits->p2.y; + + _add_edge (polygon, p1, p2, top_y, bot_y, dir); + } + else if (p1->x <= limits->p1.x && p2->x <= limits->p1.x) { p[0].x = limits->p1.x; p[0].y = limits->p1.y; @@ -229,19 +242,6 @@ _add_clipped_edge (cairo_polygon_t *polygon, _add_edge (polygon, &p[0], &p[1], top_y, bot_y, dir); } - else if (p1->x >= limits->p1.x && p2->x >= limits->p1.x && - p1->x <= limits->p2.x && p2->x <= limits->p2.x) - { - top_y = top; - if (top_y < limits->p1.y) - top_y = limits->p1.y; - - bot_y = bottom; - if (bot_y > limits->p2.y) - bot_y = limits->p2.y; - - _add_edge (polygon, p1, p2, top_y, bot_y, dir); - } else { int left_y, right_y; |