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

Side by Side Diff: Source/core/rendering/RenderLayer.cpp

Issue 20103002: Make composited scrolling codepaths co-operate. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: UMA + bug Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) 124 RenderLayer::RenderLayer(RenderLayerModelObject* renderer)
125 : m_inResizeMode(false) 125 : m_inResizeMode(false)
126 , m_normalFlowListDirty(true) 126 , m_normalFlowListDirty(true)
127 , m_hasSelfPaintingLayerDescendant(false) 127 , m_hasSelfPaintingLayerDescendant(false)
128 , m_hasSelfPaintingLayerDescendantDirty(false) 128 , m_hasSelfPaintingLayerDescendantDirty(false)
129 , m_hasOutOfFlowPositionedDescendant(false) 129 , m_hasOutOfFlowPositionedDescendant(false)
130 , m_hasOutOfFlowPositionedDescendantDirty(true) 130 , m_hasOutOfFlowPositionedDescendantDirty(true)
131 , m_hasUnclippedDescendant(false) 131 , m_hasUnclippedDescendant(false)
132 , m_isUnclippedDescendant(false) 132 , m_isUnclippedDescendant(false)
133 , m_needsCompositedScrolling(false) 133 , m_needsCompositedScrolling(false)
134 , m_needsCompositedScrollingHasBeenRecorded(false) 134 , m_needsToBeStackingContainerHasBeenRecorded(false)
135 , m_willUseCompositedScrollingHasBeenRecorded(false) 135 , m_willUseCompositedScrollingHasBeenRecorded(false)
136 , m_isScrollableAreaHasBeenRecorded(false) 136 , m_isScrollableAreaHasBeenRecorded(false)
137 , m_needsToBeStackingContainer(false)
137 , m_canBePromotedToStackingContainer(false) 138 , m_canBePromotedToStackingContainer(false)
138 , m_canBePromotedToStackingContainerDirty(true) 139 , m_canBePromotedToStackingContainerDirty(true)
139 , m_isRootLayer(renderer->isRenderView()) 140 , m_isRootLayer(renderer->isRenderView())
140 , m_usedTransparency(false) 141 , m_usedTransparency(false)
141 , m_paintingInsideReflection(false) 142 , m_paintingInsideReflection(false)
142 , m_inOverflowRelayout(false) 143 , m_inOverflowRelayout(false)
143 , m_repaintStatus(NeedsNormalRepaint) 144 , m_repaintStatus(NeedsNormalRepaint)
144 , m_visibleContentStatusDirty(true) 145 , m_visibleContentStatusDirty(true)
145 , m_hasVisibleContent(false) 146 , m_hasVisibleContent(false)
146 , m_visibleDescendantStatusDirty(false) 147 , m_visibleDescendantStatusDirty(false)
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 471 }
471 } 472 }
472 } 473 }
473 474
474 bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const 475 bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const
475 { 476 {
476 const Settings* settings = renderer()->document().settings(); 477 const Settings* settings = renderer()->document().settings();
477 return settings && settings->acceleratedCompositingForOverflowScrollEnabled( ); 478 return settings && settings->acceleratedCompositingForOverflowScrollEnabled( );
478 } 479 }
479 480
481 bool RenderLayer::useCompositorDrivenAcceleratedScrolling() const
Ian Vollick 2013/09/06 02:01:05 It looks like there's some repeated logic here in
hartmanng 2013/09/06 20:18:36 Yeah, I guess we can... I thought we needed it fro
482 {
483 if (!compositorDrivenAcceleratedScrollingEnabled())
484 return false;
485
486 const RenderLayer* scrollingLayer = ancestorScrollingLayer();
487 if (!scrollingLayer || scrollingLayer->isStackingContainer())
488 return false;
489
490 if (scrollingLayer->m_canBePromotedToStackingContainerDirty) {
491 // We don't know if it's safe to promote to stacking container, and
492 // aren't in a position to find out, so we have to assume the worst.
493 return true;
494 }
495
496 return !scrollingLayer->needsToBeStackingContainer();
497 }
498
480 // FIXME: This is a temporary flag and should be removed once accelerated 499 // FIXME: This is a temporary flag and should be removed once accelerated
481 // overflow scroll is ready (crbug.com/254111). 500 // overflow scroll is ready (crbug.com/254111).
482 bool RenderLayer::compositorDrivenAcceleratedScrollingEnabled() const 501 bool RenderLayer::compositorDrivenAcceleratedScrollingEnabled() const
483 { 502 {
484 if (!acceleratedCompositingForOverflowScrollEnabled()) 503 if (!acceleratedCompositingForOverflowScrollEnabled())
485 return false; 504 return false;
486 505
487 const Settings* settings = renderer()->document().settings(); 506 const Settings* settings = renderer()->document().settings();
488 return settings && settings->isCompositorDrivenAcceleratedScrollingEnabled() ; 507 return settings && settings->isCompositorDrivenAcceleratedScrollingEnabled() ;
489 } 508 }
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 { 2050 {
2032 RenderBox* box = renderBox(); 2051 RenderBox* box = renderBox();
2033 2052
2034 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling 2053 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling
2035 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar))) 2054 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar)))
2036 return false; 2055 return false;
2037 2056
2038 return isComposited() && backing()->scrollingLayer(); 2057 return isComposited() && backing()->scrollingLayer();
2039 } 2058 }
2040 2059
2041 bool RenderLayer::needsCompositedScrolling() const 2060 bool RenderLayer::adjustForForceCompositedScrollingMode(bool value) const
2042 {
2043 if (!compositorDrivenAcceleratedScrollingEnabled())
2044 return needsToBeStackingContainer();
2045 if (FrameView* frameView = renderer()->view()->frameView())
2046 return frameView->containsScrollableArea(scrollableArea());
2047 return false;
2048 }
2049
2050 bool RenderLayer::needsToBeStackingContainer() const
2051 { 2061 {
2052 switch (m_forceNeedsCompositedScrolling) { 2062 switch (m_forceNeedsCompositedScrolling) {
2053 case DoNotForceCompositedScrolling: 2063 case DoNotForceCompositedScrolling:
2054 return m_needsCompositedScrolling; 2064 return value;
2055 case CompositedScrollingAlwaysOn: 2065 case CompositedScrollingAlwaysOn:
2056 return true; 2066 return true;
2057 case CompositedScrollingAlwaysOff: 2067 case CompositedScrollingAlwaysOff:
2058 return false; 2068 return false;
2059 } 2069 }
2060 2070
2061 ASSERT_NOT_REACHED(); 2071 ASSERT_NOT_REACHED();
2062 return m_needsCompositedScrolling; 2072 return value;
2073 }
2074
2075 bool RenderLayer::needsCompositedScrolling() const
2076 {
2077 return adjustForForceCompositedScrollingMode(m_needsCompositedScrolling);
2078 }
2079
2080 bool RenderLayer::needsToBeStackingContainer() const
2081 {
2082 return adjustForForceCompositedScrollingMode(m_needsToBeStackingContainer);
2063 } 2083 }
2064 2084
2065 bool RenderLayer::hasScrollParent() const 2085 bool RenderLayer::hasScrollParent() const
2066 { 2086 {
2067 if (!compositorDrivenAcceleratedScrollingEnabled()) 2087 if (!useCompositorDrivenAcceleratedScrolling())
2068 return false; 2088 return false;
2069 2089
2070 // A layer scrolls with its containing block. So to find the overflow scroll ing layer 2090 // A layer scrolls with its containing block. So to find the overflow scroll ing layer
2071 // that we scroll with respect to, we must ascend the layer tree until we re ach the 2091 // that we scroll with respect to, we must ascend the layer tree until we re ach the
2072 // first overflow scrolling div at or above our containing block. I will ref er to this 2092 // first overflow scrolling div at or above our containing block. I will ref er to this
2073 // layer as our 'scrolling ancestor'. 2093 // layer as our 'scrolling ancestor'.
2074 // 2094 //
2075 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling 2095 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling
2076 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order 2096 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order
2077 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking 2097 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking
2078 // context, then we know that in the stacking tree, we will not be in the su btree rooted at 2098 // context, then we know that in the stacking tree, we will not be in the su btree rooted at
2079 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must 2099 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must
2080 // be a composited layer since the compositor will need to take special meas ures to ensure 2100 // be a composited layer since the compositor will need to take special meas ures to ensure
2081 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote. 2101 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote.
2082 RenderLayer* scrollParent = ancestorScrollingLayer(); 2102 RenderLayer* scrollParent = ancestorScrollingLayer();
2083 2103
2084 if (!scrollParent || scrollParent->isStackingContext()) 2104 if (!scrollParent || scrollParent->isStackingContext())
Ian Vollick 2013/09/06 02:01:05 Could this be changed to (scrollParent->needsToBeS
hartmanng 2013/09/06 20:18:36 That would exclude stacking contexts, are you sure
2085 return false; 2105 return false;
2086 2106
2087 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already 2107 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already
2088 // be composited due to an overflow scrolling parent, so we don't need to. 2108 // be composited due to an overflow scrolling parent, so we don't need to.
2089 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) { 2109 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) {
2090 if (ancestor->isStackingContext()) 2110 if (ancestor->isStackingContext())
Ian Vollick 2013/09/06 02:01:05 Should this be ancestor->stackingContainer()?
hartmanng 2013/09/06 20:18:36 yeah, I think so. Done.
2091 return false; 2111 return false;
2092 } 2112 }
2093 2113
2094 return true; 2114 return true;
2095 } 2115 }
2096 2116
2097 void RenderLayer::updateNeedsCompositedScrolling() 2117 void RenderLayer::updateNeedsCompositedScrolling()
2098 { 2118 {
2099 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); 2119 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling");
2100 2120
2101 updateCanBeStackingContainer(); 2121 updateCanBeStackingContainer();
2102 updateDescendantDependentFlags(); 2122 updateDescendantDependentFlags();
2103 2123
2104 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); 2124 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea()));
2105 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() 2125 const bool needsToBeStackingContainer = acceleratedCompositingForOverflowScr ollEnabled()
2106 && canBeStackingContainer() 2126 && canBeStackingContainer()
2107 && !hasUnclippedDescendant(); 2127 && !hasUnclippedDescendant();
2108 2128
2129 const bool needsToBeStackingContainerDidChange = setNeedsToBeStackingContain er(needsToBeStackingContainer);
2130
2131 const bool needsCompositedScrolling = needsToBeStackingContainer
2132 || compositorDrivenAcceleratedScrollingEnabled();
2133
2109 // We gather a boolean value for use with Google UMA histograms to 2134 // We gather a boolean value for use with Google UMA histograms to
2110 // quantify the actual effects of a set of patches attempting to 2135 // quantify the actual effects of a set of patches attempting to
2111 // relax composited scrolling requirements, thereby increasing the 2136 // relax composited scrolling requirements, thereby increasing the
2112 // number of composited overflow divs. 2137 // number of composited overflow divs.
2113 if (acceleratedCompositingForOverflowScrollEnabled()) 2138 if (acceleratedCompositingForOverflowScrollEnabled())
2114 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrollin g", needsCompositedScrolling, 2); 2139 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrollin g", needsCompositedScrolling, 2);
2115 2140
2116 setNeedsCompositedScrolling(needsCompositedScrolling); 2141 const bool needsCompositedScrollingDidChange = setNeedsCompositedScrolling(n eedsCompositedScrolling);
2142
2143 if (needsToBeStackingContainerDidChange || needsCompositedScrollingDidChange ) {
2144 // Note, the z-order lists may need to be rebuilt, but our code guarante es
2145 // that we have not affected stacking, so we will not dirty
2146 // m_canBePromotedToStackingContainer for either us or our stacking cont ext
2147 // or container.
2148 didUpdateNeedsCompositedScrolling();
2149 }
2117 } 2150 }
2118 2151
2119 enum CompositedScrollingHistogramBuckets { 2152 enum CompositedScrollingHistogramBuckets {
2120 IsScrollableAreaBucket = 0, 2153 IsScrollableAreaBucket = 0,
2121 NeedsToBeStackingContainerBucket = 1, 2154 NeedsToBeStackingContainerBucket = 1,
2122 WillUseCompositedScrollingBucket = 2, 2155 WillUseCompositedScrollingBucket = 2,
2123 CompositedScrollingHistogramMax = 3 2156 CompositedScrollingHistogramMax = 3
2124 }; 2157 };
2125 2158
2126 void RenderLayer::setNeedsCompositedScrolling(bool needsCompositedScrolling) 2159 bool RenderLayer::setNeedsCompositedScrolling(bool needsCompositedScrolling)
2127 { 2160 {
2128 if (m_needsCompositedScrolling == needsCompositedScrolling) 2161 if (m_needsCompositedScrolling == needsCompositedScrolling)
2129 return; 2162 return false;
2130
2131 // Count the total number of RenderLayers which need to be stacking
2132 // containers some point. This should be recorded at most once per
2133 // RenderLayer, so we check m_needsCompositedScrollingHasBeenRecorded.
2134 if (acceleratedCompositingForOverflowScrollEnabled() && !m_needsCompositedSc rollingHasBeenRecorded) {
2135 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", N eedsToBeStackingContainerBucket, CompositedScrollingHistogramMax);
2136 m_needsCompositedScrollingHasBeenRecorded = true;
2137 }
2138 2163
2139 // Count the total number of RenderLayers which need composited scrolling at 2164 // Count the total number of RenderLayers which need composited scrolling at
2140 // some point. This should be recorded at most once per RenderLayer, so we 2165 // some point. This should be recorded at most once per RenderLayer, so we
2141 // check m_willUseCompositedScrollingHasBeenRecorded. 2166 // check m_willUseCompositedScrollingHasBeenRecorded.
2142 //
2143 // FIXME: Currently, this computes the exact same value as the above.
2144 // However, it will soon be expanded to cover more than just stacking
2145 // containers (see crbug.com/249354). When this happens, we should see a
2146 // spike in "WillUseCompositedScrolling", while "NeedsToBeStackingContainer"
2147 // will remain relatively static.
2148 if (acceleratedCompositingForOverflowScrollEnabled() && !m_willUseComposited ScrollingHasBeenRecorded) { 2167 if (acceleratedCompositingForOverflowScrollEnabled() && !m_willUseComposited ScrollingHasBeenRecorded) {
2149 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", W illUseCompositedScrollingBucket, CompositedScrollingHistogramMax); 2168 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", W illUseCompositedScrollingBucket, CompositedScrollingHistogramMax);
2150 m_willUseCompositedScrollingHasBeenRecorded = true; 2169 m_willUseCompositedScrollingHasBeenRecorded = true;
2151 } 2170 }
2152 2171
2153 m_needsCompositedScrolling = needsCompositedScrolling; 2172 m_needsCompositedScrolling = needsCompositedScrolling;
2154 2173
2155 // Note, the z-order lists may need to be rebuilt, but our code guarantees 2174 return true;
2156 // that we have not affected stacking, so we will not dirty 2175 }
2157 // m_canBePromotedToStackingContainer for either us or our stacking context 2176
2158 // or container. 2177 bool RenderLayer::setNeedsToBeStackingContainer(bool needsToBeStackingContainer)
2159 didUpdateNeedsCompositedScrolling(); 2178 {
2179 if (m_needsToBeStackingContainer == needsToBeStackingContainer)
2180 return false;
2181
2182 // Count the total number of RenderLayers which need to be stacking
2183 // containers some point. This should be recorded at most once per
2184 // RenderLayer, so we check m_needsToBeStackingContainerHasBeenRecorded.
2185 if (acceleratedCompositingForOverflowScrollEnabled() && !m_needsToBeStacking ContainerHasBeenRecorded) {
2186 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", N eedsToBeStackingContainerBucket, CompositedScrollingHistogramMax);
2187 m_needsToBeStackingContainerHasBeenRecorded = true;
2188 }
2189
2190 m_needsToBeStackingContainer = needsToBeStackingContainer;
2191
2192 return true;
2160 } 2193 }
2161 2194
2162 void RenderLayer::setForceNeedsCompositedScrolling(RenderLayer::ForceNeedsCompos itedScrollingMode mode) 2195 void RenderLayer::setForceNeedsCompositedScrolling(RenderLayer::ForceNeedsCompos itedScrollingMode mode)
2163 { 2196 {
2164 if (m_forceNeedsCompositedScrolling == mode) 2197 if (m_forceNeedsCompositedScrolling == mode)
2165 return; 2198 return;
2166 2199
2167 m_forceNeedsCompositedScrolling = mode; 2200 m_forceNeedsCompositedScrolling = mode;
2168 didUpdateNeedsCompositedScrolling(); 2201 didUpdateNeedsCompositedScrolling();
2169 } 2202 }
(...skipping 4247 matching lines...) Expand 10 before | Expand all | Expand 10 after
6417 } 6450 }
6418 } 6451 }
6419 6452
6420 void showLayerTree(const WebCore::RenderObject* renderer) 6453 void showLayerTree(const WebCore::RenderObject* renderer)
6421 { 6454 {
6422 if (!renderer) 6455 if (!renderer)
6423 return; 6456 return;
6424 showLayerTree(renderer->enclosingLayer()); 6457 showLayerTree(renderer->enclosingLayer());
6425 } 6458 }
6426 #endif 6459 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698