<!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>[225088] 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/225088">225088</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2017-11-21 17:02:24 -0800 (Tue, 21 Nov 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Some FELighting cleanup
https://bugs.webkit.org/show_bug.cgi?id=179924

Reviewed by Sam Weinig.

Make the normal-computation functions const and have them return an IntSize.
Replace bit shifting with multiply by two (compilers know how to do this, folks).

* platform/graphics/filters/FELighting.cpp:
(WebCore::FELighting::LightingData::topLeftNormal const):
(WebCore::FELighting::LightingData::topRowNormal const):
(WebCore::FELighting::LightingData::topRightNormal const):
(WebCore::FELighting::LightingData::leftColumnNormal const):
(WebCore::FELighting::LightingData::interiorNormal const):
(WebCore::FELighting::LightingData::rightColumnNormal const):
(WebCore::FELighting::LightingData::bottomLeftNormal const):
(WebCore::FELighting::LightingData::bottomRowNormal const):
(WebCore::FELighting::LightingData::bottomRightNormal const):
(WebCore::FELighting::inlineSetPixel):
(WebCore::FELighting::setPixel):
(WebCore::FELighting::platformApplyGenericPaint):
(WebCore::FELighting::drawLighting):
(WebCore::FELighting::LightingData::topLeft): Deleted.
(WebCore::FELighting::LightingData::topRow): Deleted.
(WebCore::FELighting::LightingData::topRight): Deleted.
(WebCore::FELighting::LightingData::leftColumn): Deleted.
(WebCore::FELighting::LightingData::interior): Deleted.
(WebCore::FELighting::LightingData::rightColumn): Deleted.
(WebCore::FELighting::LightingData::bottomLeft): Deleted.
(WebCore::FELighting::LightingData::bottomRow): Deleted.
(WebCore::FELighting::LightingData::bottomRight): Deleted.
* platform/graphics/filters/FELighting.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFELightingcpp">trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFELightingh">trunk/Source/WebCore/platform/graphics/filters/FELighting.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (225087 => 225088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-11-21 23:14:58 UTC (rev 225087)
+++ trunk/Source/WebCore/ChangeLog      2017-11-22 01:02:24 UTC (rev 225088)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2017-11-21  Simon Fraser  <simon.fraser@apple.com>
+
+        Some FELighting cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=179924
+
+        Reviewed by Sam Weinig.
+
+        Make the normal-computation functions const and have them return an IntSize.
+        Replace bit shifting with multiply by two (compilers know how to do this, folks).
+
+        * platform/graphics/filters/FELighting.cpp:
+        (WebCore::FELighting::LightingData::topLeftNormal const):
+        (WebCore::FELighting::LightingData::topRowNormal const):
+        (WebCore::FELighting::LightingData::topRightNormal const):
+        (WebCore::FELighting::LightingData::leftColumnNormal const):
+        (WebCore::FELighting::LightingData::interiorNormal const):
+        (WebCore::FELighting::LightingData::rightColumnNormal const):
+        (WebCore::FELighting::LightingData::bottomLeftNormal const):
+        (WebCore::FELighting::LightingData::bottomRowNormal const):
+        (WebCore::FELighting::LightingData::bottomRightNormal const):
+        (WebCore::FELighting::inlineSetPixel):
+        (WebCore::FELighting::setPixel):
+        (WebCore::FELighting::platformApplyGenericPaint):
+        (WebCore::FELighting::drawLighting):
+        (WebCore::FELighting::LightingData::topLeft): Deleted.
+        (WebCore::FELighting::LightingData::topRow): Deleted.
+        (WebCore::FELighting::LightingData::topRight): Deleted.
+        (WebCore::FELighting::LightingData::leftColumn): Deleted.
+        (WebCore::FELighting::LightingData::interior): Deleted.
+        (WebCore::FELighting::LightingData::rightColumn): Deleted.
+        (WebCore::FELighting::LightingData::bottomLeft): Deleted.
+        (WebCore::FELighting::LightingData::bottomRow): Deleted.
+        (WebCore::FELighting::LightingData::bottomRight): Deleted.
+        * platform/graphics/filters/FELighting.h:
+
</ins><span class="cx"> 2017-11-21  Christopher Reid  <chris.reid@sony.com>
</span><span class="cx"> 
</span><span class="cx">         [PAL] Remove FileSystem's dependency on WebCoreNSStringExtras
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFELightingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp (225087 => 225088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp    2017-11-21 23:14:58 UTC (rev 225087)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp       2017-11-22 01:02:24 UTC (rev 225088)
</span><span class="lines">@@ -85,13 +85,14 @@
</span><span class="cx"> const static int cPixelSize = 4;
</span><span class="cx"> const static int cAlphaChannelOffset = 3;
</span><span class="cx"> const static unsigned char cOpaqueAlpha = static_cast<unsigned char>(0xff);
</span><ins>+
+// These factors and the normal coefficients come from the table under https://www.w3.org/TR/SVG/filters.html#feDiffuseLightingElement.
</ins><span class="cx"> const static float cFactor1div2 = -1 / 2.f;
</span><span class="cx"> const static float cFactor1div3 = -1 / 3.f;
</span><span class="cx"> const static float cFactor1div4 = -1 / 4.f;
</span><span class="cx"> const static float cFactor2div3 = -2 / 3.f;
</span><span class="cx"> 
</span><del>-// << 1 is signed multiply by 2
-inline void FELighting::LightingData::topLeft(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::topLeftNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><span class="lines">@@ -98,11 +99,13 @@
</span><span class="cx">     offset += widthMultipliedByPixelSize;
</span><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-(center << 1) + (right << 1) - bottom + bottomRight);
-    normalVector.setY(-(center << 1) - right + (bottom << 1) + bottomRight);
</del><ins>+    return {
+        -2 * center + 2 * right - bottom + bottomRight,
+        -2 * center - right + 2 * bottom + bottomRight
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::topRow(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::topRowNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="lines">@@ -111,11 +114,13 @@
</span><span class="cx">     int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-(left << 1) + (right << 1) - bottomLeft + bottomRight);
-    normalVector.setY(-left - (center << 1) - right + bottomLeft + (bottom << 1) + bottomRight);
</del><ins>+    return {
+        -2 * left + 2 * right - bottomLeft + bottomRight,
+        -left - 2 * center - right + bottomLeft + 2 * bottom + bottomRight
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::topRight(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::topRightNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="lines">@@ -122,11 +127,13 @@
</span><span class="cx">     offset += widthMultipliedByPixelSize;
</span><span class="cx">     int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-(left << 1) + (center << 1) - bottomLeft + bottom);
-    normalVector.setY(-left - (center << 1) + bottomLeft + (bottom << 1));
</del><ins>+    return {
+        -2 * left + 2 * center - bottomLeft + bottom,
+        -left - 2 * center + bottomLeft + 2 * bottom
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::leftColumn(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::leftColumnNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><span class="lines">@@ -133,14 +140,16 @@
</span><span class="cx">     offset -= widthMultipliedByPixelSize;
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    offset += widthMultipliedByPixelSize << 1;
</del><ins>+    offset += 2 * widthMultipliedByPixelSize;
</ins><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-top + topRight - (center << 1) + (right << 1) - bottom + bottomRight);
-    normalVector.setY(-(top << 1) - topRight + (bottom << 1) + bottomRight);
</del><ins>+    return {
+        -top + topRight - 2 * center + 2 * right - bottom + bottomRight,
+        -2 * top - topRight + 2 * bottom + bottomRight
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::interior(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::interiorNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><span class="lines">@@ -148,15 +157,17 @@
</span><span class="cx">     int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    offset += widthMultipliedByPixelSize << 1;
</del><ins>+    offset += 2 * widthMultipliedByPixelSize;
</ins><span class="cx">     int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-topLeft + topRight - (left << 1) + (right << 1) - bottomLeft + bottomRight);
-    normalVector.setY(-topLeft - (top << 1) - topRight + bottomLeft + (bottom << 1) + bottomRight);
</del><ins>+    return {
+        -topLeft + topRight - 2 * left + 2 * right - bottomLeft + bottomRight,
+        -topLeft - 2 * top - topRight + bottomLeft + 2 * bottom + bottomRight
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::rightColumn(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::rightColumnNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="lines">@@ -163,14 +174,16 @@
</span><span class="cx">     offset -= widthMultipliedByPixelSize;
</span><span class="cx">     int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><del>-    offset += widthMultipliedByPixelSize << 1;
</del><ins>+    offset += 2 * widthMultipliedByPixelSize;
</ins><span class="cx">     int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-topLeft + top - (left << 1) + (center << 1) - bottomLeft + bottom);
-    normalVector.setY(-topLeft - (top << 1) + bottomLeft + (bottom << 1));
</del><ins>+    return {
+        -topLeft + top - 2 * left + 2 * center - bottomLeft + bottom,
+        -topLeft - 2 * top + bottomLeft + 2 * bottom
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::bottomLeft(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::bottomLeftNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><span class="lines">@@ -177,11 +190,13 @@
</span><span class="cx">     offset -= widthMultipliedByPixelSize;
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-top + topRight - (center << 1) + (right << 1));
-    normalVector.setY(-(top << 1) - topRight + (center << 1) + right);
</del><ins>+    return {
+        -top + topRight - 2 * center + 2 * right,
+        -2 * top - topRight + 2 * center + right
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::bottomRow(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::bottomRowNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="lines">@@ -190,11 +205,13 @@
</span><span class="cx">     int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="cx">     int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-topLeft + topRight - (left << 1) + (right << 1));
-    normalVector.setY(-topLeft - (top << 1) - topRight + left + (center << 1) + right);
</del><ins>+    return {
+        -topLeft + topRight - 2 * left + 2 * right,
+        -topLeft - 2 * top - topRight + left + 2 * center + right
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::LightingData::bottomRight(int offset, IntPoint& normalVector)
</del><ins>+inline IntSize FELighting::LightingData::bottomRightNormal(int offset) const
</ins><span class="cx"> {
</span><span class="cx">     int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><span class="lines">@@ -201,17 +218,18 @@
</span><span class="cx">     offset -= widthMultipliedByPixelSize;
</span><span class="cx">     int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset));
</span><span class="cx">     int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset));
</span><del>-    normalVector.setX(-topLeft + top - (left << 1) + (center << 1));
-    normalVector.setY(-topLeft - (top << 1) + left + (center << 1));
</del><ins>+    return {
+        -topLeft + top - 2 * left + 2 * center,
+        topLeft - 2 * top + left + 2 * center
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void FELighting::inlineSetPixel(int offset, LightingData& data, LightSource::PaintingData& paintingData,
-                                       int lightX, int lightY, float factorX, float factorY, IntPoint& normal2DVector)
</del><ins>+inline void FELighting::inlineSetPixel(int offset, LightingData& data, LightSource::PaintingData& paintingData, int lightX, int lightY, float factorX, float factorY, IntSize normal2DVector)
</ins><span class="cx"> {
</span><span class="cx">     m_lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels->item(offset + cAlphaChannelOffset)) * data.surfaceScale);
</span><span class="cx"> 
</span><span class="cx">     float lightStrength;
</span><del>-    if (!normal2DVector.x() && !normal2DVector.y()) {
</del><ins>+    if (normal2DVector.isZero()) {
</ins><span class="cx">         // Normal vector is (0, 0, 1). This is a quite frequent case.
</span><span class="cx">         if (m_lightingType == FELighting::DiffuseLighting)
</span><span class="cx">             lightStrength = m_diffuseConstant * paintingData.lightVector.z() / paintingData.lightVectorLength;
</span><span class="lines">@@ -226,8 +244,8 @@
</span><span class="cx">         }
</span><span class="cx">     } else {
</span><span class="cx">         FloatPoint3D normalVector;
</span><del>-        normalVector.setX(factorX * static_cast<float>(normal2DVector.x()) * data.surfaceScale);
-        normalVector.setY(factorY * static_cast<float>(normal2DVector.y()) * data.surfaceScale);
</del><ins>+        normalVector.setX(factorX * static_cast<float>(normal2DVector.width()) * data.surfaceScale);
+        normalVector.setY(factorY * static_cast<float>(normal2DVector.height()) * data.surfaceScale);
</ins><span class="cx">         normalVector.setZ(1);
</span><span class="cx">         float normalVectorLength = normalVector.length();
</span><span class="cx"> 
</span><span class="lines">@@ -254,8 +272,7 @@
</span><span class="cx">     data.pixels->set(offset + 2, static_cast<unsigned char>(lightStrength * paintingData.colorVector.z()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FELighting::setPixel(int offset, LightingData& data, LightSource::PaintingData& paintingData,
-                          int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector)
</del><ins>+void FELighting::setPixel(int offset, LightingData& data, LightSource::PaintingData& paintingData, int lightX, int lightY, float factorX, float factorY, IntSize normalVector)
</ins><span class="cx"> {
</span><span class="cx">     inlineSetPixel(offset, data, paintingData, lightX, lightY, factorX, factorY, normalVector);
</span><span class="cx"> }
</span><span class="lines">@@ -262,14 +279,10 @@
</span><span class="cx"> 
</span><span class="cx"> inline void FELighting::platformApplyGenericPaint(LightingData& data, LightSource::PaintingData& paintingData, int startY, int endY)
</span><span class="cx"> {
</span><del>-    IntPoint normalVector;
-    int offset = 0;
-
</del><span class="cx">     for (int y = startY; y < endY; ++y) {
</span><del>-        offset = y * data.widthMultipliedByPixelSize + cPixelSize;
</del><ins>+        int offset = y * data.widthMultipliedByPixelSize + cPixelSize;
</ins><span class="cx">         for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize) {
</span><del>-            data.interior(offset, normalVector);
-            inlineSetPixel(offset, data, paintingData, x, y, cFactor1div4, cFactor1div4, normalVector);
</del><ins>+            inlineSetPixel(offset, data, paintingData, x, y, cFactor1div4, cFactor1div4, data.interiorNormal(offset));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -341,55 +354,44 @@
</span><span class="cx">     paintingData.colorVector = FloatPoint3D(m_lightingColor.red(), m_lightingColor.green(), m_lightingColor.blue());
</span><span class="cx">     m_lightSource->initPaintingData(paintingData);
</span><span class="cx"> 
</span><del>-    // Top/Left corner.
-    IntPoint normalVector;
</del><ins>+    // Top left.
</ins><span class="cx">     int offset = 0;
</span><del>-    data.topLeft(offset, normalVector);
-    setPixel(offset, data, paintingData, 0, 0, cFactor2div3, cFactor2div3, normalVector);
</del><ins>+    setPixel(offset, data, paintingData, 0, 0, cFactor2div3, cFactor2div3, data.topLeftNormal(offset));
</ins><span class="cx"> 
</span><del>-    // Top/Right pixel.
</del><ins>+    // Top right.
</ins><span class="cx">     offset = data.widthMultipliedByPixelSize - cPixelSize;
</span><del>-    data.topRight(offset, normalVector);
-    setPixel(offset, data, paintingData, data.widthDecreasedByOne, 0, cFactor2div3, cFactor2div3, normalVector);
</del><ins>+    setPixel(offset, data, paintingData, data.widthDecreasedByOne, 0, cFactor2div3, cFactor2div3, data.topRightNormal(offset));
</ins><span class="cx"> 
</span><del>-    // Bottom/Left pixel.
</del><ins>+    // Bottom left.
</ins><span class="cx">     offset = data.heightDecreasedByOne * data.widthMultipliedByPixelSize;
</span><del>-    data.bottomLeft(offset, normalVector);
-    setPixel(offset, data, paintingData, 0, data.heightDecreasedByOne, cFactor2div3, cFactor2div3, normalVector);
</del><ins>+    setPixel(offset, data, paintingData, 0, data.heightDecreasedByOne, cFactor2div3, cFactor2div3, data.bottomLeftNormal(offset));
</ins><span class="cx"> 
</span><del>-    // Bottom/Right pixel.
</del><ins>+    // Bottom right.
</ins><span class="cx">     offset = height * data.widthMultipliedByPixelSize - cPixelSize;
</span><del>-    data.bottomRight(offset, normalVector);
-    setPixel(offset, data, paintingData, data.widthDecreasedByOne, data.heightDecreasedByOne, cFactor2div3, cFactor2div3, normalVector);
</del><ins>+    setPixel(offset, data, paintingData, data.widthDecreasedByOne, data.heightDecreasedByOne, cFactor2div3, cFactor2div3, data.bottomRightNormal(offset));
</ins><span class="cx"> 
</span><span class="cx">     if (width >= 3) {
</span><span class="cx">         // Top row.
</span><span class="cx">         offset = cPixelSize;
</span><del>-        for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize) {
-            data.topRow(offset, normalVector);
-            inlineSetPixel(offset, data, paintingData, x, 0, cFactor1div3, cFactor1div2, normalVector);
-        }
</del><ins>+        for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize)
+            inlineSetPixel(offset, data, paintingData, x, 0, cFactor1div3, cFactor1div2, data.topRowNormal(offset));
+
</ins><span class="cx">         // Bottom row.
</span><span class="cx">         offset = data.heightDecreasedByOne * data.widthMultipliedByPixelSize + cPixelSize;
</span><del>-        for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize) {
-            data.bottomRow(offset, normalVector);
-            inlineSetPixel(offset, data, paintingData, x, data.heightDecreasedByOne, cFactor1div3, cFactor1div2, normalVector);
-        }
</del><ins>+        for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize)
+            inlineSetPixel(offset, data, paintingData, x, data.heightDecreasedByOne, cFactor1div3, cFactor1div2, data.bottomRowNormal(offset));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (height >= 3) {
</span><span class="cx">         // Left column.
</span><span class="cx">         offset = data.widthMultipliedByPixelSize;
</span><del>-        for (int y = 1; y < data.heightDecreasedByOne; ++y, offset += data.widthMultipliedByPixelSize) {
-            data.leftColumn(offset, normalVector);
-            inlineSetPixel(offset, data, paintingData, 0, y, cFactor1div2, cFactor1div3, normalVector);
-        }
</del><ins>+        for (int y = 1; y < data.heightDecreasedByOne; ++y, offset += data.widthMultipliedByPixelSize)
+            inlineSetPixel(offset, data, paintingData, 0, y, cFactor1div2, cFactor1div3, data.leftColumnNormal(offset));
+
</ins><span class="cx">         // Right column.
</span><del>-        offset = (data.widthMultipliedByPixelSize << 1) - cPixelSize;
-        for (int y = 1; y < data.heightDecreasedByOne; ++y, offset += data.widthMultipliedByPixelSize) {
-            data.rightColumn(offset, normalVector);
-            inlineSetPixel(offset, data, paintingData, data.widthDecreasedByOne, y, cFactor1div2, cFactor1div3, normalVector);
-        }
</del><ins>+        offset = 2 * data.widthMultipliedByPixelSize - cPixelSize;
+        for (int y = 1; y < data.heightDecreasedByOne; ++y, offset += data.widthMultipliedByPixelSize)
+            inlineSetPixel(offset, data, paintingData, data.widthDecreasedByOne, y, cFactor1div2, cFactor1div3, data.rightColumnNormal(offset));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (width >= 3 && height >= 3) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFELightingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.h (225087 => 225088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FELighting.h      2017-11-21 23:14:58 UTC (rev 225087)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.h 2017-11-22 01:02:24 UTC (rev 225088)
</span><span class="lines">@@ -72,15 +72,15 @@
</span><span class="cx">         int widthDecreasedByOne;
</span><span class="cx">         int heightDecreasedByOne;
</span><span class="cx"> 
</span><del>-        inline void topLeft(int offset, IntPoint& normalVector);
-        inline void topRow(int offset, IntPoint& normalVector);
-        inline void topRight(int offset, IntPoint& normalVector);
-        inline void leftColumn(int offset, IntPoint& normalVector);
-        inline void interior(int offset, IntPoint& normalVector);
-        inline void rightColumn(int offset, IntPoint& normalVector);
-        inline void bottomLeft(int offset, IntPoint& normalVector);
-        inline void bottomRow(int offset, IntPoint& normalVector);
-        inline void bottomRight(int offset, IntPoint& normalVector);
</del><ins>+        inline IntSize topLeftNormal(int offset) const;
+        inline IntSize topRowNormal(int offset) const;
+        inline IntSize topRightNormal(int offset) const;
+        inline IntSize leftColumnNormal(int offset) const;
+        inline IntSize interiorNormal(int offset) const;
+        inline IntSize rightColumnNormal(int offset) const;
+        inline IntSize bottomLeftNormal(int offset) const;
+        inline IntSize bottomRowNormal(int offset) const;
+        inline IntSize bottomRightNormal(int offset) const;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     template<typename Type>
</span><span class="lines">@@ -101,11 +101,11 @@
</span><span class="cx"> 
</span><span class="cx">     bool drawLighting(Uint8ClampedArray*, int, int);
</span><span class="cx">     inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&,
</span><del>-                               int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
</del><ins>+        int lightX, int lightY, float factorX, float factorY, IntSize normalVector);
</ins><span class="cx"> 
</span><span class="cx">     // Not worth to inline every occurence of setPixel.
</span><span class="cx">     void setPixel(int offset, LightingData&, LightSource::PaintingData&,
</span><del>-                  int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
</del><ins>+        int lightX, int lightY, float factorX, float factorY, IntSize normalVector);
</ins><span class="cx"> 
</span><span class="cx">     void platformApplySoftware() override;
</span><span class="cx"> 
</span><span class="lines">@@ -114,8 +114,10 @@
</span><span class="cx">     inline void platformApplyGenericPaint(LightingData&, LightSource::PaintingData&, int startX, int startY);
</span><span class="cx">     inline void platformApplyGeneric(LightingData&, LightSource::PaintingData&);
</span><span class="cx"> 
</span><ins>+#if CPU(ARM_NEON) && CPU(ARM_TRADITIONAL) && COMPILER(GCC_OR_CLANG)
</ins><span class="cx">     static int getPowerCoefficients(float exponent);
</span><span class="cx">     inline void platformApplyNeon(LightingData&, LightSource::PaintingData&);
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     LightingType m_lightingType;
</span><span class="cx">     Ref<LightSource> m_lightSource;
</span></span></pre>
</div>
</div>

</body>
</html>