Skip to content

Commit c6cbfed

Browse files
https://bugs.webkit.org/show_bug.cgi?id=99768
We should limit the tile cache coverage when a page can't take advantage of fast tile scrolling anyway Reviewed by Simon Fraser. When sites can't use fast-scrolling, there is no need to inflate the tile cache. In fact, we get a performance boost by keeping it small on painting-intensive sites. Instead of just looking a whether or not the FrameView canHaveScrollbar(), consult shouldUpdateScrollLayerPositionOnMainThread(). * page/FrameView.cpp: (WebCore::FrameView::performPostLayoutTasks): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::RenderLayerBacking): Expose shouldUpdateScrollLayerPositionOnMainThread(). * page/scrolling/ScrollingCoordinator.cpp: (WebCore::ScrollingCoordinator::hasNonLayerFixedObjects): (WebCore::ScrollingCoordinator::shouldUpdateScrollLayerPositionOnMainThread): (WebCore): (WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread): * page/scrolling/ScrollingCoordinator.h: (ScrollingCoordinator): Bug fix. Should be bitwise and. * platform/graphics/ca/mac/TileCache.mm: (WebCore::TileCache::tileCoverageRect): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131939 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 6df1a80 commit c6cbfed

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

Source/WebCore/ChangeLog

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
2012-10-19 Beth Dakin <[email protected]>
2+
3+
https://bugs.webkit.org/show_bug.cgi?id=99768
4+
We should limit the tile cache coverage when a page can't take
5+
advantage of fast tile scrolling anyway
6+
7+
Reviewed by Simon Fraser.
8+
9+
When sites can't use fast-scrolling, there is no need to inflate the
10+
tile cache. In fact, we get a performance boost by keeping it small
11+
on painting-intensive sites.
12+
13+
Instead of just looking a whether or not the FrameView
14+
canHaveScrollbar(), consult
15+
shouldUpdateScrollLayerPositionOnMainThread().
16+
* page/FrameView.cpp:
17+
(WebCore::FrameView::performPostLayoutTasks):
18+
* rendering/RenderLayerBacking.cpp:
19+
(WebCore::RenderLayerBacking::RenderLayerBacking):
20+
21+
Expose shouldUpdateScrollLayerPositionOnMainThread().
22+
* page/scrolling/ScrollingCoordinator.cpp:
23+
(WebCore::ScrollingCoordinator::hasNonLayerFixedObjects):
24+
(WebCore::ScrollingCoordinator::shouldUpdateScrollLayerPositionOnMainThread):
25+
(WebCore):
26+
(WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread):
27+
* page/scrolling/ScrollingCoordinator.h:
28+
(ScrollingCoordinator):
29+
30+
Bug fix. Should be bitwise and.
31+
* platform/graphics/ca/mac/TileCache.mm:
32+
(WebCore::TileCache::tileCoverageRect):
33+
134
2012-10-19 Mark Lam <[email protected]>
235

336
Added WTF::StackStats mechanism.

Source/WebCore/page/FrameView.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2500,8 +2500,14 @@ void FrameView::performPostLayoutTasks()
25002500
}
25012501

25022502
#if USE(ACCELERATED_COMPOSITING)
2503-
if (TiledBacking* tiledBacking = this->tiledBacking())
2504-
tiledBacking->setTileCoverage(canHaveScrollbars() ? TiledBacking::CoverageForScrolling : TiledBacking::CoverageForVisibleArea);
2503+
if (TiledBacking* tiledBacking = this->tiledBacking()) {
2504+
if (page) {
2505+
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
2506+
bool shouldLimitTileCoverage = !canHaveScrollbars() || scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread();
2507+
tiledBacking->setTileCoverage(shouldLimitTileCoverage ? TiledBacking::CoverageForVisibleArea : TiledBacking::CoverageForScrolling);
2508+
}
2509+
}
2510+
}
25052511
#endif
25062512

25072513
scrollToAnchor();

Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
258258
}
259259
#endif
260260

261-
bool ScrollingCoordinator::hasNonLayerFixedObjects(FrameView* frameView)
261+
bool ScrollingCoordinator::hasNonLayerFixedObjects(FrameView* frameView) const
262262
{
263263
const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
264264
if (!viewportConstrainedObjects)
@@ -279,7 +279,7 @@ bool ScrollingCoordinator::hasNonLayerFixedObjects(FrameView* frameView)
279279
#endif
280280
}
281281

282-
void ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread()
282+
MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() const
283283
{
284284
FrameView* frameView = m_page->mainFrame()->view();
285285

@@ -296,7 +296,12 @@ void ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread()
296296
if (m_page->mainFrame()->document()->isImageDocument())
297297
mainThreadScrollingReasons |= IsImageDocument;
298298

299-
setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReasons);
299+
return mainThreadScrollingReasons;
300+
}
301+
302+
void ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread()
303+
{
304+
setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReasons());
300305
}
301306

302307
void ScrollingCoordinator::setForceMainThreadScrollLayerPositionUpdates(bool forceMainThreadScrollLayerPositionUpdates)

Source/WebCore/page/scrolling/ScrollingCoordinator.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
127127
IsImageDocument = 1 << 4
128128
};
129129

130+
MainThreadScrollingReasons mainThreadScrollingReasons() const;
131+
bool shouldUpdateScrollLayerPositionOnMainThread() const { return mainThreadScrollingReasons() != 0; }
132+
130133
// These virtual functions are currently unique to Chromium's WebLayer approach. Their meaningful
131134
// implementations are in ScrollingCoordinatorChromium.
132135
virtual void frameViewHorizontalScrollbarLayerDidChange(FrameView*, GraphicsLayer*) { }
@@ -148,7 +151,7 @@ class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
148151
virtual void recomputeWheelEventHandlerCountForFrameView(FrameView*) { }
149152
virtual void setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons) { }
150153

151-
bool hasNonLayerFixedObjects(FrameView*);
154+
bool hasNonLayerFixedObjects(FrameView*) const;
152155
void updateShouldUpdateScrollLayerPositionOnMainThread();
153156

154157
bool m_forceMainThreadScrollLayerPositionUpdates;

Source/WebCore/platform/graphics/ca/mac/TileCache.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ - (void)setAcceleratesDrawing:(BOOL)flag;
315315
// Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
316316
// These values were chosen because it's more common to have tall pages and to scroll vertically,
317317
// so we keep more tiles above and below the current area.
318-
if (m_tileCoverage && CoverageForHorizontalScrolling)
318+
if (m_tileCoverage & CoverageForHorizontalScrolling)
319319
tileCoverageRect.inflateX(tileCoverageRect.width() / 2);
320320

321-
if (m_tileCoverage && CoverageForVerticalScrolling)
321+
if (m_tileCoverage & CoverageForVerticalScrolling)
322322
tileCoverageRect.inflateY(tileCoverageRect.height());
323323
}
324324

Source/WebCore/rendering/RenderLayerBacking.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer* layer)
125125
if (TiledBacking* tiledBacking = m_graphicsLayer->tiledBacking()) {
126126
Frame* frame = renderer()->frame();
127127
tiledBacking->setIsInWindow(page->isOnscreen());
128-
tiledBacking->setTileCoverage(frame->view()->canHaveScrollbars() ? TiledBacking::CoverageForScrolling : TiledBacking::CoverageForVisibleArea);
128+
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
129+
bool shouldLimitTileCoverage = !frame->view()->canHaveScrollbars() || scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread();
130+
tiledBacking->setTileCoverage(shouldLimitTileCoverage ? TiledBacking::CoverageForVisibleArea : TiledBacking::CoverageForScrolling);
131+
}
129132
tiledBacking->setScrollingPerformanceLoggingEnabled(frame->settings() && frame->settings()->scrollingPerformanceLoggingEnabled());
130133
}
131134
}

0 commit comments

Comments
 (0)