Title: [230479] trunk/Source/WebCore
Revision
230479
Author
zandober...@gmail.com
Date
2018-04-10 03:47:16 -0700 (Tue, 10 Apr 2018)

Log Message

[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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (230478 => 230479)


--- 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)
@@ -1,3 +1,35 @@
+2018-04-10  Zan Dobersek  <zdober...@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:
+
 2018-04-09  Brent Fulgham  <bfulg...@apple.com>
 
         Add ProcessPrivilege assertions to places that access NSApp

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (230478 => 230479)


--- 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)
@@ -63,17 +63,35 @@
         return;
 
     // Compute transforms recursively on the way down to leafs.
-    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);
+    {
+        TransformationMatrix parentTransform;
+        if (m_parent)
+            parentTransform = m_parent->m_layerTransforms.combinedForChildren;
+        else if (m_effectTarget)
+            parentTransform = m_effectTarget->m_layerTransforms.combined;
 
-    m_state.visible = m_state.backfaceVisibility || !m_currentTransform.combined().isBackFaceVisible();
+        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();
 
+        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();
+
     if (m_parent && m_parent->m_state.preserves3D)
-        m_centerZ = m_currentTransform.combined().mapPoint(FloatPoint3D(m_state.size.width() / 2, m_state.size.height() / 2, 0)).z();
+        m_centerZ = m_layerTransforms.combined.mapPoint(FloatPoint3D(m_state.size.width() / 2, m_state.size.height() / 2, 0)).z();
 
     if (m_state.maskLayer)
         m_state.maskLayer->computeTransformsRecursive();
@@ -117,7 +135,7 @@
     TransformationMatrix transform;
     transform.translate(options.offset.width(), options.offset.height());
     transform.multiply(options.transform);
-    transform.multiply(m_currentTransform.combined());
+    transform.multiply(m_layerTransforms.combined);
 
     if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.isVisible()) {
         options.textureMapper.drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
@@ -177,7 +195,7 @@
         TransformationMatrix clipTransform;
         clipTransform.translate(options.offset.width(), options.offset.height());
         clipTransform.multiply(options.transform);
-        clipTransform.multiply(m_currentTransform.combined());
+        clipTransform.multiply(m_layerTransforms.combined);
         options.textureMapper.beginClip(clipTransform, layerRect());
 
         // If as a result of beginClip(), the clipping area is empty, it means that the intersection of the previous
@@ -225,8 +243,8 @@
     if (m_state.replicaLayer) {
         TextureMapperPaintOptions replicaOptions(options);
         replicaOptions.transform
-            .multiply(m_state.replicaLayer->m_currentTransform.combined())
-            .multiply(m_currentTransform.combined().inverse().value_or(TransformationMatrix()));
+            .multiply(m_state.replicaLayer->m_layerTransforms.combined)
+            .multiply(m_layerTransforms.combined.inverse().value_or(TransformationMatrix()));
         paintSelfAndChildren(replicaOptions);
     }
 
@@ -235,7 +253,8 @@
 
 TransformationMatrix TextureMapperLayer::replicaTransform()
 {
-    return TransformationMatrix(m_state.replicaLayer->m_currentTransform.combined()).multiply(m_currentTransform.combined().inverse().value_or(TransformationMatrix()));
+    return TransformationMatrix(m_state.replicaLayer->m_layerTransforms.combined)
+        .multiply(m_layerTransforms.combined.inverse().value_or(TransformationMatrix()));
 }
 
 static void resolveOverlaps(Region& newRegion, Region& overlapRegion, Region& nonOverlapRegion)
@@ -273,7 +292,7 @@
         boundingRect.unite(replicaMatrix.mapRect(boundingRect));
     }
 
-    boundingRect = m_currentTransform.combined().mapRect(boundingRect);
+    boundingRect = m_layerTransforms.combined.mapRect(boundingRect);
 
     // Count all masks and filters as overlap layers.
     if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
@@ -498,37 +517,31 @@
 void TextureMapperLayer::setPosition(const FloatPoint& position)
 {
     m_state.pos = position;
-    m_currentTransform.setPosition(adjustedPosition());
 }
 
 void TextureMapperLayer::setSize(const FloatSize& size)
 {
     m_state.size = size;
-    m_currentTransform.setSize(size);
 }
 
 void TextureMapperLayer::setAnchorPoint(const FloatPoint3D& anchorPoint)
 {
     m_state.anchorPoint = anchorPoint;
-    m_currentTransform.setAnchorPoint(anchorPoint);
 }
 
 void TextureMapperLayer::setPreserves3D(bool preserves3D)
 {
     m_state.preserves3D = preserves3D;
-    m_currentTransform.setFlattening(!preserves3D);
 }
 
 void TextureMapperLayer::setTransform(const TransformationMatrix& transform)
 {
     m_state.transform = transform;
-    m_currentTransform.setLocalTransform(transform);
 }
 
 void TextureMapperLayer::setChildrenTransform(const TransformationMatrix& childrenTransform)
 {
     m_state.childrenTransform = childrenTransform;
-    m_currentTransform.setChildrenTransform(childrenTransform);
 }
 
 void TextureMapperLayer::setContentsRect(const FloatRect& contentsRect)
@@ -643,7 +656,7 @@
     TextureMapperAnimation::ApplicationResult applicationResults;
     m_animations.apply(applicationResults, time);
 
-    m_currentTransform.setLocalTransform(applicationResults.transform.value_or(m_state.transform));
+    m_layerTransforms.localTransform = applicationResults.transform.value_or(m_state.transform);
     m_currentOpacity = applicationResults.opacity.value_or(m_state.opacity);
     m_currentFilters = applicationResults.filters.value_or(m_state.filters);
 
@@ -670,7 +683,6 @@
         m_scrollPositionDelta = FloatSize();
     else
         m_scrollPositionDelta = delta;
-    m_currentTransform.setPosition(adjustedPosition());
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (230478 => 230479)


--- 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)
@@ -22,7 +22,6 @@
 
 #include "FilterOperations.h"
 #include "FloatRect.h"
-#include "GraphicsLayerTransform.h"
 #include "TextureMapper.h"
 #include "TextureMapperAnimation.h"
 #include "TextureMapperBackingStore.h"
@@ -149,7 +148,6 @@
     TextureMapperLayer* m_parent { nullptr };
     TextureMapperLayer* m_effectTarget { nullptr };
     RefPtr<TextureMapperBackingStore> m_backingStore;
-    GraphicsLayerTransform m_currentTransform;
     TextureMapperPlatformLayer* m_contentsLayer { nullptr };
     float m_currentOpacity { 1.0 };
     FilterOperations m_currentFilters;
@@ -208,6 +206,13 @@
     FloatSize m_scrollPositionDelta;
     bool m_fixedToViewport { false };
     uint32_t m_id { 0 };
+
+    struct {
+        TransformationMatrix localTransform;
+
+        TransformationMatrix combined;
+        TransformationMatrix combinedForChildren;
+    } m_layerTransforms;
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to