summaryrefslogtreecommitdiff
path: root/src/cairo-path-fixed.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-08-09 15:15:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-08-09 16:06:50 +0100
commit323e48f8ec2b6de467971d4e4a7fb45f56416e1e (patch)
treebe1b0da9ca988880b887bd1abb17f3eb2f59b556 /src/cairo-path-fixed.c
parent786d4b2a2af53efc6121fd4be04038f2262adf39 (diff)
fill: A horizontal/vertical line is also a degenerate fill box
Since we discard empty fill boxes whilst filling, we can also treat horizontal/vertical lines as a filled box and so proceed with the rectangular fast path in the presence of cairo_rectangle (x, y, w, h) with w == 0 || h == 0. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-path-fixed.c')
-rw-r--r--src/cairo-path-fixed.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 58d4f4b20..7af45f86a 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -1338,11 +1338,8 @@ _cairo_path_fixed_iter_is_fill_box (cairo_path_fixed_iter_t *_iter,
iter = *_iter;
- if (iter.n_op == iter.buf->num_ops &&
- ! _cairo_path_fixed_iter_next_op (&iter))
- {
+ if (iter.n_op == iter.buf->num_ops && ! _cairo_path_fixed_iter_next_op (&iter))
return FALSE;
- }
/* Check whether the ops are those that would be used for a rectangle */
if (iter.buf->op[iter.n_op] != CAIRO_PATH_OP_MOVE_TO)
@@ -1357,8 +1354,20 @@ _cairo_path_fixed_iter_is_fill_box (cairo_path_fixed_iter_t *_iter,
if (! _cairo_path_fixed_iter_next_op (&iter))
return FALSE;
- if (iter.buf->op[iter.n_op] != CAIRO_PATH_OP_LINE_TO)
+ /* a horizontal/vertical closed line is also a degenerate rectangle */
+ switch (iter.buf->op[iter.n_op]) {
+ case CAIRO_PATH_OP_CLOSE_PATH:
+ _cairo_path_fixed_iter_next_op (&iter);
+ case CAIRO_PATH_OP_MOVE_TO: /* implicit close */
+ box->p1 = box->p2 = points[0];
+ *_iter = iter;
+ return TRUE;
+ default:
return FALSE;
+ case CAIRO_PATH_OP_LINE_TO:
+ break;
+ }
+
points[2] = iter.buf->points[iter.n_point++];
if (! _cairo_path_fixed_iter_next_op (&iter))
return FALSE;
@@ -1372,19 +1381,18 @@ _cairo_path_fixed_iter_is_fill_box (cairo_path_fixed_iter_t *_iter,
/* Now, there are choices. The rectangle might end with a LINE_TO
* (to the original point), but this isn't required. If it
* doesn't, then it must end with a CLOSE_PATH (which may be implicit). */
- if (iter.buf->op[iter.n_op] == CAIRO_PATH_OP_LINE_TO)
- {
+ if (iter.buf->op[iter.n_op] == CAIRO_PATH_OP_LINE_TO) {
points[4] = iter.buf->points[iter.n_point++];
if (points[4].x != points[0].x || points[4].y != points[0].y)
return FALSE;
- }
- else if (! (iter.buf->op[iter.n_op] == CAIRO_PATH_OP_CLOSE_PATH ||
- iter.buf->op[iter.n_op] == CAIRO_PATH_OP_MOVE_TO))
- {
+ _cairo_path_fixed_iter_next_op (&iter);
+ } else if (iter.buf->op[iter.n_op] == CAIRO_PATH_OP_CLOSE_PATH) {
+ _cairo_path_fixed_iter_next_op (&iter);
+ } else if (iter.buf->op[iter.n_op] == CAIRO_PATH_OP_MOVE_TO) {
+ /* implicit close-path */
+ } else {
return FALSE;
}
- if (! _cairo_path_fixed_iter_next_op (&iter))
- return FALSE;
/* Ok, we may have a box, if the points line up */
if (points[0].y == points[1].y &&