OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye
r*>& layersNeedingPaintInvalidation) | 51 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye
r*>& layersNeedingPaintInvalidation) |
52 { | 52 { |
53 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); | 53 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); |
54 | 54 |
55 SquashingState squashingState; | 55 SquashingState squashingState; |
56 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingPain
tInvalidation); | 56 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingPain
tInvalidation); |
57 if (squashingState.hasMostRecentMapping) | 57 if (squashingState.hasMostRecentMapping) |
58 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); | 58 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); |
59 } | 59 } |
60 | 60 |
61 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping, bool hasNewCompositedLayerMa
pping) | 61 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping) |
62 { | 62 { |
63 // The most recent backing is done accumulating any more squashing layers. | 63 // The most recent backing is done accumulating any more squashing layers. |
64 if (hasMostRecentMapping) | 64 if (hasMostRecentMapping) |
65 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); | 65 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); |
66 | 66 |
67 nextSquashedLayerIndex = 0; | 67 nextSquashedLayerIndex = 0; |
68 boundingRect = IntRect(); | 68 boundingRect = IntRect(); |
69 mostRecentMapping = newCompositedLayerMapping; | 69 mostRecentMapping = newCompositedLayerMapping; |
70 hasMostRecentMapping = hasNewCompositedLayerMapping; | 70 hasMostRecentMapping = newCompositedLayerMapping; |
71 haveAssignedBackingsToEntireSquashingLayerSubtree = false; | 71 haveAssignedBackingsToEntireSquashingLayerSubtree = false; |
72 } | 72 } |
73 | 73 |
74 bool CompositingLayerAssigner::squashingWouldExceedSparsityTolerance(const Rende
rLayer* candidate, const CompositingLayerAssigner::SquashingState& squashingStat
e) | 74 bool CompositingLayerAssigner::squashingWouldExceedSparsityTolerance(const Rende
rLayer* candidate, const CompositingLayerAssigner::SquashingState& squashingStat
e) |
75 { | 75 { |
76 IntRect bounds = candidate->clippedAbsoluteBoundingBox(); | 76 IntRect bounds = candidate->clippedAbsoluteBoundingBox(); |
77 IntRect newBoundingRect = squashingState.boundingRect; | 77 IntRect newBoundingRect = squashingState.boundingRect; |
78 newBoundingRect.unite(bounds); | 78 newBoundingRect.unite(bounds); |
79 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); | 79 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); |
80 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b
ounds.size().area(); | 80 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b
ounds.size().area(); |
81 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; | 81 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; |
82 } | 82 } |
83 | 83 |
84 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const | 84 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const |
85 { | 85 { |
86 if (!m_compositor->canBeComposited(layer)) | 86 if (!m_compositor->canBeComposited(layer)) |
87 return false; | 87 return false; |
88 | 88 |
89 // If squashing is disabled, then layers that would have been squashed shoul
d just be separately composited. | 89 // If squashing is disabled, then layers that would have been squashed shoul
d just be separately composited. |
90 bool needsOwnBackingForDisabledSquashing = !m_layerSquashingEnabled && requi
resSquashing(layer->compositingReasons()); | 90 bool needsOwnBackingForDisabledSquashing = !m_layerSquashingEnabled && requi
resSquashing(layer->compositingReasons()); |
91 | 91 |
92 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo
rDisabledSquashing || (m_compositor->staleInCompositingMode() && layer->isRootLa
yer()); | 92 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo
rDisabledSquashing || (m_compositor->staleInCompositingMode() && layer->isRootLa
yer()); |
93 } | 93 } |
94 | 94 |
95 CompositingStateTransitionType CompositingLayerAssigner::computeCompositedLayerU
pdate(RenderLayer* layer) | 95 CompositingStateTransitionType CompositingLayerAssigner::computeCompositedLayerU
pdate(RenderLayer* layer) |
96 { | 96 { |
97 CompositingStateTransitionType update = NoCompositingStateChange; | 97 CompositingStateTransitionType update = NoCompositingStateChange; |
| 98 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi
ng(); |
98 if (needsOwnBacking(layer)) { | 99 if (needsOwnBacking(layer)) { |
99 if (!layer->hasCompositedLayerMapping()) { | 100 if (!compositedLayerMapping) { |
100 update = AllocateOwnCompositedLayerMapping; | 101 update = AllocateOwnCompositedLayerMapping; |
101 } | 102 } |
102 } else { | 103 } else { |
103 if (layer->hasCompositedLayerMapping()) | 104 if (compositedLayerMapping) |
104 update = RemoveOwnCompositedLayerMapping; | 105 update = RemoveOwnCompositedLayerMapping; |
105 | 106 |
106 if (m_layerSquashingEnabled) { | 107 if (m_layerSquashingEnabled) { |
107 if (!layer->subtreeIsInvisible() && requiresSquashing(layer->composi
tingReasons())) { | 108 if (!layer->subtreeIsInvisible() && requiresSquashing(layer->composi
tingReasons())) { |
108 // We can't compute at this time whether the squashing layer upd
ate is a no-op, | 109 // We can't compute at this time whether the squashing layer upd
ate is a no-op, |
109 // since that requires walking the render layer tree. | 110 // since that requires walking the render layer tree. |
110 update = PutInSquashingLayer; | 111 update = PutInSquashingLayer; |
111 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { | 112 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { |
112 update = RemoveFromSquashingLayer; | 113 update = RemoveFromSquashingLayer; |
113 } | 114 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 178 |
178 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, | 179 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, |
179 Vector<RenderLayer*>& layersNeedingPaintInvalidation) | 180 Vector<RenderLayer*>& layersNeedingPaintInvalidation) |
180 { | 181 { |
181 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than | 182 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than |
182 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs | 183 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs |
183 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers | 184 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers |
184 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. | 185 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. |
185 if (compositedLayerUpdate == PutInSquashingLayer) { | 186 if (compositedLayerUpdate == PutInSquashingLayer) { |
186 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. | 187 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. |
187 ASSERT(!layer->hasCompositedLayerMapping()); | 188 ASSERT(!layer->compositedLayerMapping()); |
188 ASSERT(squashingState.hasMostRecentMapping); | 189 ASSERT(squashingState.hasMostRecentMapping); |
189 | 190 |
190 bool changedSquashingLayer = | 191 bool changedSquashingLayer = |
191 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); | 192 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); |
192 if (!changedSquashingLayer) | 193 if (!changedSquashingLayer) |
193 return; | 194 return; |
194 | 195 |
195 // If we've modified the collection of squashed layers, we must update | 196 // If we've modified the collection of squashed layers, we must update |
196 // the graphics layer geometry. | 197 // the graphics layer geometry. |
197 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); | 198 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); |
(...skipping 26 matching lines...) Expand all Loading... |
224 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); | 225 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); |
225 if (compositedLayerUpdate != NoCompositingStateChange) { | 226 if (compositedLayerUpdate != NoCompositingStateChange) { |
226 TRACE_LAYER_INVALIDATION(reflectionLayer, InspectorLayerInvalidationTrac
kingEvent::ReflectionLayerChanged); | 227 TRACE_LAYER_INVALIDATION(reflectionLayer, InspectorLayerInvalidationTrac
kingEvent::ReflectionLayerChanged); |
227 layersNeedingPaintInvalidation.append(reflectionLayer); | 228 layersNeedingPaintInvalidation.append(reflectionLayer); |
228 m_layersChanged = true; | 229 m_layersChanged = true; |
229 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); | 230 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); |
230 } | 231 } |
231 m_compositor->updateDirectCompositingReasons(reflectionLayer); | 232 m_compositor->updateDirectCompositingReasons(reflectionLayer); |
232 | 233 |
233 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? | 234 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? |
234 if (reflectionLayer->hasCompositedLayerMapping()) | 235 if (CompositedLayerMapping* compositedLayerMapping = reflectionLayer->compos
itedLayerMapping()) |
235 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); | 236 compositedLayerMapping->updateGraphicsLayerConfiguration(); |
236 } | 237 } |
237 | 238 |
238 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) | 239 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) |
239 { | 240 { |
240 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { | 241 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { |
241 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); | 242 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); |
242 if (reasonsPreventingSquashing) | 243 if (reasonsPreventingSquashing) |
243 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); | 244 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); |
244 } | 245 } |
245 | 246 |
(...skipping 25 matching lines...) Expand all Loading... |
271 if (layer->stackingNode()->isStackingContext()) { | 272 if (layer->stackingNode()->isStackingContext()) { |
272 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); | 273 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); |
273 while (RenderLayerStackingNode* curNode = iterator.next()) | 274 while (RenderLayerStackingNode* curNode = iterator.next()) |
274 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay
ersNeedingPaintInvalidation); | 275 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay
ersNeedingPaintInvalidation); |
275 } | 276 } |
276 | 277 |
277 if (m_layerSquashingEnabled) { | 278 if (m_layerSquashingEnabled) { |
278 // At this point, if the layer is to be separately composited, then its
backing becomes the most recent in paint-order. | 279 // At this point, if the layer is to be separately composited, then its
backing becomes the most recent in paint-order. |
279 if (layer->compositingState() == PaintsIntoOwnBacking) { | 280 if (layer->compositingState() == PaintsIntoOwnBacking) { |
280 ASSERT(!requiresSquashing(layer->compositingReasons())); | 281 ASSERT(!requiresSquashing(layer->compositingReasons())); |
281 squashingState.updateSquashingStateForNewMapping(layer->compositedLa
yerMapping(), layer->hasCompositedLayerMapping()); | 282 squashingState.updateSquashingStateForNewMapping(layer->compositedLa
yerMapping()); |
282 } | 283 } |
283 } | 284 } |
284 | 285 |
285 if (layer->scrollParent()) | 286 if (layer->scrollParent()) |
286 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer); | 287 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer); |
287 | 288 |
288 if (layer->needsCompositedScrolling()) | 289 if (layer->needsCompositedScrolling()) |
289 layer->scrollableArea()->setTopmostScrollChild(0); | 290 layer->scrollableArea()->setTopmostScrollChild(0); |
290 | 291 |
291 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 292 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
292 while (RenderLayerStackingNode* curNode = iterator.next()) | 293 while (RenderLayerStackingNode* curNode = iterator.next()) |
293 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); | 294 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); |
294 | 295 |
295 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) | 296 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) |
296 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 297 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
297 } | 298 } |
298 | 299 |
299 } | 300 } |
OLD | NEW |