Cairo patch update for bug 792903. DONTBUILD
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 26 Sep 2012 21:34:30 +1200
changeset 108125 71192a9431a74baf053bb127f2c61d2455a20590
parent 108124 eb8a3fd355ba5b364c611e662ad65002394068c9
child 108126 6b444917f491c4d4fb5ea9a64a3f63b8860acb34
push id23539
push userryanvm@gmail.com
push dateWed, 26 Sep 2012 22:55:55 +0000
treeherderautoland@ec079fd92224 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs792903
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Cairo patch update for bug 792903. DONTBUILD
gfx/cairo/README
gfx/cairo/d2d-gradient-ensure-stops.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -185,16 +185,18 @@ win32-ExtCreatePen-zero-size.patch: Don'
 d2d-repeating-gradients.patch: Minimize number of gradient stops added to handle repeating with path fills (bug 768775)
 
 xlib-glyph-clip-region.patch: bug 709477, addressed upstream by be1ff2f45fdbc69537e513834fcffa0435e63073
 
 gdi-RGB24-ARGB32.patch: bug 788794
 
 dwrite-font-printing.patch: bug 468568; don't substitute a GDI font for a DWrite font if the name tables aren't equal
 
+d2d-gradient-ensure-stops.patch: bug 792903, ensure we don't set num_stops to 0
+
 ==== pixman patches ====
 
 pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
 
 pixman-rename-and-endian.patch: include cairo-platform.h for renaming of external symbols and endian macros
 
 NOTE: we previously supported ARM assembler on MSVC, this has been removed because of the maintenance burden
 
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/d2d-gradient-ensure-stops.patch
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Robert O'Callahan <robert@ocallahan.org>
+# Date 1348618772 -43200
+# Node ID 55ccbc8d52e69b020f2ba493e92ad2e214388df0
+# Parent  e0d69219dd2b3b2826d186dc99c673b879409ea6
+Bug 792903. Prevent num_stops from being set to zero. r=bas
+
+diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
+--- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
++++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
+@@ -1641,17 +1641,20 @@ static RefPtr<ID2D1Brush>
+ 	min_dist = MIN(_cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(top_left, p1)),
+ 		       _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(top_right, p1)));
+ 	min_dist = MIN(min_dist, _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(bottom_left, p1)));
+ 	min_dist = MIN(min_dist, _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(bottom_right, p1)));
+ 
+ 	min_dist = MAX(-min_dist, 0);
+ 
+ 	// Repeats after gradient start.
+-	int after_repeat = (int)ceil(max_dist / gradient_length);
++ 	// It's possible for max_dist and min_dist to both be zero, in which case
++ 	// we'll set num_stops to 0 and crash D2D. Let's just ensure after_repeat
++ 	// is at least 1.
++ 	int after_repeat = MAX((int)ceil(max_dist / gradient_length), 1);
+ 	int before_repeat = (int)ceil(min_dist / gradient_length);
+ 	num_stops *= (after_repeat + before_repeat);
+ 
+ 	p2.x = p1.x + u.x * after_repeat * gradient_length;
+ 	p2.y = p1.y + u.y * after_repeat * gradient_length;
+ 	p1.x = p1.x - u.x * before_repeat * gradient_length;
+ 	p1.y = p1.y - u.y * before_repeat * gradient_length;
+