[cairo-commit] src/cairo-win32-surface.c

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Thu Dec 4 15:01:33 PST 2008


 src/cairo-win32-surface.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 08b486c9aa1d6ad01f1b17a16dcb4d695e8cbf7d
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Thu Dec 4 17:53:06 2008 -0500

    [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

diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 863f9d5..bc66580 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -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,
 				const 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;


More information about the cairo-commit mailing list