<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[224996] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/224996">224996</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2017-11-17 15:36:24 -0800 (Fri, 17 Nov 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't invert a matrix for every channel of every pixel of an FETurbulence filter
https://bugs.webkit.org/show_bug.cgi?id=179829

Reviewed by Dean Jackson.

FETurbulence::fillRegion() called filter().mapAbsolutePointToLocalPoint(point) for each
of the 4 channels on a point, which is stupid.

Fix to invert the matrix once, and then map the point once for each pixel. This reduces
the time in fillRegion() function by about 30%.

* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::fillRegion):
* platform/graphics/filters/Filter.h:
(WebCore::Filter::absoluteTransform const):
(WebCore::Filter::mapAbsolutePointToLocalPoint const): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFETurbulencecpp">trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFETurbulenceh">trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterh">trunk/Source/WebCore/platform/graphics/filters/Filter.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (224995 => 224996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-11-17 23:34:09 UTC (rev 224995)
+++ trunk/Source/WebCore/ChangeLog      2017-11-17 23:36:24 UTC (rev 224996)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-11-17  Simon Fraser  <simon.fraser@apple.com>
+
+        Don't invert a matrix for every channel of every pixel of an FETurbulence filter
+        https://bugs.webkit.org/show_bug.cgi?id=179829
+
+        Reviewed by Dean Jackson.
+        
+        FETurbulence::fillRegion() called filter().mapAbsolutePointToLocalPoint(point) for each
+        of the 4 channels on a point, which is stupid.
+        
+        Fix to invert the matrix once, and then map the point once for each pixel. This reduces
+        the time in fillRegion() function by about 30%.
+
+        * platform/graphics/filters/FETurbulence.cpp:
+        (WebCore::FETurbulence::fillRegion):
+        * platform/graphics/filters/Filter.h:
+        (WebCore::Filter::absoluteTransform const):
+        (WebCore::Filter::mapAbsolutePointToLocalPoint const): Deleted.
+
</ins><span class="cx"> 2017-11-17  Brent Fulgham  <bfulgham@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r224390): Revert unneeded Ref use.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFETurbulencecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp (224995 => 224996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp  2017-11-17 23:34:09 UTC (rev 224995)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp     2017-11-17 23:36:24 UTC (rev 224996)
</span><span class="lines">@@ -64,11 +64,6 @@
</span><span class="cx">     return adoptRef(*new FETurbulence(filter, type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TurbulenceType FETurbulence::type() const
-{
-    return m_type;
-}
-
</del><span class="cx"> bool FETurbulence::setType(TurbulenceType type)
</span><span class="cx"> {
</span><span class="cx">     if (m_type == type)
</span><span class="lines">@@ -77,11 +72,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float FETurbulence::baseFrequencyY() const
-{
-    return m_baseFrequencyY;
-}
-
</del><span class="cx"> bool FETurbulence::setBaseFrequencyY(float baseFrequencyY)
</span><span class="cx"> {
</span><span class="cx">     if (m_baseFrequencyY == baseFrequencyY)
</span><span class="lines">@@ -90,11 +80,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float FETurbulence::baseFrequencyX() const
-{
-    return m_baseFrequencyX;
-}
-
</del><span class="cx"> bool FETurbulence::setBaseFrequencyX(float baseFrequencyX)
</span><span class="cx"> {
</span><span class="cx">     if (m_baseFrequencyX == baseFrequencyX)
</span><span class="lines">@@ -103,11 +88,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float FETurbulence::seed() const
-{
-    return m_seed; 
-}
-
</del><span class="cx"> bool FETurbulence::setSeed(float seed)
</span><span class="cx"> {
</span><span class="cx">     if (m_seed == seed)
</span><span class="lines">@@ -116,11 +96,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int FETurbulence::numOctaves() const
-{
-    return m_numOctaves;
-}
-
</del><span class="cx"> bool FETurbulence::setNumOctaves(int numOctaves)
</span><span class="cx"> {
</span><span class="cx">     if (m_numOctaves == numOctaves)
</span><span class="lines">@@ -129,11 +104,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool FETurbulence::stitchTiles() const
-{
-    return m_stitchTiles;
-}
-
</del><span class="cx"> bool FETurbulence::setStitchTiles(bool stitch)
</span><span class="cx"> {
</span><span class="cx">     if (m_stitchTiles == stitch)
</span><span class="lines">@@ -334,10 +304,10 @@
</span><span class="cx"> void FETurbulence::fillRegion(Uint8ClampedArray* pixelArray, const PaintingData& paintingData, int startY, int endY)
</span><span class="cx"> {
</span><span class="cx">     IntRect filterRegion = absolutePaintRect();
</span><del>-    IntPoint point(0, filterRegion.y() + startY);
</del><ins>+    FloatPoint point(0, filterRegion.y() + startY);
</ins><span class="cx">     int indexOfPixelChannel = startY * (filterRegion.width() << 2);
</span><del>-    int channel;
</del><span class="cx">     StitchData stitchData;
</span><ins>+    AffineTransform inverseTransfrom = filter().absoluteTransform().inverse().value_or(AffineTransform());
</ins><span class="cx"> 
</span><span class="cx">     for (int y = startY; y < endY; ++y) {
</span><span class="cx">         point.setY(point.y() + 1);
</span><span class="lines">@@ -344,8 +314,9 @@
</span><span class="cx">         point.setX(filterRegion.x());
</span><span class="cx">         for (int x = 0; x < filterRegion.width(); ++x) {
</span><span class="cx">             point.setX(point.x() + 1);
</span><del>-            for (channel = 0; channel < 4; ++channel, ++indexOfPixelChannel)
-                pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(channel, paintingData, stitchData, filter().mapAbsolutePointToLocalPoint(point)));
</del><ins>+            FloatPoint localPoint = inverseTransfrom.mapPoint(point);
+            for (int channel = 0; channel < 4; ++channel, ++indexOfPixelChannel)
+                pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(channel, paintingData, stitchData, localPoint));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFETurbulenceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h (224995 => 224996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h    2017-11-17 23:34:09 UTC (rev 224995)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h       2017-11-17 23:36:24 UTC (rev 224996)
</span><span class="lines">@@ -39,22 +39,22 @@
</span><span class="cx"> public:
</span><span class="cx">     static Ref<FETurbulence> create(Filter&, TurbulenceType, float, float, int, float, bool);
</span><span class="cx"> 
</span><del>-    TurbulenceType type() const;
</del><ins>+    TurbulenceType type() const { return m_type; }
</ins><span class="cx">     bool setType(TurbulenceType);
</span><span class="cx"> 
</span><del>-    float baseFrequencyY() const;
</del><ins>+    float baseFrequencyY() const { return m_baseFrequencyX; }
</ins><span class="cx">     bool setBaseFrequencyY(float);
</span><span class="cx"> 
</span><del>-    float baseFrequencyX() const;
</del><ins>+    float baseFrequencyX() const { return m_baseFrequencyY; }
</ins><span class="cx">     bool setBaseFrequencyX(float);
</span><span class="cx"> 
</span><del>-    float seed() const;
</del><ins>+    float seed() const { return m_seed; }
</ins><span class="cx">     bool setSeed(float);
</span><span class="cx"> 
</span><del>-    int numOctaves() const;
</del><ins>+    int numOctaves() const { return m_numOctaves; }
</ins><span class="cx">     bool setNumOctaves(int);
</span><span class="cx"> 
</span><del>-    bool stitchTiles() const;
</del><ins>+    bool stitchTiles() const { return m_stitchTiles; }
</ins><span class="cx">     bool setStitchTiles(bool);
</span><span class="cx"> 
</span><span class="cx">     static void fillRegionWorker(void*);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/Filter.h (224995 => 224996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/Filter.h  2017-11-17 23:34:09 UTC (rev 224995)
+++ trunk/Source/WebCore/platform/graphics/filters/Filter.h     2017-11-17 23:36:24 UTC (rev 224996)
</span><span class="lines">@@ -43,7 +43,6 @@
</span><span class="cx">     void setFilterScale(float scale) { m_filterScale = scale; }
</span><span class="cx"> 
</span><span class="cx">     const AffineTransform& absoluteTransform() const { return m_absoluteTransform; }
</span><del>-    FloatPoint mapAbsolutePointToLocalPoint(const FloatPoint& point) const { return m_absoluteTransform.inverse().value_or(AffineTransform()).mapPoint(point); }
</del><span class="cx"> 
</span><span class="cx">     RenderingMode renderingMode() const { return m_renderingMode; }
</span><span class="cx">     void setRenderingMode(RenderingMode renderingMode) { m_renderingMode = renderingMode; }
</span></span></pre>
</div>
</div>

</body>
</html>