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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingLayerAssigner.cpp

Issue 1730653002: Move squash preventing reasons out of compositing reasons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug and test fixes. Created 4 years, 9 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // We can't compute at this time whether the squashing layer update is a no-op, 105 // We can't compute at this time whether the squashing layer update is a no-op,
106 // since that requires walking the paint layer tree. 106 // since that requires walking the paint layer tree.
107 update = PutInSquashingLayer; 107 update = PutInSquashingLayer;
108 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { 108 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) {
109 update = RemoveFromSquashingLayer; 109 update = RemoveFromSquashingLayer;
110 } 110 }
111 } 111 }
112 return update; 112 return update;
113 } 113 }
114 114
115 CompositingReasons CompositingLayerAssigner::getReasonsPreventingSquashing(const PaintLayer* layer, const CompositingLayerAssigner::SquashingState& squashingSta te) 115 SquashingDisallowedReasons CompositingLayerAssigner::getReasonsPreventingSquashi ng(const PaintLayer* layer, const CompositingLayerAssigner::SquashingState& squa shingState)
116 { 116 {
117 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) 117 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree)
118 return CompositingReasonSquashingWouldBreakPaintOrder; 118 return SquashingDisallowedReasonWouldBreakPaintOrder;
119 119
120 ASSERT(squashingState.hasMostRecentMapping); 120 ASSERT(squashingState.hasMostRecentMapping);
121 const PaintLayer& squashingLayer = squashingState.mostRecentMapping->owningL ayer(); 121 const PaintLayer& squashingLayer = squashingState.mostRecentMapping->owningL ayer();
122 122
123 // FIXME: this special case for video exists only to deal with corner cases 123 // FIXME: this special case for video exists only to deal with corner cases
124 // where a LayoutVideo does not report that it needs to be directly composit ed. 124 // where a LayoutVideo does not report that it needs to be directly composit ed.
125 // Video does not currently support sharing a backing, but this could be 125 // Video does not currently support sharing a backing, but this could be
126 // generalized in the future. The following layout tests fail if we permit t he 126 // generalized in the future. The following layout tests fail if we permit t he
127 // video to share a backing with other layers. 127 // video to share a backing with other layers.
128 // 128 //
129 // compositing/video/video-controls-layer-creation.html 129 // compositing/video/video-controls-layer-creation.html
130 if (layer->layoutObject()->isVideo() || squashingLayer.layoutObject()->isVid eo()) 130 if (layer->layoutObject()->isVideo() || squashingLayer.layoutObject()->isVid eo())
131 return CompositingReasonSquashingVideoIsDisallowed; 131 return SquashingDisallowedReasonSquashingVideoIsDisallowed;
132 132
133 // Don't squash iframes, frames or plugins. 133 // Don't squash iframes, frames or plugins.
134 // FIXME: this is only necessary because there is frame code that assumes th at composited frames are not squashed. 134 // FIXME: this is only necessary because there is frame code that assumes th at composited frames are not squashed.
135 if (layer->layoutObject()->isLayoutPart() || squashingLayer.layoutObject()-> isLayoutPart()) 135 if (layer->layoutObject()->isLayoutPart() || squashingLayer.layoutObject()-> isLayoutPart())
136 return CompositingReasonSquashingLayoutPartIsDisallowed; 136 return SquashingDisallowedReasonSquashingLayoutPartIsDisallowed;
137 137
138 if (layer->reflectionInfo()) 138 if (layer->reflectionInfo())
139 return CompositingReasonSquashingReflectionIsDisallowed; 139 return SquashingDisallowedReasonSquashingReflectionIsDisallowed;
140 140
141 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) 141 if (squashingWouldExceedSparsityTolerance(layer, squashingState))
142 return CompositingReasonSquashingSparsityExceeded; 142 return SquashingDisallowedReasonSquashingSparsityExceeded;
143 143
144 if (layer->layoutObject()->style()->hasBlendMode() || squashingLayer.layoutO bject()->style()->hasBlendMode()) 144 if (layer->layoutObject()->style()->hasBlendMode() || squashingLayer.layoutO bject()->style()->hasBlendMode())
145 return CompositingReasonSquashingBlendingIsDisallowed; 145 return SquashingDisallowedReasonSquashingBlendingIsDisallowed;
146 146
147 // FIXME: this is not efficient, since it walks up the tree. We should store these values on the CompositingInputsCache. 147 // FIXME: this is not efficient, since it walks up the tree. We should store these values on the CompositingInputsCache.
148 if (layer->clippingContainer() != squashingLayer.clippingContainer() && !squ ashingLayer.compositedLayerMapping()->containingSquashedLayer(layer->clippingCon tainer(), squashingState.nextSquashedLayerIndex)) 148 if (layer->clippingContainer() != squashingLayer.clippingContainer() && !squ ashingLayer.compositedLayerMapping()->containingSquashedLayer(layer->clippingCon tainer(), squashingState.nextSquashedLayerIndex))
149 return CompositingReasonSquashingClippingContainerMismatch; 149 return SquashingDisallowedReasonClippingContainerMismatch;
150 150
151 // Composited descendants need to be clipped by a child containment graphics layer, which would not be available if the layer is 151 // Composited descendants need to be clipped by a child containment graphics layer, which would not be available if the layer is
152 // squashed (and therefore has no CLM nor a child containment graphics layer ). 152 // squashed (and therefore has no CLM nor a child containment graphics layer ).
153 if (m_compositor->clipsCompositingDescendants(layer)) 153 if (m_compositor->clipsCompositingDescendants(layer))
154 return CompositingReasonSquashedLayerClipsCompositingDescendants; 154 return SquashingDisallowedReasonSquashedLayerClipsCompositingDescendants ;
155 155
156 if (layer->scrollsWithRespectTo(&squashingLayer)) 156 if (layer->scrollsWithRespectTo(&squashingLayer))
157 return CompositingReasonScrollsWithRespectToSquashingLayer; 157 return SquashingDisallowedReasonScrollsWithRespectToSquashingLayer;
158 158
159 if (layer->scrollParent() && layer->hasCompositingDescendant()) 159 if (layer->scrollParent() && layer->hasCompositingDescendant())
160 return CompositingReasonScrollChildWithCompositedDescendants; 160 return SquashingDisallowedReasonScrollChildWithCompositedDescendants;
161 161
162 if (layer->opacityAncestor() != squashingLayer.opacityAncestor()) 162 if (layer->opacityAncestor() != squashingLayer.opacityAncestor())
163 return CompositingReasonSquashingOpacityAncestorMismatch; 163 return SquashingDisallowedReasonOpacityAncestorMismatch;
164 164
165 if (layer->transformAncestor() != squashingLayer.transformAncestor()) 165 if (layer->transformAncestor() != squashingLayer.transformAncestor())
166 return CompositingReasonSquashingTransformAncestorMismatch; 166 return SquashingDisallowedReasonTransformAncestorMismatch;
167 167
168 if (layer->hasFilter() || layer->filterAncestor() != squashingLayer.filterAn cestor()) 168 if (layer->hasFilter() || layer->filterAncestor() != squashingLayer.filterAn cestor())
169 return CompositingReasonSquashingFilterMismatch; 169 return SquashingDisallowedReasonFilterMismatch;
170 170
171 if (layer->nearestFixedPositionLayer() != squashingLayer.nearestFixedPositio nLayer()) 171 if (layer->nearestFixedPositionLayer() != squashingLayer.nearestFixedPositio nLayer())
172 return CompositingReasonSquashingNearestFixedPositionMismatch; 172 return SquashingDisallowedReasonNearestFixedPositionMismatch;
173 ASSERT(layer->layoutObject()->style()->position() != FixedPosition); 173 ASSERT(layer->layoutObject()->style()->position() != FixedPosition);
174 174
175 if ((squashingLayer.layoutObject()->style()->subtreeWillChangeContents() && squashingLayer.layoutObject()->style()->isRunningAnimationOnCompositor()) 175 if ((squashingLayer.layoutObject()->style()->subtreeWillChangeContents() && squashingLayer.layoutObject()->style()->isRunningAnimationOnCompositor())
176 || squashingLayer.layoutObject()->style()->shouldCompositeForCurrentAnim ations()) 176 || squashingLayer.layoutObject()->style()->shouldCompositeForCurrentAnim ations())
177 return CompositingReasonSquashingLayerIsAnimating; 177 return SquashingDisallowedReasonSquashingLayerIsAnimating;
178 178
179 return CompositingReasonNone; 179 return SquashingDisallowedReasonsNone;
180 } 180 }
181 181
182 void CompositingLayerAssigner::updateSquashingAssignment(PaintLayer* layer, Squa shingState& squashingState, const CompositingStateTransitionType compositedLayer Update, 182 void CompositingLayerAssigner::updateSquashingAssignment(PaintLayer* layer, Squa shingState& squashingState, const CompositingStateTransitionType compositedLayer Update,
183 Vector<PaintLayer*>& layersNeedingPaintInvalidation) 183 Vector<PaintLayer*>& layersNeedingPaintInvalidation)
184 { 184 {
185 // NOTE: In the future as we generalize this, the background of this layer m ay need to be assigned to a different backing than 185 // NOTE: In the future as we generalize this, the background of this layer m ay need to be assigned to a different backing than
186 // the squashed PaintLayer's own primary contents. This would happen when we have a composited negative z-index element that needs 186 // the squashed PaintLayer's own primary contents. This would happen when we have a composited negative z-index element that needs
187 // to paint on top of the background, but below the layer's main contents. F or now, because we always composite layers 187 // to paint on top of the background, but below the layer's main contents. F or now, because we always composite layers
188 // when they have a composited negative z-index child, such layers will neve r need squashing so it is not yet an issue. 188 // when they have a composited negative z-index child, such layers will neve r need squashing so it is not yet an issue.
189 if (compositedLayerUpdate == PutInSquashingLayer) { 189 if (compositedLayerUpdate == PutInSquashingLayer) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) 242 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer)
243 { 243 {
244 Page* page = layer.layoutObject()->frame()->page(); 244 Page* page = layer.layoutObject()->frame()->page();
245 return (!page) ? nullptr : page->scrollingCoordinator(); 245 return (!page) ? nullptr : page->scrollingCoordinator();
246 } 246 }
247 247
248 void CompositingLayerAssigner::assignLayersToBackingsInternal(PaintLayer* layer, SquashingState& squashingState, Vector<PaintLayer*>& layersNeedingPaintInvalida tion) 248 void CompositingLayerAssigner::assignLayersToBackingsInternal(PaintLayer* layer, SquashingState& squashingState, Vector<PaintLayer*>& layersNeedingPaintInvalida tion)
249 { 249 {
250 if (requiresSquashing(layer->compositingReasons())) { 250 if (requiresSquashing(layer->compositingReasons())) {
251 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua shing(layer, squashingState); 251 SquashingDisallowedReasons reasonsPreventingSquashing = getReasonsPreven tingSquashing(layer, squashingState);
252 if (reasonsPreventingSquashing) 252 if (reasonsPreventingSquashing) {
253 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr eventingSquashing); 253 layer->setCompositingReasons(layer->compositingReasons() | Compositi ngReasonSquashingDisallowed);
254 layer->setSquashingDisallowedReasons(reasonsPreventingSquashing);
255 }
254 } 256 }
255 257
256 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer); 258 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer);
257 259
258 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) { 260 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) {
259 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent: :NewCompositedLayer); 261 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent: :NewCompositedLayer);
260 layersNeedingPaintInvalidation.append(layer); 262 layersNeedingPaintInvalidation.append(layer);
261 m_layersChanged = true; 263 m_layersChanged = true;
262 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro mLayer(*layer)) { 264 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro mLayer(*layer)) {
263 if (layer->layoutObject()->style()->hasViewportConstrainedPosition() ) 265 if (layer->layoutObject()->style()->hasViewportConstrainedPosition() )
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 302
301 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowCh ildren | PositiveZOrderChildren); 303 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowCh ildren | PositiveZOrderChildren);
302 while (PaintLayerStackingNode* curNode = iterator.next()) 304 while (PaintLayerStackingNode* curNode = iterator.next())
303 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN eedingPaintInvalidation); 305 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN eedingPaintInvalidation);
304 306
305 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer) 307 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer)
306 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; 308 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true;
307 } 309 }
308 310
309 } // namespace blink 311 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698