Use larger tiles when possible to reduce per-tile painting overhead
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2016 02:26:49 +0000 (02:26 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2016 02:26:49 +0000 (02:26 +0000)
commitb09825d84f9057f3cb54ef07ac868d599da3f74b
tree2988c9798dae671e78341727e20257bcda2972fe
parentced93a6fb50a3fd8d75dc6530dc423ae9c73f71f
Use larger tiles when possible to reduce per-tile painting overhead
https://bugs.webkit.org/show_bug.cgi?id=154985
rdar://problem/23635219

Reviewed by Tim Horton.
Source/WebCore:

There's no reason to use lots of 512x512 tiles on a non-scrollable page. We can reduce
per-tile painting overhead by using one big tile. On vertically scrolling pages, we
can also use wide tiles to reduce tile-crossing when painting. Have FrameView tell
the TiledBacking about scrollability, allowing TileController to make tile size decisions.

Change the "giant tile" code path to just return whether Settings says we're in giant
tile mode, so that tile size decisions can be made in TileController.

TileController now stores a single margin size, and a per-edge margin flag rather than a size
per edge. It computes tile size based on scrollability, but adjusts tile size with some
hysteresis to avoid size thrashing for content that frequently resizes the document (e.g.
some performance tests).

TileGrid stores a copy of the tile size, so that it remains unchanged from one revalidate
to the next, and the grid can detect when the tile size changes, since it needs to throw away
all tiles in that case.

Tests: tiled-drawing/tile-size-both-scrollable.html
       tiled-drawing/tile-size-horizontally-scrollable.html
       tiled-drawing/tile-size-unscrollable.html
       tiled-drawing/tile-size-vertically-scrollable.html

* WebCore.xcodeproj/project.pbxproj:
* page/FrameView.cpp:
(WebCore::FrameView::addedOrRemovedScrollbar):
(WebCore::FrameView::willStartLiveResize): Tell the tile backing when live resize starts and stops.
(WebCore::FrameView::willEndLiveResize):
* platform/graphics/EdgeSet.h: Added. Template class that just stores some value
per edge.
(WebCore::EdgeSet::EdgeSet):
(WebCore::EdgeSet::top):
(WebCore::EdgeSet::setTop):
(WebCore::EdgeSet::right):
(WebCore::EdgeSet::setRight):
(WebCore::EdgeSet::bottom):
(WebCore::EdgeSet::setBottom):
(WebCore::EdgeSet::left):
(WebCore::EdgeSet::setLeft):
(WebCore::EdgeSet::operator==):
(WebCore::EdgeSet::operator!=):
* platform/graphics/GraphicsLayerClient.h: Rather than have the client return the
tile size, have it return whether we're in giant tile mode.
(WebCore::GraphicsLayerClient::useGiantTiles):
(WebCore::GraphicsLayerClient::tileSize): Deleted.
* platform/graphics/TiledBacking.h:
(WebCore::defaultTileSize): Deleted.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::platformCALayerUseGiantTiles):
(WebCore::GraphicsLayerCA::platformCALayerTileSize): Deleted.
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerUseGiantTiles):
(WebCore::PlatformCALayerClient::platformCALayerTileSize): Deleted.
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::TileController):
(WebCore::TileController::setScrollability):
(WebCore::TileController::willStartLiveResize):
(WebCore::TileController::didEndLiveResize):
(WebCore::TileController::tileSize):
(WebCore::TileController::setHasMargins):
(WebCore::TileController::setMarginSize):
(WebCore::TileController::hasMargins):
(WebCore::TileController::hasHorizontalMargins):
(WebCore::TileController::hasVerticalMargins):
(WebCore::TileController::topMarginHeight):
(WebCore::TileController::bottomMarginHeight):
(WebCore::TileController::leftMarginWidth):
(WebCore::TileController::rightMarginWidth):
(WebCore::TileController::setTileMargins): Deleted.
* platform/graphics/ca/TileController.h:
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::TileGrid):
(WebCore::TileGrid::setNeedsDisplayInRect):
(WebCore::TileGrid::rectForTileIndex):
(WebCore::TileGrid::getTileIndexRangeForRect):
(WebCore::TileGrid::removeAllTiles):
(WebCore::TileGrid::revalidateTiles):
* platform/graphics/ca/TileGrid.h:
(WebCore::TileGrid::tileSize):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::setTiledBackingHasMargins):
(WebCore::RenderLayerBacking::useGiantTiles):
(WebCore::RenderLayerBacking::tileSize): Deleted.
* rendering/RenderLayerBacking.h:

Source/WebKit2:

Do a bit of #include cleanup.

* Shared/mac/RemoteLayerBackingStore.mm:
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
* WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
* WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:

LayoutTests:

Rebaseline tests with new tile sizes. Add new tests that explicitly test tile size on
pages with different scrollability.

* tiled-drawing/background-transparency-toggle-expected.txt:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-background-no-image-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-body-background-body-layer-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-body-background-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-body-background-opacity-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-body-background-positioned-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-html-background-expected.txt:
* tiled-drawing/scrolling/fixed-background/fixed-non-propagated-body-background-expected.txt:
* tiled-drawing/tile-coverage-after-scroll-expected.txt:
* tiled-drawing/tile-coverage-after-scroll-speculative-expected.txt:
* tiled-drawing/tile-coverage-scroll-to-bottom-expected.txt:
* tiled-drawing/tile-coverage-slow-scrolling-expected.txt:
* tiled-drawing/tile-coverage-speculative-expected.txt:
* tiled-drawing/tile-size-both-scrollable-expected.txt: Copied from LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-background-no-image-expected.txt.
* tiled-drawing/tile-size-both-scrollable.html: Added.
* tiled-drawing/tile-size-horizontally-scrollable-expected.txt: Copied from LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-background-no-image-expected.txt.
* tiled-drawing/tile-size-horizontally-scrollable.html: Added.
* tiled-drawing/tile-size-unscrollable-expected.txt: Added.
* tiled-drawing/tile-size-unscrollable.html: Added.
* tiled-drawing/tile-size-vertically-scrollable-expected.txt: Copied from LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-background-no-image-expected.txt.
* tiled-drawing/tile-size-vertically-scrollable.html: Added.
* tiled-drawing/visible-rect-content-inset-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
52 files changed:
LayoutTests/ChangeLog
LayoutTests/tiled-drawing/background-transparency-toggle-expected.txt
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-background-no-image-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-body-background-body-layer-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-body-background-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-body-background-opacity-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-body-background-positioned-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-html-background-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed-background/fixed-non-propagated-body-background-expected.txt
LayoutTests/tiled-drawing/scrolling/fixed/four-bars-zoomed-expected.txt
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow-expected.txt
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders-expected.txt
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-expected.txt
LayoutTests/tiled-drawing/tile-coverage-after-scroll-expected.txt
LayoutTests/tiled-drawing/tile-coverage-after-scroll-speculative-expected.txt
LayoutTests/tiled-drawing/tile-coverage-scroll-to-bottom-expected.txt
LayoutTests/tiled-drawing/tile-coverage-slow-scrolling-expected.txt
LayoutTests/tiled-drawing/tile-coverage-speculative-expected.txt
LayoutTests/tiled-drawing/tile-size-both-scrollable-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-both-scrollable.html [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-horizontally-scrollable-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-horizontally-scrollable.html [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-unscrollable-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-unscrollable.html [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-vertically-scrollable-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/tile-size-vertically-scrollable.html [new file with mode: 0644]
LayoutTests/tiled-drawing/visible-rect-content-inset-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/EdgeSet.h [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/IntSize.cpp
Source/WebCore/platform/graphics/IntSize.h
Source/WebCore/platform/graphics/TiledBacking.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
Source/WebCore/platform/graphics/ca/TileController.cpp
Source/WebCore/platform/graphics/ca/TileController.h
Source/WebCore/platform/graphics/ca/TileGrid.cpp
Source/WebCore/platform/graphics/ca/TileGrid.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h