| 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 29 matching lines...) Expand all Loading... |
| 40 : m_compositor(compositor) | 40 : m_compositor(compositor) |
| 41 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) | 41 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) |
| 42 , m_layersChanged(false) | 42 , m_layersChanged(false) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 CompositingLayerAssigner::~CompositingLayerAssigner() | 46 CompositingLayerAssigner::~CompositingLayerAssigner() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye
r*>& layersNeedingRepaint) | 50 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye
r*>& layersNeedingPaintInvalidation) |
| 51 { | 51 { |
| 52 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); | 52 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); |
| 53 | 53 |
| 54 SquashingState squashingState; | 54 SquashingState squashingState; |
| 55 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingRepa
int); | 55 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingPain
tInvalidation); |
| 56 if (squashingState.hasMostRecentMapping) | 56 if (squashingState.hasMostRecentMapping) |
| 57 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); | 57 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping, bool hasNewCompositedLayerMa
pping) | 60 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping, bool hasNewCompositedLayerMa
pping) |
| 61 { | 61 { |
| 62 // The most recent backing is done accumulating any more squashing layers. | 62 // The most recent backing is done accumulating any more squashing layers. |
| 63 if (hasMostRecentMapping) | 63 if (hasMostRecentMapping) |
| 64 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); | 64 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); |
| 65 | 65 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (compositingInputs.transformAncestor != squashingLayerCompositingInputs.t
ransformAncestor) | 166 if (compositingInputs.transformAncestor != squashingLayerCompositingInputs.t
ransformAncestor) |
| 167 return CompositingReasonSquashingTransformAncestorMismatch; | 167 return CompositingReasonSquashingTransformAncestorMismatch; |
| 168 | 168 |
| 169 if (compositingInputs.filterAncestor != squashingLayerCompositingInputs.filt
erAncestor) | 169 if (compositingInputs.filterAncestor != squashingLayerCompositingInputs.filt
erAncestor) |
| 170 return CompositingReasonSquashingFilterAncestorMismatch; | 170 return CompositingReasonSquashingFilterAncestorMismatch; |
| 171 | 171 |
| 172 return CompositingReasonNone; | 172 return CompositingReasonNone; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, | 175 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, |
| 176 Vector<RenderLayer*>& layersNeedingRepaint) | 176 Vector<RenderLayer*>& layersNeedingPaintInvalidation) |
| 177 { | 177 { |
| 178 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than | 178 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than |
| 179 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs | 179 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs |
| 180 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers | 180 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers |
| 181 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. | 181 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. |
| 182 if (compositedLayerUpdate == PutInSquashingLayer) { | 182 if (compositedLayerUpdate == PutInSquashingLayer) { |
| 183 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. | 183 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. |
| 184 ASSERT(!layer->hasCompositedLayerMapping()); | 184 ASSERT(!layer->hasCompositedLayerMapping()); |
| 185 ASSERT(squashingState.hasMostRecentMapping); | 185 ASSERT(squashingState.hasMostRecentMapping); |
| 186 | 186 |
| 187 bool changedSquashingLayer = | 187 bool changedSquashingLayer = |
| 188 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); | 188 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); |
| 189 if (!changedSquashingLayer) | 189 if (!changedSquashingLayer) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 // If we've modified the collection of squashed layers, we must update | 192 // If we've modified the collection of squashed layers, we must update |
| 193 // the graphics layer geometry. | 193 // the graphics layer geometry. |
| 194 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); | 194 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); |
| 195 | 195 |
| 196 layer->clipper().clearClipRectsIncludingDescendants(); | 196 layer->clipper().clearClipRectsIncludingDescendants(); |
| 197 | 197 |
| 198 // Issue a repaint, since |layer| may have been added to an already-exis
ting squashing layer. | 198 // Issue a paint invalidation, since |layer| may have been added to an a
lready-existing squashing layer. |
| 199 layersNeedingRepaint.append(layer); | 199 layersNeedingPaintInvalidation.append(layer); |
| 200 m_layersChanged = true; | 200 m_layersChanged = true; |
| 201 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { | 201 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { |
| 202 if (layer->groupedMapping()) { | 202 if (layer->groupedMapping()) { |
| 203 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a repaint. | 203 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a paint invalidation. |
| 204 m_compositor->repaintOnCompositingChange(layer); | 204 m_compositor->paintInvalidationOnCompositingChange(layer); |
| 205 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); | 205 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); |
| 206 layer->setGroupedMapping(0); | 206 layer->setGroupedMapping(0); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // If we need to repaint, do so now that we've removed it from a squashe
d layer. | 209 // If we need to issue paint invalidations, do so now that we've removed
it from a squashed layer. |
| 210 layersNeedingRepaint.append(layer); | 210 layersNeedingPaintInvalidation.append(layer); |
| 211 m_layersChanged = true; | 211 m_layersChanged = true; |
| 212 | 212 |
| 213 layer->setLostGroupedMapping(false); | 213 layer->setLostGroupedMapping(false); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, Vector<RenderLayer*>& layersNeedingRepaint) | 217 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, Vector<RenderLayer*>& layersNeedingPaintInvalidation) |
| 218 { | 218 { |
| 219 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); | 219 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); |
| 220 if (compositedLayerUpdate != NoCompositingStateChange) { | 220 if (compositedLayerUpdate != NoCompositingStateChange) { |
| 221 layersNeedingRepaint.append(reflectionLayer); | 221 layersNeedingPaintInvalidation.append(reflectionLayer); |
| 222 m_layersChanged = true; | 222 m_layersChanged = true; |
| 223 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); | 223 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); |
| 224 } | 224 } |
| 225 m_compositor->updateDirectCompositingReasons(reflectionLayer); | 225 m_compositor->updateDirectCompositingReasons(reflectionLayer); |
| 226 | 226 |
| 227 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? | 227 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? |
| 228 if (reflectionLayer->hasCompositedLayerMapping()) | 228 if (reflectionLayer->hasCompositedLayerMapping()) |
| 229 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); | 229 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingRepaint) | 232 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) |
| 233 { | 233 { |
| 234 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { | 234 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { |
| 235 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); | 235 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); |
| 236 if (reasonsPreventingSquashing) | 236 if (reasonsPreventingSquashing) |
| 237 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); | 237 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); |
| 238 } | 238 } |
| 239 | 239 |
| 240 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); | 240 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); |
| 241 | 241 |
| 242 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { | 242 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { |
| 243 layersNeedingRepaint.append(layer); | 243 layersNeedingPaintInvalidation.append(layer); |
| 244 m_layersChanged = true; | 244 m_layersChanged = true; |
| 245 } | 245 } |
| 246 | 246 |
| 247 // FIXME: special-casing reflection layers here is not right. | 247 // FIXME: special-casing reflection layers here is not right. |
| 248 if (layer->reflectionInfo()) | 248 if (layer->reflectionInfo()) |
| 249 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingRepaint); | 249 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingPaintInvalidation); |
| 250 | 250 |
| 251 // Add this layer to a squashing backing if needed. | 251 // Add this layer to a squashing backing if needed. |
| 252 if (m_layerSquashingEnabled) { | 252 if (m_layerSquashingEnabled) { |
| 253 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate,
layersNeedingRepaint); | 253 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate,
layersNeedingPaintInvalidation); |
| 254 | 254 |
| 255 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLaye
r || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping
()); | 255 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLaye
r || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping
()); |
| 256 if (layerIsSquashed) { | 256 if (layerIsSquashed) { |
| 257 squashingState.nextSquashedLayerIndex++; | 257 squashingState.nextSquashedLayerIndex++; |
| 258 IntRect layerBounds = layer->clippedAbsoluteBoundingBox(); | 258 IntRect layerBounds = layer->clippedAbsoluteBoundingBox(); |
| 259 squashingState.totalAreaOfSquashedRects += layerBounds.size().area()
; | 259 squashingState.totalAreaOfSquashedRects += layerBounds.size().area()
; |
| 260 squashingState.boundingRect.unite(layerBounds); | 260 squashingState.boundingRect.unite(layerBounds); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 if (layer->stackingNode()->isStackingContext()) { | 264 if (layer->stackingNode()->isStackingContext()) { |
| 265 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); | 265 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); |
| 266 while (RenderLayerStackingNode* curNode = iterator.next()) | 266 while (RenderLayerStackingNode* curNode = iterator.next()) |
| 267 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay
ersNeedingRepaint); | 267 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay
ersNeedingPaintInvalidation); |
| 268 } | 268 } |
| 269 | 269 |
| 270 if (m_layerSquashingEnabled) { | 270 if (m_layerSquashingEnabled) { |
| 271 // At this point, if the layer is to be "separately" composited, then it
s backing becomes the most recent in paint-order. | 271 // At this point, if the layer is to be "separately" composited, then it
s backing becomes the most recent in paint-order. |
| 272 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit
ingState() == HasOwnBackingButPaintsIntoAncestor) { | 272 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit
ingState() == HasOwnBackingButPaintsIntoAncestor) { |
| 273 ASSERT(!requiresSquashing(layer->compositingReasons())); | 273 ASSERT(!requiresSquashing(layer->compositingReasons())); |
| 274 squashingState.updateSquashingStateForNewMapping(layer->compositedLa
yerMapping(), layer->hasCompositedLayerMapping()); | 274 squashingState.updateSquashingStateForNewMapping(layer->compositedLa
yerMapping(), layer->hasCompositedLayerMapping()); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (layer->scrollParent()) | 278 if (layer->scrollParent()) |
| 279 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer); | 279 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer); |
| 280 | 280 |
| 281 if (layer->needsCompositedScrolling()) | 281 if (layer->needsCompositedScrolling()) |
| 282 layer->scrollableArea()->setTopmostScrollChild(0); | 282 layer->scrollableArea()->setTopmostScrollChild(0); |
| 283 | 283 |
| 284 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 284 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
| 285 while (RenderLayerStackingNode* curNode = iterator.next()) | 285 while (RenderLayerStackingNode* curNode = iterator.next()) |
| 286 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingRepaint); | 286 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); |
| 287 | 287 |
| 288 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) | 288 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) |
| 289 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 289 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
| 290 } | 290 } |
| 291 | 291 |
| 292 } | 292 } |
| OLD | NEW |