<!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>[230479] 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/230479">230479</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2018-04-10 03:47:16 -0700 (Tue, 10 Apr 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[TexMap] TextureMapperLayer unnecessarily duplicates state in GraphicsLayerTransform
https://bugs.webkit.org/show_bug.cgi?id=183868

Reviewed by Carlos Garcia Campos.

Drop the GraphicsLayerTransform member variable from TextureMapperLayer
and instead compute all the required transform information in the
computeTransformsRecursive() method. These computations are not too
expensive, and in turn we can drop an object from this class' state that
was only duplicating a bunch of state variables.

No new tests -- no change in functionality.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeTransformsRecursive):
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::paintSelfAndChildren):
(WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
(WebCore::TextureMapperLayer::replicaTransform):
(WebCore::TextureMapperLayer::computeOverlapRegions):
(WebCore::TextureMapperLayer::setPosition):
(WebCore::TextureMapperLayer::setSize):
(WebCore::TextureMapperLayer::setAnchorPoint):
(WebCore::TextureMapperLayer::setPreserves3D):
(WebCore::TextureMapperLayer::setTransform):
(WebCore::TextureMapperLayer::setChildrenTransform):
(WebCore::TextureMapperLayer::syncAnimations):
(WebCore::TextureMapperLayer::setScrollPositionDeltaIfNeeded):
* platform/graphics/texmap/TextureMapperLayer.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayercpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayerh">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (230478 => 230479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-04-10 08:43:29 UTC (rev 230478)
+++ trunk/Source/WebCore/ChangeLog      2018-04-10 10:47:16 UTC (rev 230479)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2018-04-10  Zan Dobersek  <zdobersek@igalia.com>
+
+        [TexMap] TextureMapperLayer unnecessarily duplicates state in GraphicsLayerTransform
+        https://bugs.webkit.org/show_bug.cgi?id=183868
+
+        Reviewed by Carlos Garcia Campos.
+
+        Drop the GraphicsLayerTransform member variable from TextureMapperLayer
+        and instead compute all the required transform information in the
+        computeTransformsRecursive() method. These computations are not too
+        expensive, and in turn we can drop an object from this class' state that
+        was only duplicating a bunch of state variables.
+
+        No new tests -- no change in functionality.
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computeTransformsRecursive):
+        (WebCore::TextureMapperLayer::paintSelf):
+        (WebCore::TextureMapperLayer::paintSelfAndChildren):
+        (WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
+        (WebCore::TextureMapperLayer::replicaTransform):
+        (WebCore::TextureMapperLayer::computeOverlapRegions):
+        (WebCore::TextureMapperLayer::setPosition):
+        (WebCore::TextureMapperLayer::setSize):
+        (WebCore::TextureMapperLayer::setAnchorPoint):
+        (WebCore::TextureMapperLayer::setPreserves3D):
+        (WebCore::TextureMapperLayer::setTransform):
+        (WebCore::TextureMapperLayer::setChildrenTransform):
+        (WebCore::TextureMapperLayer::syncAnimations):
+        (WebCore::TextureMapperLayer::setScrollPositionDeltaIfNeeded):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+
</ins><span class="cx"> 2018-04-09  Brent Fulgham  <bfulgham@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add ProcessPrivilege assertions to places that access NSApp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (230478 => 230479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp     2018-04-10 08:43:29 UTC (rev 230478)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp        2018-04-10 10:47:16 UTC (rev 230479)
</span><span class="lines">@@ -63,17 +63,35 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // Compute transforms recursively on the way down to leafs.
</span><del>-    TransformationMatrix parentTransform;
-    if (m_parent)
-        parentTransform = m_parent->m_currentTransform.combinedForChildren();
-    else if (m_effectTarget)
-        parentTransform = m_effectTarget->m_currentTransform.combined();
-    m_currentTransform.combineTransforms(parentTransform);
</del><ins>+    {
+        TransformationMatrix parentTransform;
+        if (m_parent)
+            parentTransform = m_parent->m_layerTransforms.combinedForChildren;
+        else if (m_effectTarget)
+            parentTransform = m_effectTarget->m_layerTransforms.combined;
</ins><span class="cx"> 
</span><del>-    m_state.visible = m_state.backfaceVisibility || !m_currentTransform.combined().isBackFaceVisible();
</del><ins>+        const float originX = m_state.anchorPoint.x() * m_state.size.width();
+        const float originY = m_state.anchorPoint.y() * m_state.size.height();
+        auto position = adjustedPosition();
</ins><span class="cx"> 
</span><ins>+        m_layerTransforms.combined = parentTransform;
+        m_layerTransforms.combined
+            .translate3d(originX + position.x(), originY + position.y(), m_state.anchorPoint.z())
+            .multiply(m_layerTransforms.localTransform);
+
+        m_layerTransforms.combinedForChildren = m_layerTransforms.combined;
+        m_layerTransforms.combined.translate3d(-originX, -originY, -m_state.anchorPoint.z());
+
+        if (!m_state.preserves3D)
+            m_layerTransforms.combinedForChildren = m_layerTransforms.combinedForChildren.to2dTransform();
+        m_layerTransforms.combinedForChildren.multiply(m_state.childrenTransform);
+        m_layerTransforms.combinedForChildren.translate3d(-originX, -originY, -m_state.anchorPoint.z());
+    }
+
+    m_state.visible = m_state.backfaceVisibility || !m_layerTransforms.combined.isBackFaceVisible();
+
</ins><span class="cx">     if (m_parent && m_parent->m_state.preserves3D)
</span><del>-        m_centerZ = m_currentTransform.combined().mapPoint(FloatPoint3D(m_state.size.width() / 2, m_state.size.height() / 2, 0)).z();
</del><ins>+        m_centerZ = m_layerTransforms.combined.mapPoint(FloatPoint3D(m_state.size.width() / 2, m_state.size.height() / 2, 0)).z();
</ins><span class="cx"> 
</span><span class="cx">     if (m_state.maskLayer)
</span><span class="cx">         m_state.maskLayer->computeTransformsRecursive();
</span><span class="lines">@@ -117,7 +135,7 @@
</span><span class="cx">     TransformationMatrix transform;
</span><span class="cx">     transform.translate(options.offset.width(), options.offset.height());
</span><span class="cx">     transform.multiply(options.transform);
</span><del>-    transform.multiply(m_currentTransform.combined());
</del><ins>+    transform.multiply(m_layerTransforms.combined);
</ins><span class="cx"> 
</span><span class="cx">     if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.isVisible()) {
</span><span class="cx">         options.textureMapper.drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
</span><span class="lines">@@ -177,7 +195,7 @@
</span><span class="cx">         TransformationMatrix clipTransform;
</span><span class="cx">         clipTransform.translate(options.offset.width(), options.offset.height());
</span><span class="cx">         clipTransform.multiply(options.transform);
</span><del>-        clipTransform.multiply(m_currentTransform.combined());
</del><ins>+        clipTransform.multiply(m_layerTransforms.combined);
</ins><span class="cx">         options.textureMapper.beginClip(clipTransform, layerRect());
</span><span class="cx"> 
</span><span class="cx">         // If as a result of beginClip(), the clipping area is empty, it means that the intersection of the previous
</span><span class="lines">@@ -225,8 +243,8 @@
</span><span class="cx">     if (m_state.replicaLayer) {
</span><span class="cx">         TextureMapperPaintOptions replicaOptions(options);
</span><span class="cx">         replicaOptions.transform
</span><del>-            .multiply(m_state.replicaLayer->m_currentTransform.combined())
-            .multiply(m_currentTransform.combined().inverse().value_or(TransformationMatrix()));
</del><ins>+            .multiply(m_state.replicaLayer->m_layerTransforms.combined)
+            .multiply(m_layerTransforms.combined.inverse().value_or(TransformationMatrix()));
</ins><span class="cx">         paintSelfAndChildren(replicaOptions);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -235,7 +253,8 @@
</span><span class="cx"> 
</span><span class="cx"> TransformationMatrix TextureMapperLayer::replicaTransform()
</span><span class="cx"> {
</span><del>-    return TransformationMatrix(m_state.replicaLayer->m_currentTransform.combined()).multiply(m_currentTransform.combined().inverse().value_or(TransformationMatrix()));
</del><ins>+    return TransformationMatrix(m_state.replicaLayer->m_layerTransforms.combined)
+        .multiply(m_layerTransforms.combined.inverse().value_or(TransformationMatrix()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void resolveOverlaps(Region& newRegion, Region& overlapRegion, Region& nonOverlapRegion)
</span><span class="lines">@@ -273,7 +292,7 @@
</span><span class="cx">         boundingRect.unite(replicaMatrix.mapRect(boundingRect));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    boundingRect = m_currentTransform.combined().mapRect(boundingRect);
</del><ins>+    boundingRect = m_layerTransforms.combined.mapRect(boundingRect);
</ins><span class="cx"> 
</span><span class="cx">     // Count all masks and filters as overlap layers.
</span><span class="cx">     if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
</span><span class="lines">@@ -498,37 +517,31 @@
</span><span class="cx"> void TextureMapperLayer::setPosition(const FloatPoint& position)
</span><span class="cx"> {
</span><span class="cx">     m_state.pos = position;
</span><del>-    m_currentTransform.setPosition(adjustedPosition());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setSize(const FloatSize& size)
</span><span class="cx"> {
</span><span class="cx">     m_state.size = size;
</span><del>-    m_currentTransform.setSize(size);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setAnchorPoint(const FloatPoint3D& anchorPoint)
</span><span class="cx"> {
</span><span class="cx">     m_state.anchorPoint = anchorPoint;
</span><del>-    m_currentTransform.setAnchorPoint(anchorPoint);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setPreserves3D(bool preserves3D)
</span><span class="cx"> {
</span><span class="cx">     m_state.preserves3D = preserves3D;
</span><del>-    m_currentTransform.setFlattening(!preserves3D);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setTransform(const TransformationMatrix& transform)
</span><span class="cx"> {
</span><span class="cx">     m_state.transform = transform;
</span><del>-    m_currentTransform.setLocalTransform(transform);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setChildrenTransform(const TransformationMatrix& childrenTransform)
</span><span class="cx"> {
</span><span class="cx">     m_state.childrenTransform = childrenTransform;
</span><del>-    m_currentTransform.setChildrenTransform(childrenTransform);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::setContentsRect(const FloatRect& contentsRect)
</span><span class="lines">@@ -643,7 +656,7 @@
</span><span class="cx">     TextureMapperAnimation::ApplicationResult applicationResults;
</span><span class="cx">     m_animations.apply(applicationResults, time);
</span><span class="cx"> 
</span><del>-    m_currentTransform.setLocalTransform(applicationResults.transform.value_or(m_state.transform));
</del><ins>+    m_layerTransforms.localTransform = applicationResults.transform.value_or(m_state.transform);
</ins><span class="cx">     m_currentOpacity = applicationResults.opacity.value_or(m_state.opacity);
</span><span class="cx">     m_currentFilters = applicationResults.filters.value_or(m_state.filters);
</span><span class="cx"> 
</span><span class="lines">@@ -670,7 +683,6 @@
</span><span class="cx">         m_scrollPositionDelta = FloatSize();
</span><span class="cx">     else
</span><span class="cx">         m_scrollPositionDelta = delta;
</span><del>-    m_currentTransform.setPosition(adjustedPosition());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (230478 => 230479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h       2018-04-10 08:43:29 UTC (rev 230478)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h  2018-04-10 10:47:16 UTC (rev 230479)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include "FilterOperations.h"
</span><span class="cx"> #include "FloatRect.h"
</span><del>-#include "GraphicsLayerTransform.h"
</del><span class="cx"> #include "TextureMapper.h"
</span><span class="cx"> #include "TextureMapperAnimation.h"
</span><span class="cx"> #include "TextureMapperBackingStore.h"
</span><span class="lines">@@ -149,7 +148,6 @@
</span><span class="cx">     TextureMapperLayer* m_parent { nullptr };
</span><span class="cx">     TextureMapperLayer* m_effectTarget { nullptr };
</span><span class="cx">     RefPtr<TextureMapperBackingStore> m_backingStore;
</span><del>-    GraphicsLayerTransform m_currentTransform;
</del><span class="cx">     TextureMapperPlatformLayer* m_contentsLayer { nullptr };
</span><span class="cx">     float m_currentOpacity { 1.0 };
</span><span class="cx">     FilterOperations m_currentFilters;
</span><span class="lines">@@ -208,6 +206,13 @@
</span><span class="cx">     FloatSize m_scrollPositionDelta;
</span><span class="cx">     bool m_fixedToViewport { false };
</span><span class="cx">     uint32_t m_id { 0 };
</span><ins>+
+    struct {
+        TransformationMatrix localTransform;
+
+        TransformationMatrix combined;
+        TransformationMatrix combinedForChildren;
+    } m_layerTransforms;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>