WebKit Bugzilla
Attachment 346032 Details for
Bug 188143
: Shrink GraphicsLayer by making m_transform and m_childrenTransform be unique_ptrs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188143-20180729084604.patch (text/plain), 11.81 KB, created by
Simon Fraser (smfr)
on 2018-07-29 08:46:05 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2018-07-29 08:46:05 PDT
Size:
11.81 KB
patch
obsolete
>Subversion Revision: 234343 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c36ea45c71471cfa7e03f4225f68701f57f572b6..2adfc11b9ff0b6efa8cbbcbb2d3888bdd45caff9 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2018-07-28 Simon Fraser <simon.fraser@apple.com> >+ >+ Shrink GraphicsLayer by making m_transform and m_childrenTransform be unique_ptrs >+ https://bugs.webkit.org/show_bug.cgi?id=188143 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ m_transform and m_childrenTransform are usually identity; save space by making >+ these unique_ptrs. The getters still return references by returning a reference >+ to a NeverDestroyed<TransformationMatrix> if necessary. >+ >+ Shrinks GraphicsLayerCA from 840 to 640 bytes. >+ >+ * platform/graphics/GraphicsLayer.cpp: >+ (WebCore::identityTransform): >+ (WebCore::GraphicsLayer::transform const): >+ (WebCore::GraphicsLayer::setTransform): >+ (WebCore::GraphicsLayer::childrenTransform const): >+ (WebCore::GraphicsLayer::setChildrenTransform): >+ (WebCore::GraphicsLayer::dumpProperties const): >+ * platform/graphics/GraphicsLayer.h: >+ (WebCore::GraphicsLayer::hasNonIdentityTransform const): >+ (WebCore::GraphicsLayer::hasNonIdentityChildrenTransform const): >+ (WebCore::GraphicsLayer::transform const): Deleted. >+ (WebCore::GraphicsLayer::setTransform): Deleted. >+ (WebCore::GraphicsLayer::childrenTransform const): Deleted. >+ (WebCore::GraphicsLayer::setChildrenTransform): Deleted. >+ * platform/graphics/ca/GraphicsLayerCA.cpp: >+ (WebCore::GraphicsLayerCA::setTransform): >+ (WebCore::GraphicsLayerCA::setChildrenTransform): >+ (WebCore::GraphicsLayerCA::layerTransform const): >+ (WebCore::GraphicsLayerCA::updateTransform): >+ (WebCore::GraphicsLayerCA::updateChildrenTransform): >+ (WebCore::GraphicsLayerCA::removeCAAnimationFromLayer): >+ > 2018-07-28 Simon Fraser <simon.fraser@apple.com> > > Shrink GraphicsLayerCA >diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.cpp b/Source/WebCore/platform/graphics/GraphicsLayer.cpp >index 90022e6a817a681ee2df64bb436a9212ea5603f0..b9641bb536e0720164c49afa3dc83e7ed542ae17 100644 >--- a/Source/WebCore/platform/graphics/GraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/GraphicsLayer.cpp >@@ -292,6 +292,38 @@ void GraphicsLayer::removeFromParent() > } > } > >+static const TransformationMatrix& identityTransform() >+{ >+ static NeverDestroyed<TransformationMatrix> identityTransform; >+ return identityTransform; >+} >+ >+const TransformationMatrix& GraphicsLayer::transform() const >+{ >+ return m_transform ? *m_transform : identityTransform(); >+} >+ >+void GraphicsLayer::setTransform(const TransformationMatrix& matrix) >+{ >+ if (m_transform) >+ *m_transform = matrix; >+ else >+ m_transform = std::make_unique<TransformationMatrix>(matrix); >+} >+ >+const TransformationMatrix& GraphicsLayer::childrenTransform() const >+{ >+ return m_childrenTransform ? *m_childrenTransform : identityTransform(); >+} >+ >+void GraphicsLayer::setChildrenTransform(const TransformationMatrix& matrix) >+{ >+ if (m_childrenTransform) >+ *m_childrenTransform = matrix; >+ else >+ m_childrenTransform = std::make_unique<TransformationMatrix>(matrix); >+} >+ > void GraphicsLayer::setMaskLayer(GraphicsLayer* layer) > { > if (layer == m_maskLayer) >@@ -775,22 +807,22 @@ void GraphicsLayer::dumpProperties(TextStream& ts, LayerTreeAsTextBehavior behav > if (behavior & LayerTreeAsTextIncludeBackingStoreAttached) > ts << indent << "(backingStoreAttached " << backingStoreAttachedForTesting() << ")\n"; > >- if (!m_transform.isIdentity()) { >+ if (m_transform && !m_transform->isIdentity()) { > ts << indent << "(transform "; >- ts << "[" << m_transform.m11() << " " << m_transform.m12() << " " << m_transform.m13() << " " << m_transform.m14() << "] "; >- ts << "[" << m_transform.m21() << " " << m_transform.m22() << " " << m_transform.m23() << " " << m_transform.m24() << "] "; >- ts << "[" << m_transform.m31() << " " << m_transform.m32() << " " << m_transform.m33() << " " << m_transform.m34() << "] "; >- ts << "[" << m_transform.m41() << " " << m_transform.m42() << " " << m_transform.m43() << " " << m_transform.m44() << "])\n"; >+ ts << "[" << m_transform->m11() << " " << m_transform->m12() << " " << m_transform->m13() << " " << m_transform->m14() << "] "; >+ ts << "[" << m_transform->m21() << " " << m_transform->m22() << " " << m_transform->m23() << " " << m_transform->m24() << "] "; >+ ts << "[" << m_transform->m31() << " " << m_transform->m32() << " " << m_transform->m33() << " " << m_transform->m34() << "] "; >+ ts << "[" << m_transform->m41() << " " << m_transform->m42() << " " << m_transform->m43() << " " << m_transform->m44() << "])\n"; > } > > // Avoid dumping the sublayer transform on the root layer, because it's used for geometry flipping, whose behavior > // differs between platforms. >- if (parent() && !m_childrenTransform.isIdentity()) { >+ if (parent() && m_childrenTransform && !m_childrenTransform->isIdentity()) { > ts << indent << "(childrenTransform "; >- ts << "[" << m_childrenTransform.m11() << " " << m_childrenTransform.m12() << " " << m_childrenTransform.m13() << " " << m_childrenTransform.m14() << "] "; >- ts << "[" << m_childrenTransform.m21() << " " << m_childrenTransform.m22() << " " << m_childrenTransform.m23() << " " << m_childrenTransform.m24() << "] "; >- ts << "[" << m_childrenTransform.m31() << " " << m_childrenTransform.m32() << " " << m_childrenTransform.m33() << " " << m_childrenTransform.m34() << "] "; >- ts << "[" << m_childrenTransform.m41() << " " << m_childrenTransform.m42() << " " << m_childrenTransform.m43() << " " << m_childrenTransform.m44() << "])\n"; >+ ts << "[" << m_childrenTransform->m11() << " " << m_childrenTransform->m12() << " " << m_childrenTransform->m13() << " " << m_childrenTransform->m14() << "] "; >+ ts << "[" << m_childrenTransform->m21() << " " << m_childrenTransform->m22() << " " << m_childrenTransform->m23() << " " << m_childrenTransform->m24() << "] "; >+ ts << "[" << m_childrenTransform->m31() << " " << m_childrenTransform->m32() << " " << m_childrenTransform->m33() << " " << m_childrenTransform->m34() << "] "; >+ ts << "[" << m_childrenTransform->m41() << " " << m_childrenTransform->m42() << " " << m_childrenTransform->m43() << " " << m_childrenTransform->m44() << "])\n"; > } > > if (m_maskLayer) { >diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h >index b501a8f0ea276f28ccf76cd02d7649fedf216367..f11ca942c5cd2f7594e260432b194776218bb6ac 100644 >--- a/Source/WebCore/platform/graphics/GraphicsLayer.h >+++ b/Source/WebCore/platform/graphics/GraphicsLayer.h >@@ -339,11 +339,13 @@ public: > // For platforms that move underlying platform layers on a different thread for scrolling; just update the GraphicsLayer state. > virtual void syncBoundsOrigin(const FloatPoint& origin) { m_boundsOrigin = origin; } > >- const TransformationMatrix& transform() const { return m_transform; } >- virtual void setTransform(const TransformationMatrix& t) { m_transform = t; } >+ const TransformationMatrix& transform() const; >+ virtual void setTransform(const TransformationMatrix&); >+ bool hasNonIdentityTransform() const { return m_transform && !m_transform->isIdentity(); } > >- const TransformationMatrix& childrenTransform() const { return m_childrenTransform; } >- virtual void setChildrenTransform(const TransformationMatrix& t) { m_childrenTransform = t; } >+ const TransformationMatrix& childrenTransform() const; >+ virtual void setChildrenTransform(const TransformationMatrix&); >+ bool hasNonIdentityChildrenTransform() const { return m_childrenTransform && !m_childrenTransform->isIdentity(); } > > bool preserves3D() const { return m_preserves3D; } > virtual void setPreserves3D(bool b) { m_preserves3D = b; } >@@ -638,8 +640,8 @@ protected: > FloatSize m_size; > FloatPoint m_boundsOrigin; > >- TransformationMatrix m_transform; >- TransformationMatrix m_childrenTransform; >+ std::unique_ptr<TransformationMatrix> m_transform; >+ std::unique_ptr<TransformationMatrix> m_childrenTransform; > > Color m_backgroundColor; > float m_opacity { 1 }; >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >index ff4b03c2128de8b3a98c2a4d81758cee77cff93b..533bd44a1c9d82d76bc0919b5f16d2a6b28a86e3 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >@@ -654,7 +654,7 @@ void GraphicsLayerCA::syncBoundsOrigin(const FloatPoint& origin) > > void GraphicsLayerCA::setTransform(const TransformationMatrix& t) > { >- if (t == m_transform) >+ if (t == transform()) > return; > > GraphicsLayer::setTransform(t); >@@ -663,7 +663,7 @@ void GraphicsLayerCA::setTransform(const TransformationMatrix& t) > > void GraphicsLayerCA::setChildrenTransform(const TransformationMatrix& t) > { >- if (t == m_childrenTransform) >+ if (t == childrenTransform()) > return; > > GraphicsLayer::setChildrenTransform(t); >@@ -1338,7 +1338,11 @@ TransformationMatrix GraphicsLayerCA::layerTransform(const FloatPoint& position, > TransformationMatrix transform; > transform.translate(position.x(), position.y()); > >- TransformationMatrix currentTransform = customTransform ? *customTransform : m_transform; >+ TransformationMatrix currentTransform; >+ if (customTransform) >+ currentTransform = *customTransform; >+ else if (m_transform) >+ currentTransform = *m_transform; > > if (!currentTransform.isIdentity()) { > FloatPoint3D absoluteAnchorPoint(anchorPoint()); >@@ -1349,7 +1353,7 @@ TransformationMatrix GraphicsLayerCA::layerTransform(const FloatPoint& position, > } > > if (GraphicsLayer* parentLayer = parent()) { >- if (!parentLayer->childrenTransform().isIdentity()) { >+ if (parentLayer->hasNonIdentityChildrenTransform()) { > FloatPoint3D parentAnchorPoint(parentLayer->anchorPoint()); > parentAnchorPoint.scale(parentLayer->size().width(), parentLayer->size().height(), 1); > >@@ -2016,7 +2020,7 @@ void GraphicsLayerCA::updateGeometry(float pageScaleFactor, const FloatPoint& po > > void GraphicsLayerCA::updateTransform() > { >- primaryLayer()->setTransform(m_transform); >+ primaryLayer()->setTransform(transform()); > > if (LayerMap* layerCloneMap = primaryLayerClones()) { > for (auto& clone : *layerCloneMap) { >@@ -2026,18 +2030,18 @@ void GraphicsLayerCA::updateTransform() > // which we set up in replicatedLayerRoot(). > currLayer->setTransform(TransformationMatrix()); > } else >- currLayer->setTransform(m_transform); >+ currLayer->setTransform(transform()); > } > } > } > > void GraphicsLayerCA::updateChildrenTransform() > { >- primaryLayer()->setSublayerTransform(m_childrenTransform); >+ primaryLayer()->setSublayerTransform(childrenTransform()); > > if (LayerMap* layerCloneMap = primaryLayerClones()) { > for (auto& layer : layerCloneMap->values()) >- layer->setSublayerTransform(m_childrenTransform); >+ layer->setSublayerTransform(childrenTransform()); > } > } > >@@ -2911,7 +2915,7 @@ bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, co > return false; > > layer->removeAnimationForKey(animationID); >- bug7311367Workaround(m_structuralLayer.get(), m_transform); >+ bug7311367Workaround(m_structuralLayer.get(), transform()); > > if (LayerMap* layerCloneMap = animatedLayerClones(property)) { > for (auto& clone : *layerCloneMap) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188143
:
346010
|
346013
|
346014
|
346032
|
346033