[win32] Use MOD instead of the '%' operator

Repeat should be handled using MOD instead of '%' so that negative numbers
are handled as expected. E.g. -1 mod 600 = 599, not 495 as the '%' operator
gives. This was causing https://bugzilla.mozilla.org/show_bug.cgi?id=466258

Patch from Robert O'Callahan
This commit is contained in:
Jeff Muizelaar 2008-12-04 17:53:06 -05:00
parent 540de34453
commit 673640a3b3

View file

@ -872,6 +872,9 @@ _cairo_win32_surface_composite_inner (cairo_win32_surface_t *src,
return CAIRO_STATUS_SUCCESS;
}
/* from pixman-private.h */
#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
static cairo_int_status_t
_cairo_win32_surface_composite (cairo_operator_t op,
cairo_pattern_t *pattern,
@ -1153,8 +1156,8 @@ _cairo_win32_surface_composite (cairo_operator_t op,
uint32_t rendered_width = 0, rendered_height = 0;
uint32_t to_render_height, to_render_width;
int32_t piece_x, piece_y;
int32_t src_start_x = src_r.x % src_extents.width;
int32_t src_start_y = src_r.y % src_extents.height;
int32_t src_start_x = MOD(src_r.x, src_extents.width);
int32_t src_start_y = MOD(src_r.y, src_extents.height);
if (needs_scale)
goto UNSUPPORTED;