Commit 5ca5e557 authored by chrishtr@chromium.org's avatar chrishtr@chromium.org

Add methods to RenderLayer to get at the painting or scrolling graphics layers, if present.

This lets us remove code elsewhere that did the same thing, but potentially incorrectly and with unnecessary knowledge of squashing.

BUG=384520

Review URL: https://codereview.chromium.org/354223002

git-svn-id: svn://svn.chromium.org/blink/trunk@177158 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 45b4ee6f
......@@ -456,16 +456,7 @@ static void projectRectsToGraphicsLayerSpaceRecursive(
return;
// Find the appropriate GraphicsLayer for the composited RenderLayer.
GraphicsLayer* graphicsLayer;
if (compositedLayer->compositingState() == PaintsIntoGroupedBacking) {
graphicsLayer = compositedLayer->groupedMapping()->squashingLayer();
} else {
ASSERT(compositedLayer->hasCompositedLayerMapping());
CompositedLayerMappingPtr compositedLayerMapping = compositedLayer->compositedLayerMapping();
graphicsLayer = compositedLayerMapping->scrollingContentsLayer();
if (!graphicsLayer)
graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
}
GraphicsLayer* graphicsLayer = compositedLayer->graphicsLayerBackingForScrolling();
GraphicsLayerHitTestRects::iterator glIter = graphicsRects.find(graphicsLayer);
Vector<LayoutRect>* glRects;
......
......@@ -3300,6 +3300,30 @@ CompositedLayerMappingPtr RenderLayer::compositedLayerMapping() const
return m_compositedLayerMapping.get();
}
GraphicsLayer* RenderLayer::graphicsLayerBacking() const
{
switch (compositingState()) {
case NotComposited:
return 0;
case PaintsIntoGroupedBacking:
return groupedMapping()->squashingLayer();
default:
return compositedLayerMapping()->mainGraphicsLayer();
}
}
GraphicsLayer* RenderLayer::graphicsLayerBackingForScrolling() const
{
switch (compositingState()) {
case NotComposited:
return 0;
case PaintsIntoGroupedBacking:
return groupedMapping()->squashingLayer();
default:
return compositedLayerMapping()->scrollingContentsLayer() ? compositedLayerMapping()->scrollingContentsLayer() : compositedLayerMapping()->mainGraphicsLayer();
}
}
CompositedLayerMappingPtr RenderLayer::ensureCompositedLayerMapping()
{
if (!m_compositedLayerMapping) {
......
......@@ -312,15 +312,16 @@ public:
// compositing state may legally be read.
bool isAllowedToQueryCompositingState() const;
// NOTE: Don't call these compositing methods unless you know what you are doing and are sure it is the best approach!
CompositedLayerMappingPtr compositedLayerMapping() const;
CompositedLayerMappingPtr ensureCompositedLayerMapping();
GraphicsLayer* graphicsLayerBacking() const;
GraphicsLayer* graphicsLayerBackingForScrolling() const;
// NOTE: If you are using hasCompositedLayerMapping to determine the state of compositing for this layer,
// (and not just to do bookkeeping related to the mapping like, say, allocating or deallocating a mapping),
// then you may have incorrect logic. Use compositingState() instead.
bool hasCompositedLayerMapping() const { return m_compositedLayerMapping.get(); }
void clearCompositedLayerMapping(bool layerBeingDestroyed = false);
CompositedLayerMapping* groupedMapping() const { return m_groupedMapping; }
void setGroupedMapping(CompositedLayerMapping* groupedMapping, bool layerBeingDestroyed = false);
......
......@@ -122,18 +122,15 @@ RenderLayer* LinkHighlight::computeEnclosingCompositingLayer()
}
} while (!renderLayer);
CompositedLayerMappingPtr compositedLayerMapping = renderLayer->compositingState() == PaintsIntoGroupedBacking ? renderLayer->groupedMapping() : renderLayer->compositedLayerMapping();
GraphicsLayer* newGraphicsLayer = renderLayer->compositingState() == PaintsIntoGroupedBacking ? compositedLayerMapping->squashingLayer() : compositedLayerMapping->mainGraphicsLayer();
m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor));
ASSERT(renderLayer->compositingState() != NotComposited);
GraphicsLayer* newGraphicsLayer = renderLayer->graphicsLayerBacking();
if (!newGraphicsLayer->drawsContent()) {
if (renderLayer->scrollableArea() && renderLayer->scrollableArea()->usesCompositedScrolling()) {
ASSERT(renderLayer->hasCompositedLayerMapping() && renderLayer->compositedLayerMapping()->scrollingContentsLayer());
newGraphicsLayer = compositedLayerMapping->scrollingContentsLayer();
}
newGraphicsLayer = renderLayer->graphicsLayerBackingForScrolling();
}
m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor));
if (m_currentGraphicsLayer != newGraphicsLayer) {
if (m_currentGraphicsLayer)
clearGraphicsLayerLinkHighlightPointer();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment