| 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 14 matching lines...) Expand all Loading... |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/rendering/compositing/CompositingLayerAssigner.h" | 28 #include "core/rendering/compositing/CompositingLayerAssigner.h" |
| 29 | 29 |
| 30 #include "core/rendering/compositing/CompositedLayerMapping.h" | 30 #include "core/rendering/compositing/CompositedLayerMapping.h" |
| 31 #include "platform/TraceEvent.h" | 31 #include "platform/TraceEvent.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 // We will only allow squashing if the bbox-area:squashed-area doesn't exceed | |
| 36 // the ratio |gSquashingSparsityTolerance|:1. | |
| 37 static uint64_t gSquashingSparsityTolerance = 6; | |
| 38 | |
| 39 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos
itor) | 35 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos
itor) |
| 40 : m_compositor(compositor) | 36 : m_compositor(compositor) |
| 41 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) | 37 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) |
| 42 , m_layersChanged(false) | 38 , m_layersChanged(false) |
| 43 { | 39 { |
| 44 } | 40 } |
| 45 | 41 |
| 46 CompositingLayerAssigner::~CompositingLayerAssigner() | 42 CompositingLayerAssigner::~CompositingLayerAssigner() |
| 47 { | 43 { |
| 48 } | 44 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 if (hasMostRecentMapping) | 59 if (hasMostRecentMapping) |
| 64 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); | 60 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); |
| 65 | 61 |
| 66 nextSquashedLayerIndex = 0; | 62 nextSquashedLayerIndex = 0; |
| 67 boundingRect = IntRect(); | 63 boundingRect = IntRect(); |
| 68 mostRecentMapping = newCompositedLayerMapping; | 64 mostRecentMapping = newCompositedLayerMapping; |
| 69 hasMostRecentMapping = hasNewCompositedLayerMapping; | 65 hasMostRecentMapping = hasNewCompositedLayerMapping; |
| 70 haveAssignedBackingsToEntireSquashingLayerSubtree = false; | 66 haveAssignedBackingsToEntireSquashingLayerSubtree = false; |
| 71 } | 67 } |
| 72 | 68 |
| 73 bool CompositingLayerAssigner::squashingWouldExceedSparsityTolerance(const Rende
rLayer* candidate, const CompositingLayerAssigner::SquashingState& squashingStat
e) | |
| 74 { | |
| 75 IntRect bounds = candidate->clippedAbsoluteBoundingBox(); | |
| 76 IntRect newBoundingRect = squashingState.boundingRect; | |
| 77 newBoundingRect.unite(bounds); | |
| 78 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); | |
| 79 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b
ounds.size().area(); | |
| 80 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; | |
| 81 } | |
| 82 | |
| 83 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const | 69 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const |
| 84 { | 70 { |
| 85 if (!m_compositor->canBeComposited(layer)) | 71 if (!m_compositor->canBeComposited(layer)) |
| 86 return false; | 72 return false; |
| 87 | 73 |
| 88 // If squashing is disabled, then layers that would have been squashed shoul
d just be separately composited. | 74 // If squashing is disabled, then layers that would have been squashed shoul
d just be separately composited. |
| 89 bool needsOwnBackingForDisabledSquashing = !m_layerSquashingEnabled && requi
resSquashing(layer->compositingReasons()); | 75 bool needsOwnBackingForDisabledSquashing = !m_layerSquashingEnabled && requi
resSquashing(layer->compositingReasons()); |
| 90 | 76 |
| 91 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo
rDisabledSquashing || (m_compositor->staleInCompositingMode() && layer->isRootLa
yer()); | 77 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo
rDisabledSquashing || (m_compositor->staleInCompositingMode() && layer->isRootLa
yer()); |
| 92 } | 78 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 113 } | 99 } |
| 114 } | 100 } |
| 115 return update; | 101 return update; |
| 116 } | 102 } |
| 117 | 103 |
| 118 CompositingReasons CompositingLayerAssigner::getReasonsPreventingSquashing(const
RenderLayer* layer, const CompositingLayerAssigner::SquashingState& squashingSt
ate) | 104 CompositingReasons CompositingLayerAssigner::getReasonsPreventingSquashing(const
RenderLayer* layer, const CompositingLayerAssigner::SquashingState& squashingSt
ate) |
| 119 { | 105 { |
| 120 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) | 106 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) |
| 121 return CompositingReasonSquashingWouldBreakPaintOrder; | 107 return CompositingReasonSquashingWouldBreakPaintOrder; |
| 122 | 108 |
| 123 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) | |
| 124 return CompositingReasonSquashingSparsityExceeded; | |
| 125 | |
| 126 // FIXME: this is not efficient, since it walks up the tree . We should stor
e these values on the CompositingInputsCache. | 109 // FIXME: this is not efficient, since it walks up the tree . We should stor
e these values on the CompositingInputsCache. |
| 127 ASSERT(squashingState.hasMostRecentMapping); | 110 ASSERT(squashingState.hasMostRecentMapping); |
| 128 const RenderLayer& squashingLayer = squashingState.mostRecentMapping->owning
Layer(); | 111 const RenderLayer& squashingLayer = squashingState.mostRecentMapping->owning
Layer(); |
| 129 | 112 |
| 130 if (layer->clippingContainer() != squashingLayer.clippingContainer() && !squ
ashingLayer.compositedLayerMapping()->containingSquashedLayer(layer->clippingCon
tainer())) | 113 if (layer->clippingContainer() != squashingLayer.clippingContainer() && !squ
ashingLayer.compositedLayerMapping()->containingSquashedLayer(layer->clippingCon
tainer())) |
| 131 return CompositingReasonSquashingClippingContainerMismatch; | 114 return CompositingReasonSquashingClippingContainerMismatch; |
| 132 | 115 |
| 133 // Composited descendants need to be clipped by a child containment graphics
layer, which would not be available if the layer is | 116 // Composited descendants need to be clipped by a child containment graphics
layer, which would not be available if the layer is |
| 134 // squashed (and therefore has no CLM nor a child containment graphics layer
). | 117 // squashed (and therefore has no CLM nor a child containment graphics layer
). |
| 135 if (m_compositor->clipsCompositingDescendants(layer)) | 118 if (m_compositor->clipsCompositingDescendants(layer)) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 228 |
| 246 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 229 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
| 247 while (RenderLayerStackingNode* curNode = iterator.next()) | 230 while (RenderLayerStackingNode* curNode = iterator.next()) |
| 248 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); | 231 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); |
| 249 | 232 |
| 250 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) | 233 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) |
| 251 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 234 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
| 252 } | 235 } |
| 253 | 236 |
| 254 } | 237 } |
| OLD | NEW |