mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 09:58:12 +02:00
[path] Return the canonical box.
When returning the single box that represents a path, always return it consistently wound.
This commit is contained in:
parent
afea5eb79d
commit
5393aa6d6c
2 changed files with 24 additions and 36 deletions
|
|
@ -247,22 +247,6 @@ _cairo_path_fixed_fill_rectilinear_to_region (const cairo_path_fixed_t *path,
|
|||
assert (! path->is_empty_fill);
|
||||
|
||||
if (_cairo_path_fixed_is_box (path, &box)) {
|
||||
if (box.p1.x > box.p2.x) {
|
||||
cairo_fixed_t t;
|
||||
|
||||
t = box.p1.x;
|
||||
box.p1.x = box.p2.x;
|
||||
box.p2.x = t;
|
||||
}
|
||||
|
||||
if (box.p1.y > box.p2.y) {
|
||||
cairo_fixed_t t;
|
||||
|
||||
t = box.p1.y;
|
||||
box.p1.y = box.p2.y;
|
||||
box.p2.y = t;
|
||||
}
|
||||
|
||||
rectangle_stack[0].x = _cairo_fixed_integer_part (box.p1.x);
|
||||
rectangle_stack[0].y = _cairo_fixed_integer_part (box.p1.y);
|
||||
rectangle_stack[0].width = _cairo_fixed_integer_part (box.p2.x) -
|
||||
|
|
@ -375,22 +359,6 @@ _cairo_path_fixed_fill_rectilinear_to_traps (const cairo_path_fixed_t *path,
|
|||
traps->is_rectangular = TRUE;
|
||||
|
||||
if (_cairo_path_fixed_is_box (path, &box)) {
|
||||
if (box.p1.x > box.p2.x) {
|
||||
cairo_fixed_t t;
|
||||
|
||||
t = box.p1.x;
|
||||
box.p1.x = box.p2.x;
|
||||
box.p2.x = t;
|
||||
}
|
||||
|
||||
if (box.p1.y > box.p2.y) {
|
||||
cairo_fixed_t t;
|
||||
|
||||
t = box.p1.y;
|
||||
box.p1.y = box.p2.y;
|
||||
box.p2.y = t;
|
||||
}
|
||||
|
||||
return _cairo_traps_tessellate_rectangle (traps, &box.p1, &box.p2);
|
||||
} else {
|
||||
cairo_path_fixed_iter_t iter;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue