Modified: trunk/Source/WebCore/ChangeLog (89440 => 89441)
--- trunk/Source/WebCore/ChangeLog 2011-06-22 16:45:47 UTC (rev 89440)
+++ trunk/Source/WebCore/ChangeLog 2011-06-22 16:46:33 UTC (rev 89441)
@@ -1,3 +1,27 @@
+2011-06-22 Simon Fraser <[email protected]>
+
+ Reviewed by Dan Bernstein.
+
+ Update position, bounds and anchor point in GraphicsLayerCA all at once
+ https://bugs.webkit.org/show_bug.cgi?id=63148
+
+ Since position, bounds and anchor point are inter-dependent, avoid
+ redundant work by simply updating them all at the same time.
+
+ No behavior changes, so no new tests.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::setPosition):
+ (WebCore::GraphicsLayerCA::setAnchorPoint):
+ (WebCore::GraphicsLayerCA::setSize):
+ (WebCore::GraphicsLayerCA::setBoundsOrigin):
+ (WebCore::GraphicsLayerCA::setAllowTiledLayer):
+ (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+ (WebCore::GraphicsLayerCA::updateGeometry):
+ (WebCore::GraphicsLayerCA::ensureStructuralLayer):
+ (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
+ * platform/graphics/ca/GraphicsLayerCA.h:
+
2011-06-22 Ryosuke Niwa <[email protected]>
Reviewed by Darin Adler.
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (89440 => 89441)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2011-06-22 16:45:47 UTC (rev 89440)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2011-06-22 16:46:33 UTC (rev 89441)
@@ -381,7 +381,7 @@
return;
GraphicsLayer::setPosition(point);
- noteLayerPropertyChanged(PositionChanged);
+ noteLayerPropertyChanged(GeometryChanged);
}
void GraphicsLayerCA::setAnchorPoint(const FloatPoint3D& point)
@@ -390,7 +390,7 @@
return;
GraphicsLayer::setAnchorPoint(point);
- noteLayerPropertyChanged(AnchorPointChanged);
+ noteLayerPropertyChanged(GeometryChanged);
}
void GraphicsLayerCA::setSize(const FloatSize& size)
@@ -399,7 +399,7 @@
return;
GraphicsLayer::setSize(size);
- noteLayerPropertyChanged(BoundsChanged);
+ noteLayerPropertyChanged(GeometryChanged);
}
void GraphicsLayerCA::setBoundsOrigin(const FloatPoint& origin)
@@ -408,7 +408,7 @@
return;
GraphicsLayer::setBoundsOrigin(origin);
- noteLayerPropertyChanged(BoundsChanged);
+ noteLayerPropertyChanged(GeometryChanged);
}
void GraphicsLayerCA::setTransform(const TransformationMatrix& t)
@@ -506,7 +506,7 @@
m_allowTiledLayer = allowTiledLayer;
// Handling this as a BoundsChanged will cause use to switch in or out of tiled layer as needed
- noteLayerPropertyChanged(BoundsChanged);
+ noteLayerPropertyChanged(GeometryChanged);
}
void GraphicsLayerCA::setBackgroundColor(const Color& color)
@@ -855,14 +855,8 @@
if (m_uncommittedChanges & ChildrenChanged)
updateSublayerList();
- if (m_uncommittedChanges & PositionChanged)
- updateLayerPosition();
-
- if (m_uncommittedChanges & AnchorPointChanged)
- updateAnchorPoint();
-
- if (m_uncommittedChanges & BoundsChanged)
- updateBounds();
+ if (m_uncommittedChanges & GeometryChanged)
+ updateGeometry();
if (m_uncommittedChanges & TransformChanged)
updateTransform();
@@ -976,14 +970,18 @@
m_layer->setSublayers(newSublayers);
}
-void GraphicsLayerCA::updateLayerPosition()
+void GraphicsLayerCA::updateGeometry()
{
+ bool needTiledLayer = requiresTiledLayer(m_size);
+ if (needTiledLayer != m_usingTiledLayer)
+ swapFromOrToTiledLayer(needTiledLayer);
+
FloatSize usedSize = m_usingTiledLayer ? constrainedSize() : m_size;
+ FloatRect boundsRect(m_boundsOrigin, usedSize);
+ // Update position.
// Position is offset on the layer by the layer anchor point.
- FloatPoint posPoint(m_position.x() + m_anchorPoint.x() * usedSize.width(),
- m_position.y() + m_anchorPoint.y() * usedSize.height());
-
+ FloatPoint posPoint(m_position.x() + m_anchorPoint.x() * usedSize.width(), m_position.y() + m_anchorPoint.y() * usedSize.height());
primaryLayer()->setPosition(posPoint);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
@@ -998,18 +996,16 @@
it->second->setPosition(clonePosition);
}
}
-}
-void GraphicsLayerCA::updateBounds()
-{
- FloatRect rect(m_boundsOrigin, m_size);
+ // Update bounds.
+ // Note that we don't resize m_contentsLayer. It's up the caller to do that.
if (m_structuralLayer) {
- m_structuralLayer->setBounds(rect);
+ m_structuralLayer->setBounds(boundsRect);
if (LayerMap* layerCloneMap = m_structuralLayerClones.get()) {
LayerMap::const_iterator end = layerCloneMap->end();
for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->second->setBounds(rect);
+ it->second->setBounds(boundsRect);
}
// The anchor of the contents layer is always at 0.5, 0.5, so the position is center-relative.
@@ -1023,34 +1019,14 @@
}
}
- bool needTiledLayer = requiresTiledLayer(m_size);
- if (needTiledLayer != m_usingTiledLayer)
- swapFromOrToTiledLayer(needTiledLayer);
-
- if (m_usingTiledLayer) {
- FloatSize sizeToUse = constrainedSize();
- rect = CGRectMake(0, 0, sizeToUse.width(), sizeToUse.height());
- }
-
- m_layer->setBounds(rect);
+ m_layer->setBounds(boundsRect);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
LayerMap::const_iterator end = layerCloneMap->end();
for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->second->setBounds(rect);
+ it->second->setBounds(boundsRect);
}
- // Contents transform may depend on height.
- updateContentsTransform();
-
- // Note that we don't resize m_contentsLayer. It's up the caller to do that.
-
- // if we've changed the bounds, we need to recalculate the position
- // of the layer, taking anchor point into account.
- updateLayerPosition();
-}
-
-void GraphicsLayerCA::updateAnchorPoint()
-{
+ // Update anchor point.
primaryLayer()->setAnchorPoint(m_anchorPoint);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
@@ -1061,7 +1037,8 @@
}
}
- updateLayerPosition();
+ // Contents transform may depend on height.
+ updateContentsTransform();
}
void GraphicsLayerCA::updateTransform()
@@ -1162,9 +1139,7 @@
m_structuralLayer = 0;
// Update the properties of m_layer now that we no longer have a structural layer.
- updateLayerPosition();
- updateBounds();
- updateAnchorPoint();
+ updateGeometry();
updateTransform();
updateChildrenTransform();
@@ -1200,9 +1175,7 @@
updateLayerNames();
// Update the properties of the structural layer.
- updateLayerPosition();
- updateBounds();
- updateAnchorPoint();
+ updateGeometry();
updateTransform();
updateChildrenTransform();
updateBackfaceVisibility();
@@ -2085,9 +2058,7 @@
updateContentsTransform();
- updateLayerPosition();
- updateBounds();
- updateAnchorPoint();
+ updateGeometry();
updateTransform();
updateChildrenTransform();
updateMasksToBounds();
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (89440 => 89441)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2011-06-22 16:45:47 UTC (rev 89440)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2011-06-22 16:46:33 UTC (rev 89441)
@@ -264,9 +264,7 @@
// All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
void updateLayerNames();
void updateSublayerList();
- void updateLayerPosition();
- void updateBounds();
- void updateAnchorPoint();
+ void updateGeometry();
void updateTransform();
void updateChildrenTransform();
void updateMasksToBounds();
@@ -308,29 +306,27 @@
NoChange = 0,
NameChanged = 1 << 1,
ChildrenChanged = 1 << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
- PositionChanged = 1 << 3,
- AnchorPointChanged = 1 << 4,
- BoundsChanged = 1 << 5,
- TransformChanged = 1 << 6,
- ChildrenTransformChanged = 1 << 7,
- Preserves3DChanged = 1 << 8,
- MasksToBoundsChanged = 1 << 9,
- DrawsContentChanged = 1 << 10, // need this?
- BackgroundColorChanged = 1 << 11,
- ContentsOpaqueChanged = 1 << 12,
- BackfaceVisibilityChanged = 1 << 13,
- OpacityChanged = 1 << 14,
- AnimationChanged = 1 << 15,
- DirtyRectsChanged = 1 << 16,
- ContentsImageChanged = 1 << 17,
- ContentsMediaLayerChanged = 1 << 18,
- ContentsCanvasLayerChanged = 1 << 19,
- ContentsRectChanged = 1 << 20,
- MaskLayerChanged = 1 << 21,
- ReplicatedLayerChanged = 1 << 22,
- ContentsNeedsDisplay = 1 << 23,
- AcceleratesDrawingChanged = 1 << 24,
- ContentsScaleChanged = 1 << 25
+ GeometryChanged = 1 << 3,
+ TransformChanged = 1 << 4,
+ ChildrenTransformChanged = 1 << 5,
+ Preserves3DChanged = 1 << 6,
+ MasksToBoundsChanged = 1 << 7,
+ DrawsContentChanged = 1 << 8, // need this?
+ BackgroundColorChanged = 1 << 9,
+ ContentsOpaqueChanged = 1 << 10,
+ BackfaceVisibilityChanged = 1 << 11,
+ OpacityChanged = 1 << 12,
+ AnimationChanged = 1 << 13,
+ DirtyRectsChanged = 1 << 14,
+ ContentsImageChanged = 1 << 15,
+ ContentsMediaLayerChanged = 1 << 16,
+ ContentsCanvasLayerChanged = 1 << 17,
+ ContentsRectChanged = 1 << 18,
+ MaskLayerChanged = 1 << 19,
+ ReplicatedLayerChanged = 1 << 20,
+ ContentsNeedsDisplay = 1 << 21,
+ AcceleratesDrawingChanged = 1 << 22,
+ ContentsScaleChanged = 1 << 23
};
typedef unsigned LayerChangeFlags;
void noteLayerPropertyChanged(LayerChangeFlags flags);