<!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>[224977] 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/224977">224977</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2017-11-17 11:39:58 -0800 (Fri, 17 Nov 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>FETurbulence const and inline cleanup
https://bugs.webkit.org/show_bug.cgi?id=179832

Reviewed by Dean Jackson.

Pass the PaintingData& around as const, and remove some 'inline', letting the compiler
decide. Also declare a few variables closer to first use.

Speeds up FETurbulence by about 1%.

* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::initPaint):
(WebCore::FETurbulence::noise2D):
(WebCore::FETurbulence::calculateTurbulenceValueForPoint):
(WebCore::FETurbulence::fillRegion):
* platform/graphics/filters/FETurbulence.h:</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (224976 => 224977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-11-17 19:34:32 UTC (rev 224976)
+++ trunk/Source/WebCore/ChangeLog      2017-11-17 19:39:58 UTC (rev 224977)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-11-17  Simon Fraser  <simon.fraser@apple.com>
+
+        FETurbulence const and inline cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=179832
+
+        Reviewed by Dean Jackson.
+
+        Pass the PaintingData& around as const, and remove some 'inline', letting the compiler
+        decide. Also declare a few variables closer to first use.
+        
+        Speeds up FETurbulence by about 1%.
+
+        * platform/graphics/filters/FETurbulence.cpp:
+        (WebCore::FETurbulence::initPaint):
+        (WebCore::FETurbulence::noise2D):
+        (WebCore::FETurbulence::calculateTurbulenceValueForPoint):
+        (WebCore::FETurbulence::fillRegion):
+        * platform/graphics/filters/FETurbulence.h:
+
</ins><span class="cx"> 2017-11-17  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Move destroyLeftoverChildren call to RenderObject::destroy
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFETurbulencecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp (224976 => 224977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp  2017-11-17 19:34:32 UTC (rev 224976)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp     2017-11-17 19:39:58 UTC (rev 224977)
</span><span class="lines">@@ -165,7 +165,7 @@
</span><span class="cx">     return a + t * (b - a);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FETurbulence::initPaint(PaintingData& paintingData)
</del><ins>+void FETurbulence::initPaint(PaintingData& paintingData)
</ins><span class="cx"> {
</span><span class="cx">     float normalizationFactor;
</span><span class="cx"> 
</span><span class="lines">@@ -189,6 +189,7 @@
</span><span class="cx">             gradient[1] /= normalizationFactor;
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     for (int i = s_blockSize - 1; i > 0; --i) {
</span><span class="cx">         int k = paintingData.latticeSelector[i];
</span><span class="cx">         int j = paintingData.random() % s_blockSize;
</span><span class="lines">@@ -197,6 +198,7 @@
</span><span class="cx">         paintingData.latticeSelector[i] = paintingData.latticeSelector[j];
</span><span class="cx">         paintingData.latticeSelector[j] = k;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     for (int i = 0; i < s_blockSize + 2; ++i) {
</span><span class="cx">         paintingData.latticeSelector[s_blockSize + i] = paintingData.latticeSelector[i];
</span><span class="cx">         for (int channel = 0; channel < 4; ++channel) {
</span><span class="lines">@@ -214,7 +216,7 @@
</span><span class="cx">         noiseValue -= newValue - 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float FETurbulence::noise2D(int channel, PaintingData& paintingData, StitchData& stitchData, const FloatPoint& noiseVector)
</del><ins>+float FETurbulence::noise2D(int channel, const PaintingData& paintingData, StitchData& stitchData, const FloatPoint& noiseVector)
</ins><span class="cx"> {
</span><span class="cx">     struct Noise {
</span><span class="cx">         int noisePositionIntegerValue;
</span><span class="lines">@@ -230,8 +232,6 @@
</span><span class="cx"> 
</span><span class="cx">     Noise noiseX(noiseVector.x());
</span><span class="cx">     Noise noiseY(noiseVector.y());
</span><del>-    float* q;
-    float sx, sy, a, b, u, v;
</del><span class="cx"> 
</span><span class="cx">     // If stitching, adjust lattice points accordingly.
</span><span class="cx">     if (m_stitchTiles) {
</span><span class="lines">@@ -244,12 +244,13 @@
</span><span class="cx">     int latticeIndex = paintingData.latticeSelector[noiseX.noisePositionIntegerValue];
</span><span class="cx">     int nextLatticeIndex = paintingData.latticeSelector[(noiseX.noisePositionIntegerValue + 1) & s_blockMask];
</span><span class="cx"> 
</span><del>-    sx = smoothCurve(noiseX.noisePositionFractionValue);
-    sy = smoothCurve(noiseY.noisePositionFractionValue);
</del><ins>+    float sx = smoothCurve(noiseX.noisePositionFractionValue);
+    float sy = smoothCurve(noiseY.noisePositionFractionValue);
+    float a, b, u, v;
</ins><span class="cx"> 
</span><span class="cx">     // This is taken 1:1 from SVG spec: http://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement.
</span><span class="cx">     int temp = paintingData.latticeSelector[latticeIndex + noiseY.noisePositionIntegerValue];
</span><del>-    q = paintingData.gradient[channel][temp];
</del><ins>+    const float* q = paintingData.gradient[channel][temp];
</ins><span class="cx">     u = noiseX.noisePositionFractionValue * q[0] + noiseY.noisePositionFractionValue * q[1];
</span><span class="cx">     temp = paintingData.latticeSelector[nextLatticeIndex + noiseY.noisePositionIntegerValue];
</span><span class="cx">     q = paintingData.gradient[channel][temp];
</span><span class="lines">@@ -265,7 +266,7 @@
</span><span class="cx">     return linearInterpolation(sy, a, b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned char FETurbulence::calculateTurbulenceValueForPoint(int channel, PaintingData& paintingData, StitchData& stitchData, const FloatPoint& point)
</del><ins>+unsigned char FETurbulence::calculateTurbulenceValueForPoint(int channel, const PaintingData& paintingData, StitchData& stitchData, const FloatPoint& point)
</ins><span class="cx"> {
</span><span class="cx">     float tileWidth = paintingData.filterSize.width();
</span><span class="cx">     float tileHeight = paintingData.filterSize.height();
</span><span class="lines">@@ -299,6 +300,7 @@
</span><span class="cx">         stitchData.height = roundf(tileHeight * baseFrequencyY);
</span><span class="cx">         stitchData.wrapY = s_perlinNoise + stitchData.height;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     float turbulenceFunctionResult = 0;
</span><span class="cx">     FloatPoint noiseVector(point.x() * baseFrequencyX, point.y() * baseFrequencyY);
</span><span class="cx">     float ratio = 1;
</span><span class="lines">@@ -329,7 +331,7 @@
</span><span class="cx">     return static_cast<unsigned char>(turbulenceFunctionResult * 255);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FETurbulence::fillRegion(Uint8ClampedArray* pixelArray, PaintingData& paintingData, int startY, int endY)
</del><ins>+void FETurbulence::fillRegion(Uint8ClampedArray* pixelArray, const PaintingData& paintingData, int startY, int endY)
</ins><span class="cx"> {
</span><span class="cx">     IntRect filterRegion = absolutePaintRect();
</span><span class="cx">     IntPoint point(0, filterRegion.y() + startY);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFETurbulenceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h (224976 => 224977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h    2017-11-17 19:34:32 UTC (rev 224976)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h       2017-11-17 19:39:58 UTC (rev 224977)
</span><span class="lines">@@ -117,10 +117,10 @@
</span><span class="cx"> 
</span><span class="cx">     FETurbulence(Filter&, TurbulenceType, float, float, int, float, bool);
</span><span class="cx"> 
</span><del>-    inline void initPaint(PaintingData&);
-    float noise2D(int channel, PaintingData&, StitchData&, const FloatPoint&);
-    unsigned char calculateTurbulenceValueForPoint(int channel, PaintingData&, StitchData&, const FloatPoint&);
-    inline void fillRegion(Uint8ClampedArray*, PaintingData&, int, int);
</del><ins>+    void initPaint(PaintingData&);
+    float noise2D(int channel, const PaintingData&, StitchData&, const FloatPoint&);
+    unsigned char calculateTurbulenceValueForPoint(int channel, const PaintingData&, StitchData&, const FloatPoint&);
+    void fillRegion(Uint8ClampedArray*, const PaintingData&, int, int);
</ins><span class="cx"> 
</span><span class="cx">     TurbulenceType m_type;
</span><span class="cx">     float m_baseFrequencyX;
</span></span></pre>
</div>
</div>

</body>
</html>