Title: [179171] trunk
- Revision
- 179171
- Author
- commit-qu...@webkit.org
- Date
- 2015-01-26 22:32:03 -0800 (Mon, 26 Jan 2015)
Log Message
Apply feTurbulence spec change to fix zero length vector generation
https://bugs.webkit.org/show_bug.cgi?id=140812
.:
Patch by Nikos Andronikos <nikos.andronikos-web...@cisra.canon.com.au> on 2015-01-26
Reviewed by Darin Adler.
Recently a bug with the turbulence algorithm was corrected in the
Filter Effects specification.
For some seed values this bug allowed zero length vectors to be generated.
This resulted in large solid color squares being present in the generated image.
The feTurbulence algorithm was updated to reject zero length vectors. This patch
applies that change in WebCore.
Test: svg/filters/feTurbulence_bad_seeds.html
* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::initPaint):
Added rejection sampling during vector generation to avoid zero length vectors.
LayoutTests:
Patch by Nikos Andronikos <nikos.andronikos-web...@cisra.canon.com.au> on 2015-01-26
Reviewed by Darin Adler.
Ref test that generates a turbulence image which is then coloured black
and alpha min/maxxed (>0 becomes 1, 0 stays zero). This allows holes
caused by zero length vectors to be easily identified.
* svg/filters/feTurbulence_bad_seeds-expected.html: Added.
* svg/filters/feTurbulence_bad_seeds.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/ChangeLog (179170 => 179171)
--- trunk/ChangeLog 2015-01-27 06:24:09 UTC (rev 179170)
+++ trunk/ChangeLog 2015-01-27 06:32:03 UTC (rev 179171)
@@ -1,3 +1,23 @@
+2015-01-26 Nikos Andronikos <nikos.andronikos-web...@cisra.canon.com.au>
+
+ Apply feTurbulence spec change to fix zero length vector generation
+ https://bugs.webkit.org/show_bug.cgi?id=140812
+
+ Reviewed by Darin Adler.
+
+ Recently a bug with the turbulence algorithm was corrected in the
+ Filter Effects specification.
+ For some seed values this bug allowed zero length vectors to be generated.
+ This resulted in large solid color squares being present in the generated image.
+ The feTurbulence algorithm was updated to reject zero length vectors. This patch
+ applies that change in WebCore.
+
+ Test: svg/filters/feTurbulence_bad_seeds.html
+
+ * platform/graphics/filters/FETurbulence.cpp:
+ (WebCore::FETurbulence::initPaint):
+ Added rejection sampling during vector generation to avoid zero length vectors.
+
2015-01-26 Csaba Osztrogonác <o...@webkit.org>
[cmake] Remove compiler version calculate cruft
Modified: trunk/LayoutTests/ChangeLog (179170 => 179171)
--- trunk/LayoutTests/ChangeLog 2015-01-27 06:24:09 UTC (rev 179170)
+++ trunk/LayoutTests/ChangeLog 2015-01-27 06:32:03 UTC (rev 179171)
@@ -1,3 +1,17 @@
+2015-01-26 Nikos Andronikos <nikos.andronikos-web...@cisra.canon.com.au>
+
+ Apply feTurbulence spec change to fix zero length vector generation
+ https://bugs.webkit.org/show_bug.cgi?id=140812
+
+ Reviewed by Darin Adler.
+
+ Ref test that generates a turbulence image which is then coloured black
+ and alpha min/maxxed (>0 becomes 1, 0 stays zero). This allows holes
+ caused by zero length vectors to be easily identified.
+
+ * svg/filters/feTurbulence_bad_seeds-expected.html: Added.
+ * svg/filters/feTurbulence_bad_seeds.html: Added.
+
2015-01-26 Sylvain Galineau <galin...@adobe.com>
The computed value of line-height:normal is incorrect
Added: trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds-expected.html (0 => 179171)
--- trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds-expected.html (rev 0)
+++ trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds-expected.html 2015-01-27 06:32:03 UTC (rev 179171)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+<svg viewbox="0 0 512 256">
+ <rect x="0" y="0" width="256" height="128" fill="black" />
+</svg>
+</body>
+</html>
Added: trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds.html (0 => 179171)
--- trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds.html (rev 0)
+++ trunk/LayoutTests/svg/filters/feTurbulence_bad_seeds.html 2015-01-27 06:32:03 UTC (rev 179171)
@@ -0,0 +1,52 @@
+<!doctype html>
+<!--
+This test determines whether the feTurbulence algorithm allows zero length vectors on some particular seeds. These zero length
+vectors result in large rectangular holes in the generated image.
+Seed 514 is the first seed value that demonstrates the error.
+Others are: 1977,2337,4777,8032,9615,14783,14862,14921,18607,19537,19852,19955,22456,23056,26678,27351,29383,29560,29929, ...
+The feTurbulence algorithm in the specification uses rejection sampling to avoid generating zero length vectors and so in a
+correct implementation we should not see any large holes in the image.
+-->
+<html>
+<body>
+<svg viewbox="0 0 512 256">
+ <desc>Test passes if there are no red squares.</desc>
+ <defs>
+ <filter id="turb1" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
+ <feTurbulence x="0" y="0" width="100%" height="100%" baseFrequency="0.02 0.1" numOctaves="5" seed="514" result="a" />
+ <feComponentTransfer in="a">
+ <!-- set colour to black everywhere and set opacity to full if alpha > 0 -->
+ <feFuncR type="linear" slope="-10000" intercept="0"/><feFuncG type="linear" slope="-10000" intercept="0"/><feFuncB type="linear" slope="-10000" intercept="0"/>
+ <feFuncA type="linear" slope="10000" intercept="0"/>
+ </feComponentTransfer>
+ </filter>
+ <filter id="turb2" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
+ <feTurbulence x="0" y="0" width="100%" height="100%" baseFrequency="0.02 0.1" numOctaves="5" seed="14783" result="a" />
+ <feComponentTransfer in="a">
+ <feFuncR type="linear" slope="-10000" intercept="0"/><feFuncG type="linear" slope="-10000" intercept="0"/><feFuncB type="linear" slope="-10000" intercept="0"/>
+ <feFuncA type="linear" slope="10000" intercept="0"/>
+ </feComponentTransfer>
+ </filter>
+ <filter id="turb3" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
+ <feTurbulence x="0" y="0" width="100%" height="100%" baseFrequency="0.02 0.1" numOctaves="5" seed="23056" result="a" />
+ <feComponentTransfer in="a">
+ <feFuncR type="linear" slope="-10000" intercept="0"/><feFuncG type="linear" slope="-10000" intercept="0"/><feFuncB type="linear" slope="-10000" intercept="0"/>
+ <feFuncA type="linear" slope="10000" intercept="0"/>
+ </feComponentTransfer>
+ </filter>
+ <filter id="turb4" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
+ <feTurbulence x="0" y="0" width="100%" height="100%" baseFrequency="0.02 0.1" numOctaves="5" seed="9615" result="a" />
+ <feComponentTransfer in="a">
+ <feFuncR type="linear" slope="-10000" intercept="0"/><feFuncG type="linear" slope="-10000" intercept="0"/><feFuncB type="linear" slope="-10000" intercept="0"/>
+ <feFuncA type="linear" slope="10000" intercept="0"/>
+ </feComponentTransfer>
+ </filter>
+ </defs>
+ <rect x="0" y="0" width="256" height="128" fill="red" />
+ <rect x="0" y="0" width="64" height="128" fill="black" filter="url(#turb1)"/>
+ <rect x="64" y="0" width="64" height="128" fill="blue" filter="url(#turb2)"/>
+ <rect x="128" y="0" width="64" height="128" fill="black" filter="url(#turb3)"/>
+ <rect x="192" y="0" width="64" height="128" fill="blue" filter="url(#turb4)"/>
+</svg>
+</body>
+</html>
Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp (179170 => 179171)
--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp 2015-01-27 06:24:09 UTC (rev 179170)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp 2015-01-27 06:32:03 UTC (rev 179171)
@@ -180,8 +180,10 @@
for (int i = 0; i < s_blockSize; ++i) {
paintingData.latticeSelector[i] = i;
gradient = paintingData.gradient[channel][i];
- gradient[0] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize;
- gradient[1] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize;
+ do {
+ gradient[0] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize;
+ gradient[1] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize;
+ } while (!gradient[0] && !gradient[1]);
normalizationFactor = sqrtf(gradient[0] * gradient[0] + gradient[1] * gradient[1]);
gradient[0] /= normalizationFactor;
gradient[1] /= normalizationFactor;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes