Bug 466268. Fix cairo-win32 bug that needed MOD but was using the C % operator. r=jmuizelaar
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 08 Dec 2008 13:54:10 +1300
changeset 22492 eb91ec5673df7bd4d7198a140a3fcb43d500d6e6
parent 22491 0e0c23ff64cf7178400e915d1db542df0f591be1
child 22493 ce9f05b57b957d1731fe2dd86e149d1652dcc365
push idunknown
push userunknown
push dateunknown
reviewersjmuizelaar
bugs466268
milestone1.9.2a1pre
Bug 466268. Fix cairo-win32 bug that needed MOD but was using the C % operator. r=jmuizelaar
gfx/cairo/cairo/src/cairo-win32-surface.c
gfx/cairo/win32-composite-src-mod.patch
layout/reftests/bugs/466258-1-ref.html
layout/reftests/bugs/466258-1.html
layout/reftests/bugs/reftest.list
--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
@@ -928,16 +928,19 @@ static cairo_int_status_t
   	return _composite_alpha_blend (dst, src, alpha,
 				       src_r.x, src_r.y, src_r.width, src_r.height,
 				       dst_r.x, dst_r.y, dst_r.width, dst_r.height);
     }
 
     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,
 				cairo_pattern_t		*mask_pattern,
 				void			*abstract_dst,
 				int			src_x,
 				int			src_y,
 				int			mask_x,
@@ -1209,18 +1212,18 @@ static cairo_int_status_t
     /* If we need to repeat, we turn the repeated blit into
      * a bunch of piece-by-piece blits.
      */
     if (needs_repeat) {
 	cairo_rectangle_int_t piece_src_r, piece_dst_r;
 	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;
 
 	/* If both the src and dest have an image, we may as well fall
 	 * back, because it will be faster than our separate blits.
 	 * Our blit code will be fastest when the src is a DDB and the
 	 * destination is a DDB.
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/win32-composite-src-mod.patch
@@ -0,0 +1,44 @@
+diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
+--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
++++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
+@@ -928,16 +928,19 @@ _cairo_win32_surface_composite_inner (ca
+   	return _composite_alpha_blend (dst, src, alpha,
+ 				       src_r.x, src_r.y, src_r.width, src_r.height,
+ 				       dst_r.x, dst_r.y, dst_r.width, dst_r.height);
+     }
+ 
+     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,
+ 				cairo_pattern_t		*mask_pattern,
+ 				void			*abstract_dst,
+ 				int			src_x,
+ 				int			src_y,
+ 				int			mask_x,
+@@ -1209,18 +1212,18 @@ _cairo_win32_surface_composite (cairo_op
+     /* If we need to repeat, we turn the repeated blit into
+      * a bunch of piece-by-piece blits.
+      */
+     if (needs_repeat) {
+ 	cairo_rectangle_int_t piece_src_r, piece_dst_r;
+ 	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;
+ 
+ 	/* If both the src and dest have an image, we may as well fall
+ 	 * back, because it will be faster than our separate blits.
+ 	 * Our blit code will be fastest when the src is a DDB and the
+ 	 * destination is a DDB.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/466258-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<div style="background-position:-590px 0;
+            background-image: url(mozilla-banner.gif);
+            width:10px; height:58px; float:left;">
+</div>
+<div style="background-image: url(mozilla-banner.gif);
+            width:590px; height:58px; float:left;">
+</div>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/466258-1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<div style="background-position:10px 0;
+            background-image: url(mozilla-banner.gif);
+            width:600px; height:58px;">
+</div>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -975,13 +975,14 @@ fails == 461512-1.html 461512-1-ref.html
 == 462844-1.html 462844-ref.html
 == 462844-2.html 462844-ref.html
 == 462844-3.html 462844-ref.html
 == 462844-4.html 462844-ref.html
 == 463204-1.html 463204-1-ref.html
 == 463217-1.xul 463217-1-ref.xul
 == 463952-1.html 463952-1-ref.html
 == 464811-1.html 464811-1-ref.html
+== 466258-1.html 466258-1-ref.html
 == 466395-1.html 466395-1-ref.html
 == 466395-2.html 466395-2-ref.html
 == 467084-1.html 467084-1-ref.html
 == 467084-2.html 467084-2-ref.html
 == 467460-1.html 467460-1-ref.html