Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp

Issue 2565223002: Add more specific metrics for main thread scrolling reasons (Closed)
Patch Set: Move logic regarding clearing up ReasonsCounter upon layer dispose to ScrollingCoordinator Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 updateMainThreadScrollingReasonsFromStyle(layer);
256
253 // Video is special. It's the only PaintLayer type that can both have 257 // 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 258 // 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 259 // into. These children (the controls) always need to be promoted into their
256 // own layers to draw on top of the accelerated video. 260 // own layers to draw on top of the accelerated video.
257 if (currentRecursionData.m_compositingAncestor && 261 if (currentRecursionData.m_compositingAncestor &&
258 currentRecursionData.m_compositingAncestor->layoutObject()->isVideo()) 262 currentRecursionData.m_compositingAncestor->layoutObject()->isVideo())
259 directReasons |= CompositingReasonVideoOverlay; 263 directReasons |= CompositingReasonVideoOverlay;
260 264
261 bool hasCompositedScrollingAncestor = 265 bool hasCompositedScrollingAncestor =
262 layer->ancestorScrollingLayer() && 266 layer->ancestorScrollingLayer() &&
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 541
538 descendantHas3DTransform |= 542 descendantHas3DTransform |=
539 anyDescendantHas3DTransform || layer->has3DTransform(); 543 anyDescendantHas3DTransform || layer->has3DTransform();
540 } 544 }
541 545
542 // At this point we have finished collecting all reasons to composite this 546 // At this point we have finished collecting all reasons to composite this
543 // layer. 547 // layer.
544 layer->setCompositingReasons(reasonsToComposite); 548 layer->setCompositingReasons(reasonsToComposite);
545 } 549 }
546 550
551 // Check if current layer has layout object that contains properties that cause
552 // main thread scrolling.
553 void CompositingRequirementsUpdater::updateMainThreadScrollingReasonsFromStyle(
554 const PaintLayer* layer) const {
555 // If current layer has opacity and has not been recorded, add the layer into
556 // frameView and vice versa.
557 if (!layer || !layer->getScrollableArea())
558 return;
559 if (layer->compositesWithOpacity() !=
560 layer->getScrollableArea()->hasMainThreadScrollingReason(
561 MainThreadScrollingReason::kHasOpacity)) {
562 layer->getScrollableArea()->flipMainThreadScrollingReason(
563 MainThreadScrollingReason::kHasOpacity);
564
565 if (ScrollingCoordinator* scrollingCoordinator =
bokan 2016/12/15 20:47:45 Should we early out above if there's no scrolling
yigu 2016/12/16 18:17:39 Done.
566 m_layoutView.document().page()->scrollingCoordinator()) {
567 scrollingCoordinator->adjustMainThreadReasonsFromStyle(
568 MainThreadScrollingReason::kHasOpacity,
569 layer->compositesWithOpacity());
570 }
571 }
572 }
573
547 } // namespace blink 574 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698