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" | |
| 31 #include "core/paint/PaintLayer.h" | 32 #include "core/paint/PaintLayer.h" |
| 32 #include "core/paint/PaintLayerStackingNode.h" | 33 #include "core/paint/PaintLayerStackingNode.h" |
| 33 #include "core/paint/PaintLayerStackingNodeIterator.h" | 34 #include "core/paint/PaintLayerStackingNodeIterator.h" |
| 34 #include "platform/tracing/TraceEvent.h" | 35 #include "platform/tracing/TraceEvent.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 class OverlapMapContainer { | 39 class OverlapMapContainer { |
| 39 public: | 40 public: |
| 40 void add(const IntRect& bounds) { | 41 void add(const IntRect& bounds) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 Vector<PaintLayer*>& unclippedDescendants, | 244 Vector<PaintLayer*>& unclippedDescendants, |
| 244 IntRect& absoluteDescendantBoundingBox) { | 245 IntRect& absoluteDescendantBoundingBox) { |
| 245 PaintLayerCompositor* compositor = m_layoutView.compositor(); | 246 PaintLayerCompositor* compositor = m_layoutView.compositor(); |
| 246 | 247 |
| 247 layer->stackingNode()->updateLayerListsIfNeeded(); | 248 layer->stackingNode()->updateLayerListsIfNeeded(); |
| 248 | 249 |
| 249 CompositingReasons reasonsToComposite = CompositingReasonNone; | 250 CompositingReasons reasonsToComposite = CompositingReasonNone; |
| 250 CompositingReasons directReasons = | 251 CompositingReasons directReasons = |
| 251 m_compositingReasonFinder.directReasons(layer); | 252 m_compositingReasonFinder.directReasons(layer); |
| 252 | 253 |
| 254 if (ScrollingCoordinator* scrollingCoordinator = | |
| 255 m_layoutView.document().page()->scrollingCoordinator()) | |
| 256 updateMainThreadScrollingReasonsFromStyle(layer, scrollingCoordinator); | |
|
bokan
2016/12/14 13:28:58
No need to pass in ScrollingCoordinator, just get
yigu
2016/12/14 21:17:32
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, | |
| 556 ScrollingCoordinator* scrollingCoordinator) const { | |
| 557 // If current layer has opacity and has not been recorded, add the layer into | |
| 558 // frameView and vice versa. | |
| 559 if (!layer || !layer->getScrollableArea()) | |
| 560 return; | |
| 561 if (layer->compositesWithOpacity() != | |
| 562 layer->getScrollableArea()->hasMainThreadScrollingReason( | |
| 563 MainThreadScrollingReason::kHasOpacity)) { | |
| 564 layer->getScrollableArea()->flipMainThreadScrollingReason( | |
| 565 MainThreadScrollingReason::kHasOpacity); | |
| 566 | |
| 567 scrollingCoordinator->adjustMainThreadReasonsFromStyle( | |
| 568 MainThreadScrollingReason::kHasOpacity, layer->compositesWithOpacity()); | |
| 569 } | |
| 570 } | |
| 571 | |
| 547 } // namespace blink | 572 } // namespace blink |
| OLD | NEW |