| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 Vector<OverlapMapContainer> m_overlapStack; | 121 Vector<OverlapMapContainer> m_overlapStack; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 class CompositingRequirementsUpdater::RecursionData { | 124 class CompositingRequirementsUpdater::RecursionData { |
| 125 public: | 125 public: |
| 126 explicit RecursionData(RenderLayer* compositingAncestor) | 126 explicit RecursionData(RenderLayer* compositingAncestor) |
| 127 : m_compositingAncestor(compositingAncestor) | 127 : m_compositingAncestor(compositingAncestor) |
| 128 , m_subtreeIsCompositing(false) | 128 , m_subtreeIsCompositing(false) |
| 129 , m_hasUnisolatedCompositedBlendingDescendant(false) | |
| 130 , m_testingOverlap(true) | 129 , m_testingOverlap(true) |
| 131 { | 130 { |
| 132 } | 131 } |
| 133 | 132 |
| 134 RenderLayer* m_compositingAncestor; | 133 RenderLayer* m_compositingAncestor; |
| 135 bool m_subtreeIsCompositing; | 134 bool m_subtreeIsCompositing; |
| 136 bool m_hasUnisolatedCompositedBlendingDescendant; | |
| 137 bool m_testingOverlap; | 135 bool m_testingOverlap; |
| 138 }; | 136 }; |
| 139 | 137 |
| 140 static bool requiresCompositingOrSquashing(CompositingReasons reasons) | 138 static bool requiresCompositingOrSquashing(CompositingReasons reasons) |
| 141 { | 139 { |
| 142 #if ENABLE(ASSERT) | 140 #if ENABLE(ASSERT) |
| 143 bool fastAnswer = reasons != CompositingReasonNone; | 141 bool fastAnswer = reasons != CompositingReasonNone; |
| 144 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons)
; | 142 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons)
; |
| 145 ASSERT(fastAnswer == slowAnswer); | 143 ASSERT(fastAnswer == slowAnswer); |
| 146 #endif | 144 #endif |
| 147 return reasons != CompositingReasonNone; | 145 return reasons != CompositingReasonNone; |
| 148 } | 146 } |
| 149 | 147 |
| 150 static CompositingReasons subtreeReasonsForCompositing(RenderLayer* layer, bool
hasCompositedDescendants, bool has3DTransformedDescendants) | 148 static CompositingReasons subtreeReasonsForCompositing(RenderLayer* layer, bool
hasCompositedDescendants, bool has3DTransformedDescendants) |
| 151 { | 149 { |
| 152 CompositingReasons subtreeReasons = CompositingReasonNone; | 150 CompositingReasons subtreeReasons = CompositingReasonNone; |
| 153 | 151 |
| 154 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented | 152 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented |
| 155 // via compositing so that they also apply to those composited descdendants. | 153 // via compositing so that they also apply to those composited descdendants. |
| 156 if (hasCompositedDescendants) { | 154 if (hasCompositedDescendants) { |
| 157 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() & Compos
itingReasonComboCompositedDescendants; | 155 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() & Compos
itingReasonComboCompositedDescendants; |
| 158 | 156 |
| 159 if (layer->shouldIsolateCompositedDescendants()) { | |
| 160 ASSERT(layer->stackingNode()->isStackingContext()); | |
| 161 subtreeReasons |= CompositingReasonIsolateCompositedDescendants; | |
| 162 } | |
| 163 | 157 |
| 164 // FIXME: This should move into CompositingReasonFinder::potentialCompos
itingReasonsFromStyle, but | 158 // FIXME: This should move into CompositingReasonFinder::potentialCompos
itingReasonsFromStyle, but |
| 165 // theres a poor interaction with RenderTextControlSingleLine, which set
s this hasOverflowClip directly. | 159 // theres a poor interaction with RenderTextControlSingleLine, which set
s this hasOverflowClip directly. |
| 166 if (layer->renderer()->hasClipOrOverflowClip()) | 160 if (layer->renderer()->hasClipOrOverflowClip()) |
| 167 subtreeReasons |= CompositingReasonClipsCompositingDescendants; | 161 subtreeReasons |= CompositingReasonClipsCompositingDescendants; |
| 168 } | 162 } |
| 169 | 163 |
| 170 // A layer with preserve-3d or perspective only needs to be composited if th
ere are descendant layers that | 164 // A layer with preserve-3d or perspective only needs to be composited if th
ere are descendant layers that |
| 171 // will be affected by the preserve-3d or perspective. | 165 // will be affected by the preserve-3d or perspective. |
| 172 if (has3DTransformedDescendants) | 166 if (has3DTransformedDescendants) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 322 |
| 329 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 323 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
| 330 while (RenderLayerStackingNode* curNode = iterator.next()) { | 324 while (RenderLayerStackingNode* curNode = iterator.next()) { |
| 331 IntRect absoluteChildDecendantBoundingBox; | 325 IntRect absoluteChildDecendantBoundingBox; |
| 332 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData,
anyDescendantHas3DTransform, unclippedDescendants, absoluteChildDecendantBoundi
ngBox); | 326 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData,
anyDescendantHas3DTransform, unclippedDescendants, absoluteChildDecendantBoundi
ngBox); |
| 333 absoluteDecendantBoundingBox.unite(absoluteChildDecendantBoundingBox); | 327 absoluteDecendantBoundingBox.unite(absoluteChildDecendantBoundingBox); |
| 334 } | 328 } |
| 335 | 329 |
| 336 // Now that the subtree has been traversed, we can check for compositing rea
sons that depended on the state of the subtree. | 330 // Now that the subtree has been traversed, we can check for compositing rea
sons that depended on the state of the subtree. |
| 337 | 331 |
| 338 if (layer->stackingNode()->isStackingContext()) { | |
| 339 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni
solatedCompositedBlendingDescendant); | |
| 340 } else { | |
| 341 layer->setShouldIsolateCompositedDescendants(false); | |
| 342 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child
RecursionData.m_hasUnisolatedCompositedBlendingDescendant; | |
| 343 } | |
| 344 | |
| 345 // Subsequent layers in the parent's stacking context may also need to compo
site. | 332 // Subsequent layers in the parent's stacking context may also need to compo
site. |
| 346 if (childRecursionData.m_subtreeIsCompositing) | 333 if (childRecursionData.m_subtreeIsCompositing) |
| 347 currentRecursionData.m_subtreeIsCompositing = true; | 334 currentRecursionData.m_subtreeIsCompositing = true; |
| 348 | 335 |
| 349 // Set the flag to say that this SC has compositing children. | 336 // Set the flag to say that this SC has compositing children. |
| 350 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); | 337 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); |
| 351 | 338 |
| 352 if (layer->isRootLayer()) { | 339 if (layer->isRootLayer()) { |
| 353 // The root layer needs to be composited if anything else in the tree is
composited. | 340 // The root layer needs to be composited if anything else in the tree is
composited. |
| 354 // Otherwise, we can disable compositing entirely. | 341 // Otherwise, we can disable compositing entirely. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 374 // now, because the code is designed to push overlap information to
the | 361 // now, because the code is designed to push overlap information to
the |
| 375 // second-from-top context of the stack. | 362 // second-from-top context of the stack. |
| 376 overlapMap.beginNewOverlapTestingContext(); | 363 overlapMap.beginNewOverlapTestingContext(); |
| 377 overlapMap.add(layer, absoluteDecendantBoundingBox); | 364 overlapMap.add(layer, absoluteDecendantBoundingBox); |
| 378 willBeCompositedOrSquashed = true; | 365 willBeCompositedOrSquashed = true; |
| 379 } | 366 } |
| 380 | 367 |
| 381 if (willBeCompositedOrSquashed) | 368 if (willBeCompositedOrSquashed) |
| 382 reasonsToComposite |= layer->potentialCompositingReasonsFromStyle()
& CompositingReasonInlineTransform; | 369 reasonsToComposite |= layer->potentialCompositingReasonsFromStyle()
& CompositingReasonInlineTransform; |
| 383 | 370 |
| 384 if (willBeCompositedOrSquashed && layer->renderer()->hasBlendMode()) | |
| 385 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = t
rue; | |
| 386 | |
| 387 // Turn overlap testing off for later layers if it's already off, or if
we have an animating transform. | 371 // Turn overlap testing off for later layers if it's already off, or if
we have an animating transform. |
| 388 // Note that if the layer clips its descendants, there's no reason to pr
opagate the child animation to the parent layers. That's because | 372 // Note that if the layer clips its descendants, there's no reason to pr
opagate the child animation to the parent layers. That's because |
| 389 // we know for sure the animation is contained inside the clipping recta
ngle, which is already added to the overlap map. | 373 // we know for sure the animation is contained inside the clipping recta
ngle, which is already added to the overlap map. |
| 390 bool isCompositedClippingLayer = compositor->canBeComposited(layer) && (
reasonsToComposite & CompositingReasonClipsCompositingDescendants); | 374 bool isCompositedClippingLayer = compositor->canBeComposited(layer) && (
reasonsToComposite & CompositingReasonClipsCompositingDescendants); |
| 391 bool isCompositedWithInlineTransform = reasonsToComposite & CompositingR
easonInlineTransform; | 375 bool isCompositedWithInlineTransform = reasonsToComposite & CompositingR
easonInlineTransform; |
| 392 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer)
|| layer->renderer()->style()->hasCurrentTransformAnimation() || isCompositedWi
thInlineTransform) | 376 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer)
|| layer->renderer()->style()->hasCurrentTransformAnimation() || isCompositedWi
thInlineTransform) |
| 393 currentRecursionData.m_testingOverlap = false; | 377 currentRecursionData.m_testingOverlap = false; |
| 394 | 378 |
| 395 if (childRecursionData.m_compositingAncestor == layer) | 379 if (childRecursionData.m_compositingAncestor == layer) |
| 396 overlapMap.finishCurrentOverlapTestingContext(); | 380 overlapMap.finishCurrentOverlapTestingContext(); |
| 397 | 381 |
| 398 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DT
ransform(); | 382 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DT
ransform(); |
| 399 } | 383 } |
| 400 | 384 |
| 401 // At this point we have finished collecting all reasons to composite this l
ayer. | 385 // At this point we have finished collecting all reasons to composite this l
ayer. |
| 402 layer->setCompositingReasons(reasonsToComposite); | 386 layer->setCompositingReasons(reasonsToComposite); |
| 403 | 387 |
| 404 } | 388 } |
| 405 | 389 |
| 406 } // namespace blink | 390 } // namespace blink |
| OLD | NEW |