mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-08 11:50:26 +01:00
Fix this function again. Problem with signed/unsigned types reported by Jeff Muizelaar <jrmuizel@nit.ca>.
This commit is contained in:
parent
db2eb5d4cb
commit
85db25b8a1
3 changed files with 26 additions and 14 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2005-02-27 Kristian Høgsberg <krh@redhat.com>
|
||||
|
||||
* src/cairo_gstate.c (_cairo_rectangle_intersect): Fix this
|
||||
function again. Problem with signed/unsigned types reported by
|
||||
Jeff Muizelaar <jrmuizel@nit.ca>.
|
||||
|
||||
2005-02-27 Kristian Høgsberg <krh@redhat.com>
|
||||
|
||||
* src/cairo.h (cairo_fill_rule_t): Remove newline in comment which
|
||||
|
|
|
|||
|
|
@ -1407,20 +1407,23 @@ _cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_t *rectangle)
|
|||
static void
|
||||
_cairo_rectangle_intersect (cairo_rectangle_t *dest, cairo_rectangle_t *src)
|
||||
{
|
||||
cairo_rectangle_t out;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
out.x = MAX (dest->x, src->x);
|
||||
out.y = MAX (dest->y, src->y);
|
||||
out.width = MIN (dest->x + dest->width, src->x + src->width) - out.x;
|
||||
out.height = MIN (dest->y + dest->height, src->y + src->height) - out.y;
|
||||
x1 = MAX (dest->x, src->x);
|
||||
y1 = MAX (dest->y, src->y);
|
||||
x2 = MIN (dest->x + dest->width, src->x + src->width);
|
||||
y2 = MIN (dest->y + dest->height, src->y + src->height);
|
||||
|
||||
if (out.width <= 0 || out.height <= 0) {
|
||||
if (x1 >= x2 || y1 >= y2) {
|
||||
dest->x = 0;
|
||||
dest->y = 0;
|
||||
dest->width = 0;
|
||||
dest->height = 0;
|
||||
} else {
|
||||
*dest = out;
|
||||
dest->x = x1;
|
||||
dest->y = y1;
|
||||
dest->width = x2 - x1;
|
||||
dest->height = y2 - y1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1407,20 +1407,23 @@ _cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_t *rectangle)
|
|||
static void
|
||||
_cairo_rectangle_intersect (cairo_rectangle_t *dest, cairo_rectangle_t *src)
|
||||
{
|
||||
cairo_rectangle_t out;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
out.x = MAX (dest->x, src->x);
|
||||
out.y = MAX (dest->y, src->y);
|
||||
out.width = MIN (dest->x + dest->width, src->x + src->width) - out.x;
|
||||
out.height = MIN (dest->y + dest->height, src->y + src->height) - out.y;
|
||||
x1 = MAX (dest->x, src->x);
|
||||
y1 = MAX (dest->y, src->y);
|
||||
x2 = MIN (dest->x + dest->width, src->x + src->width);
|
||||
y2 = MIN (dest->y + dest->height, src->y + src->height);
|
||||
|
||||
if (out.width <= 0 || out.height <= 0) {
|
||||
if (x1 >= x2 || y1 >= y2) {
|
||||
dest->x = 0;
|
||||
dest->y = 0;
|
||||
dest->width = 0;
|
||||
dest->height = 0;
|
||||
} else {
|
||||
*dest = out;
|
||||
dest->x = x1;
|
||||
dest->y = y1;
|
||||
dest->width = x2 - x1;
|
||||
dest->height = y2 - y1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue