[CoordGraphics] Simplify CoordinatedGraphicsLayer's content buffer updates
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 14:19:52 +0000 (14:19 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 14:19:52 +0000 (14:19 +0000)
commit80a6d6b482c39b25c923465a24261fc334daefc7
tree6b1c07a345b2ed60d3c101ee68344472885dd762
parent1cf5b45800cc1e635e39f144e7033ab7144c05f1
[CoordGraphics] Simplify CoordinatedGraphicsLayer's content buffer updates
https://bugs.webkit.org/show_bug.cgi?id=179972

Reviewed by Carlos Garcia Campos.

Source/WebCore:

During layer flushes, when a CoordinatedGraphicsLayer's tiled backing store
has dirty tiles that need to be updated, the following chain of calls would
be invoked to perform the painting, starting in
CoordinatedGraphicsLayer::updateContentBuffers():
|- CoordinatedGraphicsLayer::updateContentBuffers()
 |- TiledBackingStore::updateTileBuffers()
  |- Tile::updateBackBuffer()
   |- CoordinatedGraphicsLayer::paintToSurface()
    |- CompositingCoordinator::paintToSurface()
     |- UpdateAtlas::paintOnAvailableBuffer()
      |- ThreadSafeCoordinatedSurface::paintToSurface()
       |- Tile::paintToSurfaceContext()
        |- CoordinatedGraphicsLayer::tiledBackingStorePaint()
         |- GraphicsLayer::paintGraphicsLayerContents()

That's a bit much.

In CoordinatedGraphicsLayer::updateContentBuffers(), we now first retrieve
all the dirty layers in our TiledBackingStore. We then iterate through them,
first establishing their ID and then retrieving an available CoordinatedBuffer
that we can use for painting. The CoordinatedBuffer is retrieved through
CompositingCoordinator, which is still caching these buffers via UpdateAtlas
objects.

With a CoordinatedBuffer available, we can then proceed with painting. The
painting context has to be properly set up to paint into the correct area of
the given buffer, and the alpha channel, if necessary, has to be addressed.
After properly positioning and scaling ourselves on the given context, we
can proceed with the GraphicsLayer::paintGraphicsLayerContents() call.

What's left is filling out the missing SurfaceUpdateInfo information which is
then passed to the updateTile() method that properly registers the tile
update we've just performed. The tile itself is marked clean. After the
iteration, we call the didUpdateTileBuffers() method in case any successful
tile update was indeed performed, incrementing the repaint counter.

That's it -- we clipped 8 calls from the call chain. We can now also remove
the CoordinatedBuffer::Client interface, as well as slim down the
TiledBackingStore interface. The Tile class is cleaned up a bit, with methods
shifted into a more sensible order.

No new tests -- no change in functionality.

* platform/graphics/texmap/coordinated/CoordinatedBuffer.cpp:
* platform/graphics/texmap/coordinated/CoordinatedBuffer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::didUpdateTileBuffers):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStorePaint): Deleted.
(WebCore::CoordinatedGraphicsLayer::paintToSurface): Deleted.
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/graphics/texmap/coordinated/Tile.cpp:
(WebCore::Tile::ensureTileID):
(WebCore::Tile::isDirty const):
(WebCore::Tile::invalidate):
(WebCore::Tile::markClean):
(WebCore::Tile::updateBackBuffer): Deleted.
(WebCore::Tile::paintToSurfaceContext): Deleted.
* platform/graphics/texmap/coordinated/Tile.h:
(WebCore::Tile::tileID const):
(WebCore::Tile::dirtyRect const):
* platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::dirtyTiles):
(WebCore::TiledBackingStore::updateTileBuffers): Deleted.
* platform/graphics/texmap/coordinated/TiledBackingStore.h:
* platform/graphics/texmap/coordinated/TiledBackingStoreClient.h:

Source/WebKit:

In CompositingCoordinator, add the getCoordinatedBuffer() method, replacing
paintToSurface(). The new method traverses the list of UpdateAtlases and
returns any CoordinatedBuffer object that was free to use. If none exist,
a new UpdateAtlas object is created, and its CoordinatedBuffer is returned.

In  UpdateAtlas, the paintOnAvailableBuffer() method is replaced with
getCoordinatedBuffer(). The latter allocates the necessary area but then
returns a reference to the CoordinatedBuffer buffer, along with the atlas ID
and the allocated rectangle information, and does not invoke any painting
operation like paintOnAvailableBuffer() did.

* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
(WebKit::CompositingCoordinator::getCoordinatedBuffer):
(WebKit::CompositingCoordinator::paintToSurface): Deleted.
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
(WebKit::UpdateAtlas::getCoordinatedBuffer):
(WebKit::UpdateAtlas::paintOnAvailableBuffer): Deleted.
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBuffer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBuffer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/Tile.cpp
Source/WebCore/platform/graphics/texmap/coordinated/Tile.h
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.cpp
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.h
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h