Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Unified Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 59063003: Don't coerce pointers to compositor layer mappings to booleans. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaaaase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderLayerCompositor.cpp
diff --git a/Source/core/rendering/RenderLayerCompositor.cpp b/Source/core/rendering/RenderLayerCompositor.cpp
index 508131b24e551951947d7c3f9d0c3242e07e1e8c..b82a0b34d0fea528e36465398e2f495dfda44a3e 100644
--- a/Source/core/rendering/RenderLayerCompositor.cpp
+++ b/Source/core/rendering/RenderLayerCompositor.cpp
@@ -302,7 +302,7 @@ void RenderLayerCompositor::didChangeVisibleRect()
bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const
{
- return m_compositedLayerCount > (rootLayer->compositedLayerMapping() ? 1 : 0);
+ return m_compositedLayerCount > (rootLayer->compositingState() == PaintsIntoOwnBacking ? 1 : 0);
}
void RenderLayerCompositor::updateCompositingRequirementsState()
@@ -453,12 +453,9 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
// Host the document layer in the RenderView's root layer.
if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFrame()) {
RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->document());
- if (video) {
- CompositedLayerMapping* compositedLayerMapping = video->compositedLayerMapping();
- if (compositedLayerMapping) {
- childList.clear();
- childList.append(compositedLayerMapping->mainGraphicsLayer());
- }
+ if (video && video->compositingState() == PaintsIntoOwnBacking) {
+ childList.clear();
+ childList.append(video->compositedLayerMapping()->mainGraphicsLayer());
}
}
// Even when childList is empty, don't drop out of compositing mode if there are
@@ -521,7 +518,7 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
if (needsToBeComposited(layer)) {
enableCompositingMode();
- if (!layer->compositedLayerMapping()) {
+ if (layer->compositingState() == NotComposited) {
shawnsingh 2013/11/05 10:20:27 I strongly prefer these ones to use hasCompositedL
Ian Vollick 2013/11/08 03:35:12 Done.
// If we need to repaint, do so before allocating the compositedLayerMapping
if (shouldRepaint == CompositingChangeRepaintNow)
repaintOnCompositingChange(layer);
@@ -544,15 +541,15 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForIntrinsicReasons())
compositedLayerMappingChanged = true;
} else {
- if (layer->compositedLayerMapping()) {
+ if (layer->compositingState() != NotComposited) {
shawnsingh 2013/11/05 10:20:27 Ditto same as previous comment here.
Ian Vollick 2013/11/08 03:35:12 Done.
// If we're removing the compositedLayerMapping from a reflection, clear the source GraphicsLayer's pointer to
// its replica GraphicsLayer. In practice this should never happen because reflectee and reflection
// are both either composited, or not composited.
if (layer->isReflection()) {
RenderLayer* sourceLayer = toRenderLayerModelObject(layer->renderer()->parent())->layer();
- if (CompositedLayerMapping* compositedLayerMapping = sourceLayer->compositedLayerMapping()) {
+ if (sourceLayer->compositingState() != NotComposited) {
ASSERT(compositedLayerMapping->mainGraphicsLayer()->replicaLayer() == layer->compositedLayerMapping()->mainGraphicsLayer());
- compositedLayerMapping->mainGraphicsLayer()->setReplicatedByLayer(0);
+ sourceLayer->compositedLayerMapping()->mainGraphicsLayer()->setReplicatedByLayer(0);
}
}
@@ -604,7 +601,7 @@ bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Comp
// See if we need content or clipping layers. Methods called here should assume
// that the compositing state of descendant layers has not been updated yet.
- if (layer->compositedLayerMapping() && layer->compositedLayerMapping()->updateGraphicsLayerConfiguration())
+ if (layer->compositingState() == PaintsIntoOwnBacking && layer->compositedLayerMapping()->updateGraphicsLayerConfiguration())
layerChanged = true;
return layerChanged;
@@ -663,7 +660,7 @@ void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer*
void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child)
{
- if (!child->compositedLayerMapping() || parent->renderer()->documentBeingDestroyed())
+ if (child->compositingState() != PaintsIntoOwnBacking || parent->renderer()->documentBeingDestroyed())
shawnsingh 2013/11/05 10:20:27 or HasOwnBackingButPaintsIntoAncestor...
return;
removeViewportConstrainedLayer(child);
@@ -985,7 +982,7 @@ void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render
// It's possible to be called with a parent that isn't yet composited when we're doing
// partial updates as required by painting or hit testing. Just bail in that case;
// we'll do a full layer update soon.
- if (!parentLayer || !parentLayer->compositedLayerMapping())
+ if (!parentLayer || parentLayer->compositingState() != PaintsIntoOwnBacking)
shawnsingh 2013/11/05 10:20:27 and again....
return;
if (parentLayer) {
@@ -1032,15 +1029,15 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
pixelsAddedByPromotingAllTransitions = 0.0;
}
- CompositedLayerMapping* currentCompositedLayerMapping = layer->compositedLayerMapping();
- if (currentCompositedLayerMapping) {
+ CompositedLayerMappingPtr currentCompositedLayerMapping = layer->compositedLayerMapping();
+ if (layer->compositingState() == PaintsIntoOwnBacking) {
// The compositing state of all our children has been updated already, so now
// we can compute and cache the composited bounds for this layer.
currentCompositedLayerMapping->updateCompositedBounds();
if (layer->reflectionInfo()) {
RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
- if (reflectionLayer->compositedLayerMapping())
+ if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
@@ -1064,7 +1061,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
// If this layer has a compositedLayerMapping, then that is where we place subsequent children GraphicsLayers.
// Otherwise children continue to append to the child list of the enclosing layer.
Vector<GraphicsLayer*> layerChildren;
- Vector<GraphicsLayer*>& childList = currentCompositedLayerMapping ? layerChildren : childLayersOfEnclosingLayer;
+ Vector<GraphicsLayer*>& childList = layer->compositingState() != NotComposited ? layerChildren : childLayersOfEnclosingLayer;
#if !ASSERT_DISABLED
LayerListMutationDetector mutationChecker(layer->stackingNode());
@@ -1076,7 +1073,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1);
// If a negative z-order child is compositing, we get a foreground layer which needs to get parented.
- if (currentCompositedLayerMapping && currentCompositedLayerMapping->foregroundLayer())
+ if (layer->compositingState() != NotComposited && currentCompositedLayerMapping->foregroundLayer())
childList.append(currentCompositedLayerMapping->foregroundLayer());
}
@@ -1084,7 +1081,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
while (RenderLayerStackingNode* curNode = iterator.next())
rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1);
- if (currentCompositedLayerMapping) {
+ if (layer->compositingState() != NotComposited) {
bool parented = false;
if (layer->renderer()->isRenderPart())
parented = parentFrameContentLayers(toRenderPart(layer->renderer()));
@@ -1267,10 +1264,10 @@ bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer)
return false;
RenderLayer* layer = renderer->layer();
- if (!layer->compositedLayerMapping())
+ if (layer->compositingState() != PaintsIntoOwnBacking)
return false;
- CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping();
+ CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
GraphicsLayer* hostingLayer = compositedLayerMapping->parentForSublayers();
GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer();
if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != rootLayer) {
@@ -1283,14 +1280,15 @@ bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer)
// This just updates layer geometry without changing the hierarchy.
void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer)
{
- if (CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping()) {
+ if (layer->compositingState() == PaintsIntoOwnBacking) {
+ CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
// The compositing state of all our children has been updated already, so now
// we can compute and cache the composited bounds for this layer.
compositedLayerMapping->updateCompositedBounds();
if (layer->reflectionInfo()) {
RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
- if (reflectionLayer->compositedLayerMapping())
+ if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
@@ -1314,12 +1312,13 @@ void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer)
void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStackingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly)
{
if (layer->stackingNode() != compositingAncestor) {
- if (CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping()) {
+ if (layer->compositingState() == PaintsIntoOwnBacking) {
+ CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
compositedLayerMapping->updateCompositedBounds();
if (layer->reflectionInfo()) {
RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
- if (reflectionLayer->compositedLayerMapping())
+ if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
@@ -1420,7 +1419,7 @@ void RenderLayerCompositor::clearMappingForRenderLayerIncludingDescendants(Rende
if (!layer)
return;
- if (layer->compositedLayerMapping()) {
+ if (layer->compositingState() == PaintsIntoOwnBacking) {
removeViewportConstrainedLayer(layer);
layer->clearCompositedLayerMapping();
}
@@ -1532,7 +1531,7 @@ CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend
// but a sibling in the z-order hierarchy.
bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const
{
- if (!layer->compositedLayerMapping() || !layer->parent())
+ if (layer->compositingState() != PaintsIntoOwnBacking || !layer->parent())
return false;
const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
@@ -1637,7 +1636,7 @@ bool RenderLayerCompositor::requiresCompositingForPlugin(RenderObject* renderer)
RenderWidget* pluginRenderer = toRenderWidget(renderer);
// If we can't reliably know the size of the plugin yet, don't change compositing state.
if (pluginRenderer->needsLayout())
- return pluginRenderer->hasLayer() && pluginRenderer->layer()->compositedLayerMapping();
+ return pluginRenderer->hasLayer() && pluginRenderer->layer()->compositingState() != NotComposited;
// Don't go into compositing mode if height or width are zero, or size is 1x1.
IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect());
@@ -1663,7 +1662,7 @@ bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer)
// If we can't reliably know the size of the iframe yet, don't change compositing state.
if (renderer->needsLayout())
- return frameRenderer->hasLayer() && frameRenderer->layer()->compositedLayerMapping();
+ return frameRenderer->hasLayer() && frameRenderer->layer()->compositingState() != NotComposited;
// Don't go into compositing mode if height or width are zero.
IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect());
@@ -1833,7 +1832,7 @@ bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
// Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done.
if (!m_inPostLayoutUpdate) {
m_needsToRecomputeCompositingRequirements = true;
- return layer->compositedLayerMapping();
+ return layer->compositingState() != NotComposited;
}
bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescendant();
@@ -2319,7 +2318,7 @@ static bool isRootmostFixedOrStickyLayer(RenderLayer* layer)
return false;
for (RenderLayerStackingNode* stackingContainerNode = layer->stackingNode()->ancestorStackingContainerNode(); stackingContainerNode; stackingContainerNode = stackingContainerNode->ancestorStackingContainerNode()) {
- if (stackingContainerNode->layer()->compositedLayerMapping() && stackingContainerNode->layer()->renderer()->style()->position() == FixedPosition)
+ if (stackingContainerNode->layer()->compositingState() == PaintsIntoOwnBacking && stackingContainerNode->layer()->renderer()->style()->position() == FixedPosition)
return false;
}

Powered by Google App Engine
This is Rietveld 408576698