| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 m_subtreeIsCompositing(false), | 147 m_subtreeIsCompositing(false), |
| 148 m_hasUnisolatedCompositedBlendingDescendant(false), | 148 m_hasUnisolatedCompositedBlendingDescendant(false), |
| 149 m_testingOverlap(true), | 149 m_testingOverlap(true), |
| 150 m_hasCompositedScrollingAncestor(false) {} | 150 m_hasCompositedScrollingAncestor(false) {} |
| 151 | 151 |
| 152 PaintLayer* m_compositingAncestor; | 152 PaintLayer* m_compositingAncestor; |
| 153 bool m_subtreeIsCompositing; | 153 bool m_subtreeIsCompositing; |
| 154 bool m_hasUnisolatedCompositedBlendingDescendant; | 154 bool m_hasUnisolatedCompositedBlendingDescendant; |
| 155 bool m_testingOverlap; | 155 bool m_testingOverlap; |
| 156 bool m_hasCompositedScrollingAncestor; | 156 bool m_hasCompositedScrollingAncestor; |
| 157 Vector<PaintLayer*>& layersNeedingPostProcessing() { |
| 158 return m_layersNeedingPostProcessing; |
| 159 } |
| 160 |
| 161 private: |
| 162 Vector<PaintLayer*> m_layersNeedingPostProcessing; |
| 157 }; | 163 }; |
| 158 | 164 |
| 159 static bool requiresCompositingOrSquashing(CompositingReasons reasons) { | 165 static bool requiresCompositingOrSquashing(CompositingReasons reasons) { |
| 160 #if DCHECK_IS_ON() | 166 #if DCHECK_IS_ON() |
| 161 bool fastAnswer = reasons != CompositingReasonNone; | 167 bool fastAnswer = reasons != CompositingReasonNone; |
| 162 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons); | 168 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons); |
| 163 DCHECK_EQ(slowAnswer, fastAnswer); | 169 DCHECK_EQ(slowAnswer, fastAnswer); |
| 164 #endif | 170 #endif |
| 165 return reasons != CompositingReasonNone; | 171 return reasons != CompositingReasonNone; |
| 166 } | 172 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 516 } |
| 511 | 517 |
| 512 if (willBeCompositedOrSquashed && | 518 if (willBeCompositedOrSquashed && |
| 513 layer->layoutObject().style()->hasBlendMode()) | 519 layer->layoutObject().style()->hasBlendMode()) |
| 514 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; | 520 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; |
| 515 | 521 |
| 516 // Tell the parent it has compositing descendants. | 522 // Tell the parent it has compositing descendants. |
| 517 if (willBeCompositedOrSquashed) | 523 if (willBeCompositedOrSquashed) |
| 518 currentRecursionData.m_subtreeIsCompositing = true; | 524 currentRecursionData.m_subtreeIsCompositing = true; |
| 519 | 525 |
| 526 // Track non-composited skewed elements |
| 527 if (!willBeCompositedOrSquashed && canBeComposited && |
| 528 layer->layoutObject().styleRef().hasTransform() && |
| 529 layer->layoutObject().styleRef().transform().hasSkew()) { |
| 530 currentRecursionData.layersNeedingPostProcessing().push_back(layer); |
| 531 } |
| 532 |
| 533 // Promote skewed elements within a promoted skewed element to improve |
| 534 // output quality. |
| 535 if (willBeCompositedOrSquashed && |
| 536 !childRecursionData.layersNeedingPostProcessing().isEmpty()) { |
| 537 // If an skewed element is composited due to its descendants, we have to |
| 538 // update the uncomposited skewed descendants to composite them. |
| 539 if (layer->layoutObject().styleRef().hasTransform() && |
| 540 layer->layoutObject().styleRef().transform().hasSkew()) { |
| 541 for (auto& childLayer : |
| 542 childRecursionData.layersNeedingPostProcessing()) { |
| 543 childLayer->setCompositingReasons( |
| 544 CompositingReasonSkewWithCompositedSkewedAncestor); |
| 545 } |
| 546 } |
| 547 childRecursionData.layersNeedingPostProcessing().clear(); |
| 548 } |
| 549 |
| 550 // Current non-leaf layer and it descendants have been updated. |
| 551 if (layer->firstChild()) { |
| 552 currentRecursionData.layersNeedingPostProcessing().clear(); |
| 553 } |
| 554 |
| 520 // Turn overlap testing off for later layers if it's already off, or if we | 555 // Turn overlap testing off for later layers if it's already off, or if we |
| 521 // have an animating transform. Note that if the layer clips its | 556 // have an animating transform. Note that if the layer clips its |
| 522 // descendants, there's no reason to propagate the child animation to the | 557 // descendants, there's no reason to propagate the child animation to the |
| 523 // parent layers. That's because we know for sure the animation is contained | 558 // parent layers. That's because we know for sure the animation is contained |
| 524 // inside the clipping rectangle, which is already added to the overlap map. | 559 // inside the clipping rectangle, which is already added to the overlap map. |
| 525 bool isCompositedClippingLayer = | 560 bool isCompositedClippingLayer = |
| 526 canBeComposited && | 561 canBeComposited && |
| 527 (reasonsToComposite & CompositingReasonClipsCompositingDescendants); | 562 (reasonsToComposite & CompositingReasonClipsCompositingDescendants); |
| 528 bool isCompositedWithInlineTransform = | 563 bool isCompositedWithInlineTransform = |
| 529 reasonsToComposite & CompositingReasonInlineTransform; | 564 reasonsToComposite & CompositingReasonInlineTransform; |
| 530 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || | 565 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || |
| 531 layer->layoutObject().style()->hasCurrentTransformAnimation() || | 566 layer->layoutObject().style()->hasCurrentTransformAnimation() || |
| 532 isCompositedWithInlineTransform) | 567 isCompositedWithInlineTransform) |
| 533 currentRecursionData.m_testingOverlap = false; | 568 currentRecursionData.m_testingOverlap = false; |
| 534 | 569 |
| 535 if (childRecursionData.m_compositingAncestor == layer) | 570 if (childRecursionData.m_compositingAncestor == layer) |
| 536 overlapMap.finishCurrentOverlapTestingContext(); | 571 overlapMap.finishCurrentOverlapTestingContext(); |
| 537 | 572 |
| 538 descendantHas3DTransform |= | 573 descendantHas3DTransform |= |
| 539 anyDescendantHas3DTransform || layer->has3DTransform(); | 574 anyDescendantHas3DTransform || layer->has3DTransform(); |
| 540 } | 575 } |
| 541 | 576 |
| 542 // At this point we have finished collecting all reasons to composite this | 577 // At this point we have finished collecting all reasons to composite this |
| 543 // layer. | 578 // layer. |
| 544 layer->setCompositingReasons(reasonsToComposite); | 579 layer->setCompositingReasons(reasonsToComposite); |
| 545 } | 580 } |
| 546 | 581 |
| 547 } // namespace blink | 582 } // namespace blink |
| OLD | NEW |