diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c index 83a5109..f3a2bf8 100644 --- a/src/cairo-glitz-surface.c +++ b/src/cairo-glitz-surface.c @@ -204,14 +204,10 @@ _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface, if (interest) { - if (interest->x > x1) - x1 = interest->x; - if (interest->y > y1) - y1 = interest->y; - if (interest->x + interest->width < x2) - x2 = interest->x + interest->width; - if (interest->y + interest->height < y2) - y2 = interest->y + interest->height; + x1 = MAX (x1, interest->x); + y1 = MAX (y1, interest->y); + x2 = MIN (x2, interest->x + interest->width); + y2 = MIN (y2, interest->y + interest->height); if (x1 >= x2 || y1 >= y2) { diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index bf99c40..7d15225 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -3537,14 +3537,10 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface, font_bbox.p2.x = bbox.p2.x; font_bbox.p2.y = bbox.p2.y; } else { - if (bbox.p1.x < font_bbox.p1.x) - font_bbox.p1.x = bbox.p1.x; - if (bbox.p1.y < font_bbox.p1.y) - font_bbox.p1.y = bbox.p1.y; - if (bbox.p2.x > font_bbox.p2.x) - font_bbox.p2.x = bbox.p2.x; - if (bbox.p2.y > font_bbox.p2.y) - font_bbox.p2.y = bbox.p2.y; + font_bbox.p1.x = MIN (font_bbox.p1.x, bbox.p1.x); + font_bbox.p1.y = MIN (font_bbox.p1.y, bbox.p1.y); + font_bbox.p2.x = MAX (font_bbox.p2.x, bbox.p2.x); + font_bbox.p2.y = MAX (font_bbox.p2.y, bbox.p2.y); } } diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 9a774e2..d86c3b8 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -2508,14 +2508,10 @@ _cairo_ps_surface_set_bounding_box (void *abstract_surface, surface->bbox_x2 = x2; surface->bbox_y2 = y2; } else { - if (x1 < surface->bbox_x1) - surface->bbox_x1 = x1; - if (y1 < surface->bbox_y1) - surface->bbox_y1 = y1; - if (x2 > surface->bbox_x2) - surface->bbox_x2 = x2; - if (y2 > surface->bbox_y2) - surface->bbox_y2 = y2; + surface->bbox_x1 = MIN (surface->bbox_x1, x1); + surface->bbox_y1 = MIN (surface->bbox_y1, y1); + surface->bbox_x2 = MAX (surface->bbox_x2, x2); + surface->bbox_y2 = MAX (surface->bbox_y2, y2); } return _cairo_output_stream_get_status (surface->stream); diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index 4abeaf9..b67e980 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -1151,15 +1151,11 @@ _cairo_surface_fallback_fill_rectangles (cairo_surface_t *surface, y2 = rects[0].y + rects[0].height; for (i = 1; i < num_rects; i++) { - if (rects[i].x < x1) - x1 = rects[i].x; - if (rects[i].y < y1) - y1 = rects[i].y; - - if (rects[i].x + rects[i].width > x2) - x2 = rects[i].x + rects[i].width; - if (rects[i].y + rects[i].height > y2) - y2 = rects[i].y + rects[i].height; + x1 = MIN (x1, rects[i].x); + y1 = MIN (y1, rects[i].y); + + x2 = MAX (x2, rects[i].x + rects[i].width); + y2 = MAX (y2, rects[i].y + rects[i].height); } status = _fallback_init (&state, surface, x1, y1, x2 - x1, y2 - y1); diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index 7b94325..bcc0568 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -624,14 +624,10 @@ _cairo_win32_surface_acquire_dest_image (void *abstract_surfa y1 = clip_box.top; y2 = clip_box.bottom; - if (interest_rect->x > x1) - x1 = interest_rect->x; - if (interest_rect->y > y1) - y1 = interest_rect->y; - if (interest_rect->x + interest_rect->width < x2) - x2 = interest_rect->x + interest_rect->width; - if (interest_rect->y + interest_rect->height < y2) - y2 = interest_rect->y + interest_rect->height; + x1 = MAX (x1, interest_rect->x); + y1 = MAX (y1, interest_rect->y); + x2 = MIN (x2, interest_rect->x + interest_rect->width); + y2 = MIN (y2, interest_rect->y + interest_rect->height); if (x1 >= x2 || y1 >= y2) { *image_out = NULL; diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index 451cc8f..1663521 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -322,14 +322,10 @@ _get_image_surface (cairo_xcb_surface_t *surface, rect.width = interest_rect->width; rect.height = interest_rect->height; - if (rect.x > x1) - x1 = rect.x; - if (rect.y > y1) - y1 = rect.y; - if (rect.x + rect.width < x2) - x2 = rect.x + rect.width; - if (rect.y + rect.height < y2) - y2 = rect.y + rect.height; + x1 = MAX (x1, rect.x); + y1 = MAX (y1, rect.y); + x2 = MIN (x2, rect.x + rect.width); + y2 = MIN (y2, rect.y + rect.height); if (x1 >= x2 || y1 >= y2) { *image_out = NULL; diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index f911de1..ec2f668 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -476,14 +476,10 @@ _get_image_surface (cairo_xlib_surface_t *surface, rect.width = interest_rect->width; rect.height = interest_rect->height; - if (rect.x > x1) - x1 = rect.x; - if (rect.y > y1) - y1 = rect.y; - if (rect.x + rect.width < x2) - x2 = rect.x + rect.width; - if (rect.y + rect.height < y2) - y2 = rect.y + rect.height; + x1 = MAX (x1, rect.x); + y1 = MAX (y1, rect.y); + x2 = MIN (x2, rect.x + rect.width); + y2 = MIN (y2, rect.y + rect.height); if (x1 >= x2 || y1 >= y2) { *image_out = NULL;