Title: [225024] trunk
Revision
225024
Author
[email protected]
Date
2017-11-18 16:48:44 -0800 (Sat, 18 Nov 2017)

Log Message

Line of garbage pixels at the bottom of an feTurbulence sometimes
https://bugs.webkit.org/show_bug.cgi?id=179866

Reviewed by Wenson Hsieh.
Source/WebCore:

The ParallelJobs logic was broken in that the sum of the computed job
heights was one too short sometimes. Fix and clean up the logic.

Test: svg/filters/feTurbulence-parallel-jobs.html

* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::platformApplySoftware):

LayoutTests:

* svg/filters/feTurbulence-parallel-jobs-expected.html: Added.
* svg/filters/feTurbulence-parallel-jobs.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225023 => 225024)


--- trunk/LayoutTests/ChangeLog	2017-11-18 22:50:30 UTC (rev 225023)
+++ trunk/LayoutTests/ChangeLog	2017-11-19 00:48:44 UTC (rev 225024)
@@ -1,5 +1,15 @@
 2017-11-18  Simon Fraser  <[email protected]>
 
+        Line of garbage pixels at the bottom of an feTurbulence sometimes
+        https://bugs.webkit.org/show_bug.cgi?id=179866
+
+        Reviewed by Wenson Hsieh.
+
+        * svg/filters/feTurbulence-parallel-jobs-expected.html: Added.
+        * svg/filters/feTurbulence-parallel-jobs.html: Added.
+
+2017-11-18  Simon Fraser  <[email protected]>
+
         More FETurbulence cleanup
         https://bugs.webkit.org/show_bug.cgi?id=179863
 

Added: trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs-expected.html (0 => 225024)


--- trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs-expected.html	2017-11-19 00:48:44 UTC (rev 225024)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>You should see a line of black pixels at the botton of the gray square.</p>
+        <svg width="800px" height="800px" xmlns="http://www.w3.org/2000/svg">
+            <defs>
+                <clipPath id="clip-out-middle">
+                  <rect x="10" y="240" width="200" height="4" />
+                </clipPath>
+            </defs>
+            <rect x="10" y="40" width="201" height="201" fill="black" clip-path="url(#clip-out-middle)"/>
+            <rect x="10" y="40" width="200" height="202" fill="none" stroke="gray" />
+        </svg>
+        </div>
+    </body>
+</html>

Added: trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs.html (0 => 225024)


--- trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs.html	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feTurbulence-parallel-jobs.html	2017-11-19 00:48:44 UTC (rev 225024)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>You should see a line of black pixels at the botton of the gray square.</p>
+        <svg width="800px" height="800px" xmlns="http://www.w3.org/2000/svg">
+            <defs>
+                <filter id="light" filterUnits="userSpaceOnUse" x="10" y="40" width="200" height="201">
+                    <feTurbulence seed="10" type="turbulence" baseFrequency="0.01" numOctaves="1" />
+                    <feComponentTransfer>
+                      <feFuncR type="discrete" tableValues="0 0 0 0 1" />
+                      <feFuncG type="discrete" tableValues="0 0 0 0 1" />
+                      <feFuncB type="discrete" tableValues="0 0 0 0 1" />
+                      <feFuncA type="discrete" tableValues="0 1 1 1 1" />
+                    </feComponentTransfer>
+                </filter>
+                <clipPath id="clip-out-middle">
+                  <rect x="10" y="240" width="200" height="4" />
+                </clipPath>
+            </defs>
+            <rect x="0" y="0" width="201" height="201" filter="url(#light)" clip-path="url(#clip-out-middle)"/>
+            <rect x="10" y="40" width="200" height="202" fill="none" stroke="gray" />
+        </svg>
+        </div>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (225023 => 225024)


--- trunk/Source/WebCore/ChangeLog	2017-11-18 22:50:30 UTC (rev 225023)
+++ trunk/Source/WebCore/ChangeLog	2017-11-19 00:48:44 UTC (rev 225024)
@@ -1,5 +1,20 @@
 2017-11-18  Simon Fraser  <[email protected]>
 
+        Line of garbage pixels at the bottom of an feTurbulence sometimes
+        https://bugs.webkit.org/show_bug.cgi?id=179866
+
+        Reviewed by Wenson Hsieh.
+        
+        The ParallelJobs logic was broken in that the sum of the computed job
+        heights was one too short sometimes. Fix and clean up the logic.
+
+        Test: svg/filters/feTurbulence-parallel-jobs.html
+
+        * platform/graphics/filters/FETurbulence.cpp:
+        (WebCore::FETurbulence::platformApplySoftware):
+
+2017-11-18  Simon Fraser  <[email protected]>
+
         Use #pragma once in FE* files.
         
         Rubber-stamped by Dan Bates.

Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp (225023 => 225024)


--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp	2017-11-18 22:50:30 UTC (rev 225023)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp	2017-11-19 00:48:44 UTC (rev 225024)
@@ -413,32 +413,37 @@
     PaintingData paintingData(m_seed, tileSize, baseFrequencyX, baseFrequencyY);
     initPaint(paintingData);
 
-    int optimalThreadNumber = (absolutePaintRect().width() * absolutePaintRect().height()) / s_minimalRectDimension;
+    int height = absolutePaintRect().height();
+
+    auto area = absolutePaintRect().area();
+    if (area.hasOverflowed())
+        return;
+
+    unsigned optimalThreadNumber = area.unsafeGet() / s_minimalRectDimension;
     if (optimalThreadNumber > 1) {
-        // Initialize parallel jobs
         WTF::ParallelJobs<FillRegionParameters> parallelJobs(&WebCore::FETurbulence::fillRegionWorker, optimalThreadNumber);
 
         // Fill the parameter array
-        int i = parallelJobs.numberOfJobs();
-        if (i > 1) {
-            // Split the job into "stepY"-sized jobs but there a few jobs that need to be slightly larger since
-            // stepY * jobs < total size. These extras are handled by the remainder "jobsWithExtra".
-            const int stepY = absolutePaintRect().height() / i;
-            const int jobsWithExtra = absolutePaintRect().height() % i;
+        unsigned numJobs = parallelJobs.numberOfJobs();
+        if (numJobs > 1) {
+            // Split the job into "stepY"-sized jobs, distributing the extra rows into the first "jobsWithExtra" jobs.
+            unsigned stepY = height / numJobs;
+            unsigned jobsWithExtra = height % numJobs;
+            unsigned startY = 0;
 
-            int startY = 0;
-            for (; i > 0; --i) {
-                FillRegionParameters& params = parallelJobs.parameter(i - 1);
+            for (unsigned i = 0; i < numJobs; ++i) {
+                FillRegionParameters& params = parallelJobs.parameter(i);
                 params.filter = this;
                 params.pixelArray = pixelArray;
                 params.paintingData = &paintingData;
                 params.stitchData = stitchData;
                 params.startY = startY;
-                startY += i < jobsWithExtra ? stepY + 1 : stepY;
-                params.endY = startY;
+
+                unsigned jobHeight = (i < jobsWithExtra) ? stepY + 1 : stepY;
+                params.endY = params.startY + jobHeight;
+                startY += jobHeight;
             }
 
-            // Execute parallel jobs
             parallelJobs.execute();
             return;
         }
@@ -445,7 +450,7 @@
     }
 
     // Fallback to single threaded mode if there is no room for a new thread or the paint area is too small.
-    fillRegion(pixelArray, paintingData, stitchData, 0, absolutePaintRect().height());
+    fillRegion(pixelArray, paintingData, stitchData, 0, height);
 }
 
 void FETurbulence::dump()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to