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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (needsOwnBacking(layer)) { | 101 if (needsOwnBacking(layer)) { |
102 if (!layer->hasCompositedLayerMapping()) { | 102 if (!layer->hasCompositedLayerMapping()) { |
103 update = AllocateOwnCompositedLayerMapping; | 103 update = AllocateOwnCompositedLayerMapping; |
104 } | 104 } |
105 } else { | 105 } else { |
106 if (layer->hasCompositedLayerMapping()) | 106 if (layer->hasCompositedLayerMapping()) |
107 update = RemoveOwnCompositedLayerMapping; | 107 update = RemoveOwnCompositedLayerMapping; |
108 | 108 |
109 if (!layer->subtreeIsInvisible() && m_compositor->canBeComposited(layer) && | 109 if (!layer->subtreeIsInvisible() && m_compositor->canBeComposited(layer) && |
110 requiresSquashing(layer->getCompositingReasons())) { | 110 requiresSquashing(layer->getCompositingReasons())) { |
111 // We can't compute at this time whether the squashing layer update is a n
o-op, | 111 // We can't compute at this time whether the squashing layer update is a |
112 // since that requires walking the paint layer tree. | 112 // no-op, since that requires walking the paint layer tree. |
113 update = PutInSquashingLayer; | 113 update = PutInSquashingLayer; |
114 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { | 114 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { |
115 update = RemoveFromSquashingLayer; | 115 update = RemoveFromSquashingLayer; |
116 } | 116 } |
117 } | 117 } |
118 return update; | 118 return update; |
119 } | 119 } |
120 | 120 |
121 SquashingDisallowedReasons | 121 SquashingDisallowedReasons |
122 CompositingLayerAssigner::getReasonsPreventingSquashing( | 122 CompositingLayerAssigner::getReasonsPreventingSquashing( |
123 const PaintLayer* layer, | 123 const PaintLayer* layer, |
124 const CompositingLayerAssigner::SquashingState& squashingState) { | 124 const CompositingLayerAssigner::SquashingState& squashingState) { |
125 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) | 125 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) |
126 return SquashingDisallowedReasonWouldBreakPaintOrder; | 126 return SquashingDisallowedReasonWouldBreakPaintOrder; |
127 | 127 |
128 ASSERT(squashingState.hasMostRecentMapping); | 128 ASSERT(squashingState.hasMostRecentMapping); |
129 const PaintLayer& squashingLayer = | 129 const PaintLayer& squashingLayer = |
130 squashingState.mostRecentMapping->owningLayer(); | 130 squashingState.mostRecentMapping->owningLayer(); |
131 | 131 |
132 // FIXME: this special case for video exists only to deal with corner cases | 132 // FIXME: this special case for video exists only to deal with corner cases |
133 // where a LayoutVideo does not report that it needs to be directly composited
. | 133 // where a LayoutVideo does not report that it needs to be directly |
134 // Video does not currently support sharing a backing, but this could be | 134 // composited. Video does not currently support sharing a backing, but this |
135 // generalized in the future. The following layout tests fail if we permit the | 135 // could be generalized in the future. The following layout tests fail if we |
136 // video to share a backing with other layers. | 136 // permit the video to share a backing with other layers. |
137 // | 137 // |
138 // compositing/video/video-controls-layer-creation.html | 138 // compositing/video/video-controls-layer-creation.html |
139 if (layer->layoutObject()->isVideo() || | 139 if (layer->layoutObject()->isVideo() || |
140 squashingLayer.layoutObject()->isVideo()) | 140 squashingLayer.layoutObject()->isVideo()) |
141 return SquashingDisallowedReasonSquashingVideoIsDisallowed; | 141 return SquashingDisallowedReasonSquashingVideoIsDisallowed; |
142 | 142 |
143 // Don't squash iframes, frames or plugins. | 143 // Don't squash iframes, frames or plugins. |
144 // FIXME: this is only necessary because there is frame code that assumes that
composited frames are not squashed. | 144 // FIXME: this is only necessary because there is frame code that assumes that |
| 145 // composited frames are not squashed. |
145 if (layer->layoutObject()->isLayoutPart() || | 146 if (layer->layoutObject()->isLayoutPart() || |
146 squashingLayer.layoutObject()->isLayoutPart()) | 147 squashingLayer.layoutObject()->isLayoutPart()) |
147 return SquashingDisallowedReasonSquashingLayoutPartIsDisallowed; | 148 return SquashingDisallowedReasonSquashingLayoutPartIsDisallowed; |
148 | 149 |
149 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) | 150 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) |
150 return SquashingDisallowedReasonSquashingSparsityExceeded; | 151 return SquashingDisallowedReasonSquashingSparsityExceeded; |
151 | 152 |
152 if (layer->layoutObject()->style()->hasBlendMode() || | 153 if (layer->layoutObject()->style()->hasBlendMode() || |
153 squashingLayer.layoutObject()->style()->hasBlendMode()) | 154 squashingLayer.layoutObject()->style()->hasBlendMode()) |
154 return SquashingDisallowedReasonSquashingBlendingIsDisallowed; | 155 return SquashingDisallowedReasonSquashingBlendingIsDisallowed; |
155 | 156 |
156 // FIXME: this is not efficient, since it walks up the tree. We should store t
hese values on the CompositingInputsCache. | 157 // FIXME: this is not efficient, since it walks up the tree. We should store |
| 158 // these values on the CompositingInputsCache. |
157 if (layer->clippingContainer() != squashingLayer.clippingContainer() && | 159 if (layer->clippingContainer() != squashingLayer.clippingContainer() && |
158 !squashingLayer.compositedLayerMapping()->containingSquashedLayer( | 160 !squashingLayer.compositedLayerMapping()->containingSquashedLayer( |
159 layer->clippingContainer(), squashingState.nextSquashedLayerIndex)) | 161 layer->clippingContainer(), squashingState.nextSquashedLayerIndex)) |
160 return SquashingDisallowedReasonClippingContainerMismatch; | 162 return SquashingDisallowedReasonClippingContainerMismatch; |
161 | 163 |
162 // Composited descendants need to be clipped by a child containment graphics l
ayer, which would not be available if the layer is | 164 // Composited descendants need to be clipped by a child containment graphics |
163 // squashed (and therefore has no CLM nor a child containment graphics layer). | 165 // layer, which would not be available if the layer is squashed (and therefore |
| 166 // has no CLM nor a child containment graphics layer). |
164 if (m_compositor->clipsCompositingDescendants(layer)) | 167 if (m_compositor->clipsCompositingDescendants(layer)) |
165 return SquashingDisallowedReasonSquashedLayerClipsCompositingDescendants; | 168 return SquashingDisallowedReasonSquashedLayerClipsCompositingDescendants; |
166 | 169 |
167 if (layer->scrollsWithRespectTo(&squashingLayer)) | 170 if (layer->scrollsWithRespectTo(&squashingLayer)) |
168 return SquashingDisallowedReasonScrollsWithRespectToSquashingLayer; | 171 return SquashingDisallowedReasonScrollsWithRespectToSquashingLayer; |
169 | 172 |
170 if (layer->scrollParent() && layer->hasCompositingDescendant()) | 173 if (layer->scrollParent() && layer->hasCompositingDescendant()) |
171 return SquashingDisallowedReasonScrollChildWithCompositedDescendants; | 174 return SquashingDisallowedReasonScrollChildWithCompositedDescendants; |
172 | 175 |
173 if (layer->opacityAncestor() != squashingLayer.opacityAncestor()) | 176 if (layer->opacityAncestor() != squashingLayer.opacityAncestor()) |
(...skipping 30 matching lines...) Expand all Loading... |
204 return SquashingDisallowedReasonFragmentedContent; | 207 return SquashingDisallowedReasonFragmentedContent; |
205 | 208 |
206 return SquashingDisallowedReasonsNone; | 209 return SquashingDisallowedReasonsNone; |
207 } | 210 } |
208 | 211 |
209 void CompositingLayerAssigner::updateSquashingAssignment( | 212 void CompositingLayerAssigner::updateSquashingAssignment( |
210 PaintLayer* layer, | 213 PaintLayer* layer, |
211 SquashingState& squashingState, | 214 SquashingState& squashingState, |
212 const CompositingStateTransitionType compositedLayerUpdate, | 215 const CompositingStateTransitionType compositedLayerUpdate, |
213 Vector<PaintLayer*>& layersNeedingPaintInvalidation) { | 216 Vector<PaintLayer*>& layersNeedingPaintInvalidation) { |
214 // NOTE: In the future as we generalize this, the background of this layer may
need to be assigned to a different backing than | 217 // NOTE: In the future as we generalize this, the background of this layer may |
215 // the squashed PaintLayer's own primary contents. This would happen when we h
ave a composited negative z-index element that needs | 218 // need to be assigned to a different backing than the squashed PaintLayer's |
216 // to paint on top of the background, but below the layer's main contents. For
now, because we always composite layers | 219 // own primary contents. This would happen when we have a composited negative |
217 // when they have a composited negative z-index child, such layers will never
need squashing so it is not yet an issue. | 220 // z-index element that needs to paint on top of the background, but below the |
| 221 // layer's main contents. For now, because we always composite layers when |
| 222 // they have a composited negative z-index child, such layers will never need |
| 223 // squashing so it is not yet an issue. |
218 if (compositedLayerUpdate == PutInSquashingLayer) { | 224 if (compositedLayerUpdate == PutInSquashingLayer) { |
219 // A layer that is squashed with other layers cannot have its own Composited
LayerMapping. | 225 // A layer that is squashed with other layers cannot have its own |
| 226 // CompositedLayerMapping. |
220 ASSERT(!layer->hasCompositedLayerMapping()); | 227 ASSERT(!layer->hasCompositedLayerMapping()); |
221 ASSERT(squashingState.hasMostRecentMapping); | 228 ASSERT(squashingState.hasMostRecentMapping); |
222 | 229 |
223 bool changedSquashingLayer = | 230 bool changedSquashingLayer = |
224 squashingState.mostRecentMapping->updateSquashingLayerAssignment( | 231 squashingState.mostRecentMapping->updateSquashingLayerAssignment( |
225 layer, squashingState.nextSquashedLayerIndex); | 232 layer, squashingState.nextSquashedLayerIndex); |
226 if (!changedSquashingLayer) | 233 if (!changedSquashingLayer) |
227 return; | 234 return; |
228 | 235 |
229 // If we've modified the collection of squashed layers, we must update | 236 // If we've modified the collection of squashed layers, we must update |
230 // the graphics layer geometry. | 237 // the graphics layer geometry. |
231 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate( | 238 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate( |
232 GraphicsLayerUpdateSubtree); | 239 GraphicsLayerUpdateSubtree); |
233 | 240 |
234 layer->clipper().clearClipRectsIncludingDescendants(); | 241 layer->clipper().clearClipRectsIncludingDescendants(); |
235 | 242 |
236 // Issue a paint invalidation, since |layer| may have been added to an alrea
dy-existing squashing layer. | 243 // Issue a paint invalidation, since |layer| may have been added to an |
| 244 // already-existing squashing layer. |
237 TRACE_LAYER_INVALIDATION( | 245 TRACE_LAYER_INVALIDATION( |
238 layer, InspectorLayerInvalidationTrackingEvent::AddedToSquashingLayer); | 246 layer, InspectorLayerInvalidationTrackingEvent::AddedToSquashingLayer); |
239 layersNeedingPaintInvalidation.append(layer); | 247 layersNeedingPaintInvalidation.append(layer); |
240 m_layersChanged = true; | 248 m_layersChanged = true; |
241 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { | 249 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { |
242 if (layer->groupedMapping()) { | 250 if (layer->groupedMapping()) { |
243 // Before removing |layer| from an already-existing squashing layer that m
ay have other content, issue a paint invalidation. | 251 // Before removing |layer| from an already-existing squashing layer that |
| 252 // may have other content, issue a paint invalidation. |
244 m_compositor->paintInvalidationOnCompositingChange(layer); | 253 m_compositor->paintInvalidationOnCompositingChange(layer); |
245 layer->groupedMapping()->setNeedsGraphicsLayerUpdate( | 254 layer->groupedMapping()->setNeedsGraphicsLayerUpdate( |
246 GraphicsLayerUpdateSubtree); | 255 GraphicsLayerUpdateSubtree); |
247 layer->setGroupedMapping(nullptr, | 256 layer->setGroupedMapping(nullptr, |
248 PaintLayer::InvalidateLayerAndRemoveFromMapping); | 257 PaintLayer::InvalidateLayerAndRemoveFromMapping); |
249 } | 258 } |
250 | 259 |
251 // If we need to issue paint invalidations, do so now that we've removed it
from a squashed layer. | 260 // If we need to issue paint invalidations, do so now that we've removed it |
| 261 // from a squashed layer. |
252 TRACE_LAYER_INVALIDATION( | 262 TRACE_LAYER_INVALIDATION( |
253 layer, | 263 layer, |
254 InspectorLayerInvalidationTrackingEvent::RemovedFromSquashingLayer); | 264 InspectorLayerInvalidationTrackingEvent::RemovedFromSquashingLayer); |
255 layersNeedingPaintInvalidation.append(layer); | 265 layersNeedingPaintInvalidation.append(layer); |
256 m_layersChanged = true; | 266 m_layersChanged = true; |
257 | 267 |
258 layer->setLostGroupedMapping(false); | 268 layer->setLostGroupedMapping(false); |
259 } | 269 } |
260 } | 270 } |
261 | 271 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 321 } |
312 | 322 |
313 if (layer->stackingNode()->isStackingContext()) { | 323 if (layer->stackingNode()->isStackingContext()) { |
314 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(), | 324 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(), |
315 NegativeZOrderChildren); | 325 NegativeZOrderChildren); |
316 while (PaintLayerStackingNode* curNode = iterator.next()) | 326 while (PaintLayerStackingNode* curNode = iterator.next()) |
317 assignLayersToBackingsInternal(curNode->layer(), squashingState, | 327 assignLayersToBackingsInternal(curNode->layer(), squashingState, |
318 layersNeedingPaintInvalidation); | 328 layersNeedingPaintInvalidation); |
319 } | 329 } |
320 | 330 |
321 // At this point, if the layer is to be separately composited, then its backin
g becomes the most recent in paint-order. | 331 // At this point, if the layer is to be separately composited, then its |
| 332 // backing becomes the most recent in paint-order. |
322 if (layer->compositingState() == PaintsIntoOwnBacking) { | 333 if (layer->compositingState() == PaintsIntoOwnBacking) { |
323 ASSERT(!requiresSquashing(layer->getCompositingReasons())); | 334 ASSERT(!requiresSquashing(layer->getCompositingReasons())); |
324 squashingState.updateSquashingStateForNewMapping( | 335 squashingState.updateSquashingStateForNewMapping( |
325 layer->compositedLayerMapping(), layer->hasCompositedLayerMapping(), | 336 layer->compositedLayerMapping(), layer->hasCompositedLayerMapping(), |
326 layersNeedingPaintInvalidation); | 337 layersNeedingPaintInvalidation); |
327 } | 338 } |
328 | 339 |
329 if (layer->scrollParent()) | 340 if (layer->scrollParent()) |
330 layer->scrollParent()->getScrollableArea()->setTopmostScrollChild(layer); | 341 layer->scrollParent()->getScrollableArea()->setTopmostScrollChild(layer); |
331 | 342 |
332 if (layer->needsCompositedScrolling()) | 343 if (layer->needsCompositedScrolling()) |
333 layer->getScrollableArea()->setTopmostScrollChild(nullptr); | 344 layer->getScrollableArea()->setTopmostScrollChild(nullptr); |
334 | 345 |
335 PaintLayerStackingNodeIterator iterator( | 346 PaintLayerStackingNodeIterator iterator( |
336 *layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren); | 347 *layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren); |
337 while (PaintLayerStackingNode* curNode = iterator.next()) | 348 while (PaintLayerStackingNode* curNode = iterator.next()) |
338 assignLayersToBackingsInternal(curNode->layer(), squashingState, | 349 assignLayersToBackingsInternal(curNode->layer(), squashingState, |
339 layersNeedingPaintInvalidation); | 350 layersNeedingPaintInvalidation); |
340 | 351 |
341 if (squashingState.hasMostRecentMapping && | 352 if (squashingState.hasMostRecentMapping && |
342 &squashingState.mostRecentMapping->owningLayer() == layer) | 353 &squashingState.mostRecentMapping->owningLayer() == layer) |
343 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 354 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
344 } | 355 } |
345 | 356 |
346 } // namespace blink | 357 } // namespace blink |
OLD | NEW |