diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h index 75ecc06dc..b30879438 100644 --- a/src/cairo-fixed-private.h +++ b/src/cairo-fixed-private.h @@ -165,6 +165,12 @@ _cairo_fixed_integer_round (cairo_fixed_t f) return (f + (CAIRO_FIXED_FRAC_MASK+1)/2) >> CAIRO_FIXED_FRAC_BITS; } +static inline int +_cairo_fixed_integer_round_down (cairo_fixed_t f) +{ + return (f + CAIRO_FIXED_FRAC_MASK/2) >> CAIRO_FIXED_FRAC_BITS; +} + static inline int _cairo_fixed_fractional_part (cairo_fixed_t f) { diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index a6953fb1b..b2b69d372 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -2864,10 +2864,11 @@ _composite_boxes (cairo_image_surface_t *dst, cairo_box_t *box = chunk->base; for (i = 0; i < chunk->count; i++) { - int x1 = _cairo_fixed_integer_round (box[i].p1.x); - int y1 = _cairo_fixed_integer_round (box[i].p1.y); - int x2 = _cairo_fixed_integer_round (box[i].p2.x); - int y2 = _cairo_fixed_integer_round (box[i].p2.y); + /* round down here to match Pixman's behavior when using traps. */ + int x1 = _cairo_fixed_integer_round_down (box[i].p1.x); + int y1 = _cairo_fixed_integer_round_down (box[i].p1.y); + int x2 = _cairo_fixed_integer_round_down (box[i].p2.x); + int y2 = _cairo_fixed_integer_round_down (box[i].p2.y); if (x2 == x1 || y2 == y1) continue;