diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-29 08:02:52 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-29 17:07:40 +0100 |
commit | 5393aa6d6c4676f20d316f3cd0a18bb497574e50 (patch) | |
tree | 6b95c7aed37cc4774498cb9469d27478528977ac /src/cairo-path-fixed.c | |
parent | afea5eb79d2159fe9a5dc1a1a7b9445e40fbb474 (diff) |
[path] Return the canonical box.
When returning the single box that represents a path, always return it
consistently wound.
Diffstat (limited to 'src/cairo-path-fixed.c')
-rw-r--r-- | src/cairo-path-fixed.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index a1a8184d..4a2ce014 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -1100,6 +1100,28 @@ _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path, &flattener); } +static inline void +_canonical_box (cairo_box_t *box, + const cairo_point_t *p1, + const cairo_point_t *p2) +{ + if (p1->x <= p2->x) { + box->p1.x = p1->x; + box->p2.x = p2->x; + } else { + box->p1.x = p2->x; + box->p2.x = p1->x; + } + + if (p1->y <= p2->y) { + box->p1.y = p1->y; + box->p2.y = p2->y; + } else { + box->p1.y = p2->y; + box->p2.y = p1->y; + } +} + /* * Check whether the given path contains a single rectangle. */ @@ -1152,8 +1174,7 @@ _cairo_path_fixed_is_box (const cairo_path_fixed_t *path, buf->points[2].y == buf->points[3].y && buf->points[3].x == buf->points[0].x) { - box->p1 = buf->points[0]; - box->p2 = buf->points[2]; + _canonical_box (box, &buf->points[0], &buf->points[2]); return TRUE; } @@ -1162,8 +1183,7 @@ _cairo_path_fixed_is_box (const cairo_path_fixed_t *path, buf->points[2].x == buf->points[3].x && buf->points[3].y == buf->points[0].y) { - box->p1 = buf->points[0]; - box->p2 = buf->points[2]; + _canonical_box (box, &buf->points[0], &buf->points[2]); return TRUE; } |