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

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

Issue 58543002: Use a boolean hasCompositedLayerMapping() accessor instead of the pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased 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
« no previous file with comments | « Source/core/rendering/RenderLayer.cpp ('k') | Source/core/rendering/RenderLayerModelObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderLayerCompositor.cpp
diff --git a/Source/core/rendering/RenderLayerCompositor.cpp b/Source/core/rendering/RenderLayerCompositor.cpp
index 508131b24e551951947d7c3f9d0c3242e07e1e8c..7499793f48486b14921767b34a0c920b7c54519d 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->hasCompositedLayerMapping() ? 1 : 0);
}
void RenderLayerCompositor::updateCompositingRequirementsState()
@@ -453,12 +453,11 @@ 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) {
+ if (video && video->hasCompositedLayerMapping()) {
CompositedLayerMapping* compositedLayerMapping = video->compositedLayerMapping();
- if (compositedLayerMapping) {
- childList.clear();
- childList.append(compositedLayerMapping->mainGraphicsLayer());
- }
+ ASSERT(compositedLayerMapping);
hartmanng 2013/11/04 22:56:09 Personally, I'd just take this out - seems inconsi
+ childList.clear();
+ childList.append(compositedLayerMapping->mainGraphicsLayer());
}
}
// Even when childList is empty, don't drop out of compositing mode if there are
@@ -521,7 +520,7 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
if (needsToBeComposited(layer)) {
enableCompositingMode();
- if (!layer->compositedLayerMapping()) {
+ if (!layer->hasCompositedLayerMapping()) {
// If we need to repaint, do so before allocating the compositedLayerMapping
if (shouldRepaint == CompositingChangeRepaintNow)
repaintOnCompositingChange(layer);
@@ -544,13 +543,14 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForIntrinsicReasons())
compositedLayerMappingChanged = true;
} else {
- if (layer->compositedLayerMapping()) {
+ if (layer->hasCompositedLayerMapping()) {
// 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->hasCompositedLayerMapping()) {
+ CompositedLayerMapping* compositedLayerMapping = sourceLayer->compositedLayerMapping();
ASSERT(compositedLayerMapping->mainGraphicsLayer()->replicaLayer() == layer->compositedLayerMapping()->mainGraphicsLayer());
compositedLayerMapping->mainGraphicsLayer()->setReplicatedByLayer(0);
}
@@ -604,7 +604,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->hasCompositedLayerMapping() && layer->compositedLayerMapping()->updateGraphicsLayerConfiguration())
layerChanged = true;
return layerChanged;
@@ -663,7 +663,7 @@ void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer*
void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child)
{
- if (!child->compositedLayerMapping() || parent->renderer()->documentBeingDestroyed())
+ if (!child->hasCompositedLayerMapping() || parent->renderer()->documentBeingDestroyed())
return;
removeViewportConstrainedLayer(child);
@@ -980,12 +980,12 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer)
{
ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer);
- ASSERT(childLayer->compositedLayerMapping());
+ ASSERT(childLayer->hasCompositedLayerMapping());
// 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->hasCompositedLayerMapping())
return;
if (parentLayer) {
@@ -1000,7 +1000,7 @@ void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render
void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer)
{
- ASSERT(layer->compositedLayerMapping());
+ ASSERT(layer->hasCompositedLayerMapping());
GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSublayers();
hostingLayer->removeAllChildren();
@@ -1032,15 +1032,15 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
pixelsAddedByPromotingAllTransitions = 0.0;
}
- CompositedLayerMapping* currentCompositedLayerMapping = layer->compositedLayerMapping();
- if (currentCompositedLayerMapping) {
+ if (layer->hasCompositedLayerMapping()) {
+ CompositedLayerMapping* currentCompositedLayerMapping = 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.
currentCompositedLayerMapping->updateCompositedBounds();
if (layer->reflectionInfo()) {
RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
- if (reflectionLayer->compositedLayerMapping())
+ if (reflectionLayer->hasCompositedLayerMapping())
reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
@@ -1064,7 +1064,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->hasCompositedLayerMapping() ? layerChildren : childLayersOfEnclosingLayer;
#if !ASSERT_DISABLED
LayerListMutationDetector mutationChecker(layer->stackingNode());
@@ -1076,15 +1076,16 @@ 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())
- childList.append(currentCompositedLayerMapping->foregroundLayer());
+ if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->foregroundLayer())
+ childList.append(layer->compositedLayerMapping()->foregroundLayer());
}
RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren);
while (RenderLayerStackingNode* curNode = iterator.next())
rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1);
- if (currentCompositedLayerMapping) {
+ if (layer->hasCompositedLayerMapping()) {
+ CompositedLayerMapping* currentCompositedLayerMapping = layer->compositedLayerMapping();
bool parented = false;
if (layer->renderer()->isRenderPart())
parented = parentFrameContentLayers(toRenderPart(layer->renderer()));
@@ -1267,7 +1268,7 @@ bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer)
return false;
RenderLayer* layer = renderer->layer();
- if (!layer->compositedLayerMapping())
+ if (!layer->hasCompositedLayerMapping())
return false;
CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping();
@@ -1283,14 +1284,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->hasCompositedLayerMapping()) {
+ CompositedLayerMapping* 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->hasCompositedLayerMapping())
reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
@@ -1313,20 +1315,19 @@ void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer)
// Recurs down the RenderLayer tree until its finds the compositing descendants of compositingAncestor and updates their geometry.
void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStackingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly)
{
- if (layer->stackingNode() != compositingAncestor) {
- if (CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping()) {
- compositedLayerMapping->updateCompositedBounds();
-
- if (layer->reflectionInfo()) {
- RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
- if (reflectionLayer->compositedLayerMapping())
- reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
- }
+ if (layer->stackingNode() != compositingAncestor && layer->hasCompositedLayerMapping()) {
+ CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping();
+ compositedLayerMapping->updateCompositedBounds();
- compositedLayerMapping->updateGraphicsLayerGeometry();
- if (compositedChildrenOnly)
- return;
+ if (layer->reflectionInfo()) {
+ RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer();
+ if (reflectionLayer->hasCompositedLayerMapping())
+ reflectionLayer->compositedLayerMapping()->updateCompositedBounds();
}
+
+ compositedLayerMapping->updateGraphicsLayerGeometry();
+ if (compositedChildrenOnly)
+ return;
}
if (layer->reflectionInfo())
@@ -1420,7 +1421,7 @@ void RenderLayerCompositor::clearMappingForRenderLayerIncludingDescendants(Rende
if (!layer)
return;
- if (layer->compositedLayerMapping()) {
+ if (layer->hasCompositedLayerMapping()) {
removeViewportConstrainedLayer(layer);
layer->clearCompositedLayerMapping();
}
@@ -1532,7 +1533,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->hasCompositedLayerMapping() || !layer->parent())
return false;
const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
@@ -1637,7 +1638,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()->hasCompositedLayerMapping();
// Don't go into compositing mode if height or width are zero, or size is 1x1.
IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect());
@@ -1663,7 +1664,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()->hasCompositedLayerMapping();
// Don't go into compositing mode if height or width are zero.
IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect());
@@ -1833,7 +1834,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->hasCompositedLayerMapping();
}
bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescendant();
@@ -2319,7 +2320,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()->hasCompositedLayerMapping() && stackingContainerNode->layer()->renderer()->style()->position() == FixedPosition)
return false;
}
@@ -2349,7 +2350,7 @@ void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer* layer)
FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportConstraints(RenderLayer* layer) const
{
- ASSERT(layer->compositedLayerMapping());
+ ASSERT(layer->hasCompositedLayerMapping());
FrameView* frameView = m_renderView->frameView();
LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect();
@@ -2387,7 +2388,7 @@ FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportCons
StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportConstraints(RenderLayer* layer) const
{
- ASSERT(layer->compositedLayerMapping());
+ ASSERT(layer->hasCompositedLayerMapping());
FrameView* frameView = m_renderView->frameView();
LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect();
« no previous file with comments | « Source/core/rendering/RenderLayer.cpp ('k') | Source/core/rendering/RenderLayerModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698