diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-19 21:12:55 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-23 23:55:38 +0100 |
commit | 0a4a6213e2ab915098b6fdc8bd2652cd5026599c (patch) | |
tree | 0bfde4c621b5b2231a980df39ff7cd4a3983c2df /src/cairo-path-fill.c | |
parent | 8f51ea4657d872f75e1a6493aadcc769fd3b9324 (diff) | |
download | cairo-0a4a6213e2ab915098b6fdc8bd2652cd5026599c.tar.gz |
[fill] Check for the most common rectilinear case first.
Avoid the iterative search for the extreme points by first checking the
most likely arrangement (as produced by cairo_rectangle() under no
transformation).
Diffstat (limited to 'src/cairo-path-fill.c')
-rw-r--r-- | src/cairo-path-fill.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c index 755579883..1cef20e4a 100644 --- a/src/cairo-path-fill.c +++ b/src/cairo-path-fill.c @@ -217,15 +217,19 @@ _cairo_path_fixed_fill_rectangle (cairo_path_fixed_t *path, if (_cairo_path_fixed_is_box (path, NULL)) { cairo_point_t *p = path->buf_head.base.points; cairo_point_t *top_left, *bot_right; - int n; top_left = &p[0]; - bot_right = &p[0]; - for (n = 1; n < 4; n++) { - if (p[n].x <= top_left->x && p[n].y <= top_left->y) - top_left = &p[n]; - if (p[n].x >= bot_right->x && p[n].y >= bot_right->y) - bot_right = &p[n]; + bot_right = &p[2]; + if (top_left->x > bot_right->x || top_left->y > bot_right->y) { + int n; + + /* not a simple cairo_rectangle() */ + for (n = 0; n < 4; n++) { + if (p[n].x <= top_left->x && p[n].y <= top_left->y) + top_left = &p[n]; + if (p[n].x >= bot_right->x && p[n].y >= bot_right->y) + bot_right = &p[n]; + } } return _cairo_traps_tessellate_rectangle (traps, top_left, bot_right); |