Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/layout/compositing/CompositingRequirementsUpdater.h" | 27 #include "core/layout/compositing/CompositingRequirementsUpdater.h" |
| 28 | 28 |
| 29 #include "core/layout/LayoutView.h" | 29 #include "core/layout/LayoutView.h" |
| 30 #include "core/layout/compositing/PaintLayerCompositor.h" | 30 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 31 #include "core/page/Page.h" | |
| 32 #include "core/page/scrolling/ScrollingCoordinator.h" | |
| 31 #include "core/paint/PaintLayer.h" | 33 #include "core/paint/PaintLayer.h" |
| 32 #include "core/paint/PaintLayerStackingNode.h" | 34 #include "core/paint/PaintLayerStackingNode.h" |
| 33 #include "core/paint/PaintLayerStackingNodeIterator.h" | 35 #include "core/paint/PaintLayerStackingNodeIterator.h" |
| 34 #include "platform/tracing/TraceEvent.h" | 36 #include "platform/tracing/TraceEvent.h" |
| 35 | 37 |
| 36 namespace blink { | 38 namespace blink { |
| 37 | 39 |
| 38 class OverlapMapContainer { | 40 class OverlapMapContainer { |
| 39 public: | 41 public: |
| 40 void add(const IntRect& bounds) { | 42 void add(const IntRect& bounds) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 Vector<PaintLayer*>& unclippedDescendants, | 245 Vector<PaintLayer*>& unclippedDescendants, |
| 244 IntRect& absoluteDescendantBoundingBox) { | 246 IntRect& absoluteDescendantBoundingBox) { |
| 245 PaintLayerCompositor* compositor = m_layoutView.compositor(); | 247 PaintLayerCompositor* compositor = m_layoutView.compositor(); |
| 246 | 248 |
| 247 layer->stackingNode()->updateLayerListsIfNeeded(); | 249 layer->stackingNode()->updateLayerListsIfNeeded(); |
| 248 | 250 |
| 249 CompositingReasons reasonsToComposite = CompositingReasonNone; | 251 CompositingReasons reasonsToComposite = CompositingReasonNone; |
| 250 CompositingReasons directReasons = | 252 CompositingReasons directReasons = |
| 251 m_compositingReasonFinder.directReasons(layer); | 253 m_compositingReasonFinder.directReasons(layer); |
| 252 | 254 |
| 255 if (!compositor->preferCompositingToLCDTextEnabled()) | |
| 256 updateMainThreadScrollingReasonsFromStyle(layer); | |
|
bokan
2016/12/16 23:06:01
Sorry, one last thing. I think this is the wrong p
yigu
2016/12/18 15:05:11
Done.
| |
| 257 | |
| 253 // Video is special. It's the only PaintLayer type that can both have | 258 // Video is special. It's the only PaintLayer type that can both have |
| 254 // PaintLayer children and whose children can't use its backing to render | 259 // PaintLayer children and whose children can't use its backing to render |
| 255 // into. These children (the controls) always need to be promoted into their | 260 // into. These children (the controls) always need to be promoted into their |
| 256 // own layers to draw on top of the accelerated video. | 261 // own layers to draw on top of the accelerated video. |
| 257 if (currentRecursionData.m_compositingAncestor && | 262 if (currentRecursionData.m_compositingAncestor && |
| 258 currentRecursionData.m_compositingAncestor->layoutObject()->isVideo()) | 263 currentRecursionData.m_compositingAncestor->layoutObject()->isVideo()) |
| 259 directReasons |= CompositingReasonVideoOverlay; | 264 directReasons |= CompositingReasonVideoOverlay; |
| 260 | 265 |
| 261 bool hasCompositedScrollingAncestor = | 266 bool hasCompositedScrollingAncestor = |
| 262 layer->ancestorScrollingLayer() && | 267 layer->ancestorScrollingLayer() && |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 | 542 |
| 538 descendantHas3DTransform |= | 543 descendantHas3DTransform |= |
| 539 anyDescendantHas3DTransform || layer->has3DTransform(); | 544 anyDescendantHas3DTransform || layer->has3DTransform(); |
| 540 } | 545 } |
| 541 | 546 |
| 542 // At this point we have finished collecting all reasons to composite this | 547 // At this point we have finished collecting all reasons to composite this |
| 543 // layer. | 548 // layer. |
| 544 layer->setCompositingReasons(reasonsToComposite); | 549 layer->setCompositingReasons(reasonsToComposite); |
| 545 } | 550 } |
| 546 | 551 |
| 552 // Check if current layer has layout object that contains properties that cause | |
| 553 // main thread scrolling. | |
| 554 void CompositingRequirementsUpdater::updateMainThreadScrollingReasonsFromStyle( | |
| 555 const PaintLayer* layer) const { | |
| 556 // If current layer has opacity and has not been recorded, add the layer into | |
| 557 // frameView and vice versa. | |
| 558 if (!layer || !layer->getScrollableArea()) | |
| 559 return; | |
| 560 | |
| 561 if (ScrollingCoordinator* scrollingCoordinator = | |
|
bokan
2016/12/16 23:06:01
nit: we generally prefer the above pattern of earl
yigu
2016/12/18 15:05:12
Done.
| |
| 562 m_layoutView.document().page()->scrollingCoordinator()) { | |
| 563 if (layer->compositesWithOpacity() != | |
| 564 layer->getScrollableArea()->hasMainThreadScrollingReason( | |
| 565 MainThreadScrollingReason::kHasOpacity)) { | |
| 566 layer->getScrollableArea()->flipMainThreadScrollingReason( | |
| 567 MainThreadScrollingReason::kHasOpacity); | |
| 568 | |
| 569 scrollingCoordinator->adjustMainThreadReasonsFromStyle( | |
| 570 MainThreadScrollingReason::kHasOpacity, | |
| 571 layer->compositesWithOpacity()); | |
| 572 } | |
| 573 } | |
| 574 } | |
| 575 | |
| 547 } // namespace blink | 576 } // namespace blink |
| OLD | NEW |