WebKit Bugzilla
Attachment 347627 Details for
Bug 188693
: [CoordGraphics] Switch to Nicosia::CompositionLayer state tracking
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188693-20180821133819.patch (text/plain), 72.70 KB, created by
Zan Dobersek
on 2018-08-21 04:38:21 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2018-08-21 04:38:21 PDT
Size:
72.70 KB
patch
obsolete
>Subversion Revision: 235105 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d33ed0a0891aec5fc92a63f8853ad821e4b28b42..198f94233acd650ffd3d6d700efd775bee798461 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,96 @@ >+2018-08-21 Zan Dobersek <zdobersek@igalia.com> >+ >+ [CoordGraphics] Switch to Nicosia::CompositionLayer state tracking >+ https://bugs.webkit.org/show_bug.cgi?id=188693 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Populate Nicosia::CompositionLayer with additional LayerState member >+ objects. For now we're using pending, staging and committed states, >+ though it might be possible to narrow down these to just two. >+ >+ Pending state contains state that will be moved to staging during the >+ final steps of the next layer flush. flushState() method accumulates all >+ state changes in the staging state, and also allows the caller to >+ additionally perform flushing operations that are specific to backing >+ store, image backing or content layer containers. >+ >+ commitState() method moves staging state over into the committed state, >+ again allowing user to pass a functor that receives the just-committed >+ state and apply it to their composition engine. >+ >+ Changes in state objects are done under a thread-safe lock. This might >+ not be completely necessary at this point, but will be useful when >+ additonal layer state updates will be coming from e.g. the scrolling >+ thread. It might also make sense to tie in this lock use with the >+ Nicosia::Scene lock in the future. >+ >+ Nicosia::ContentLayerTextureMapperImpl is modified slightly to allow >+ determining during flushes whether an update is pending. This is >+ necessary for a special case in ThreadedCompositor where content (i.e. >+ platform) layers like WebGL or video require an additional level of >+ scene update coordination. This complete special case has to go through >+ another review to see whether it's still necessary. Ideally we would be >+ able to remove it. >+ >+ CoordinatedGraphicsLayer is finally switched over to using >+ Nicosia layer objects for state updates of any kind. This patch only >+ adds all the necessary bits, but doesn't yet remove any of the existing >+ code (but rather disables it temporarily, before it's removed). >+ >+ Updating of simple state values is already in place. For backing stores, >+ the flushCompositingStateForThisLayerOnly() method now takes care of >+ preparing the backing store object if necessary as per layer state, >+ while the updateContentBuffers() method is switched to operate with >+ TiledBackingStore objects now kept on the BackingStoreTextureMapperImpl >+ instance associated with that backing store. Helper methods like >+ adjustContentsScale() and createBackingStore(), only called from the >+ updateContentBuffers() method, are removed and the code there inlined. >+ >+ For image-backed layers, the update is now done directly in >+ the flushCompositingStateForThisLayerOnly() method, if necessary. The >+ helper syncImageBacking() method is commented out in order to prevent >+ double-painting of image buffers for now, but all this (along with the >+ CoordinatedImageBacking logic in CompositingCoordinator) will be removed >+ later. >+ >+ For layers backed by platform layer objects, integration is relatively >+ simple. setContentsToPlatformLayer() is changed to properly handle any >+ passed-in platform layer object, and updatePlatformLayer() invokes the >+ swapBuffersIfNeeded() method on the ContentLayerTextureMapperImpl object >+ during each flush, if necessary. >+ >+ In order to ensure any Nicosia-specific state update properly triggers >+ a composition update, m_nicosia.performLayerUpdate is added and flipped >+ to true during the flush in case of any state change. This then triggers >+ a layer sync in the CompositingCoordinator object when the >+ syncPendingStateChangesIncludingSubLayers() method is called. While no >+ old-style layer state update is provided, it causes the necessary >+ synchronization step that properly picks up the Nicosia-provided state >+ changes. Once the old-style layer state tracking is removed, this method >+ of update triggering will have to be updated as well. >+ >+ * platform/graphics/nicosia/NicosiaPlatformLayer.h: >+ (Nicosia::CompositionLayer::flushState): >+ (Nicosia::CompositionLayer::commitState): >+ (Nicosia::CompositionLayer::accessCommitted): >+ * platform/graphics/nicosia/NicosiaScene.h: >+ * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: >+ (Nicosia::ContentLayerTextureMapperImpl::flushUpdate): >+ * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h: >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: >+ (WebCore::CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer): >+ (WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay): >+ (WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer): >+ (WebCore::CoordinatedGraphicsLayer::updatePlatformLayer): >+ (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly): >+ (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers): >+ (WebCore::CoordinatedGraphicsLayer::updateContentBuffers): >+ (WebCore::CoordinatedGraphicsLayer::purgeBackingStores): >+ (WebCore::CoordinatedGraphicsLayer::adjustContentsScale): Deleted. >+ (WebCore::CoordinatedGraphicsLayer::createBackingStore): Deleted. >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h: >+ > 2018-08-20 Devin Rousso <drousso@apple.com> > > Web Inspector: allow breakpoints to be set for specific event listeners >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 721fd3596019389cba1ffdc864323d255afb219f..c632d0ede73882d872acb684024f77ff7b493379 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,82 @@ >+2018-08-21 Zan Dobersek <zdobersek@igalia.com> >+ >+ [CoordGraphics] Switch to Nicosia::CompositionLayer state tracking >+ https://bugs.webkit.org/show_bug.cgi?id=188693 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Switch CoordinatedGraphicsScene to utilizing Nicosia::CompositionLayer >+ objects for state updates of the TextureMapper layer tree. >+ >+ CoordinatedGraphicsScene::paintToCurrentGLContext() now calls >+ updateSceneState() at the beginning. This is a new method that manages >+ all updates for a given Nicosia::Scene instance. Any removed layers >+ have their composition-side state cleaned up, and the current set of >+ layers is then iterated to ensure and update the corresponding >+ TextureMapperLayer objects. >+ >+ Layers with any backing (painted backing store, platform-layer or image >+ content) are temporarly stored for updating outside of mutex-controlled >+ scene update. Performing all other state updates outside of this mutex >+ area will be investigated at a later point. >+ >+ We then iterate over vectors for each layer backing, gathering any >+ affected CoordinatedBackingStore or TextureMapperPlatformLayerProxy >+ objects that we have to update. >+ >+ This drops a bunch of member variables and helper methods off the >+ CoordinatedGraphicsScene class. The applyStateChanges() method will be >+ further simplified in the future. coordinateUpdateCompletionWithClient >+ logic in ThreadedCompositor should be checked to see whether it still >+ addresses any real-life problem, because at the moment it imposes a few >+ additional operations in terms of scene updates that we could really do >+ without. This will be checked later and removed if possible. >+ >+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: >+ (WebKit::CoordinatedGraphicsScene::applyStateChanges): >+ (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): >+ (WebKit::compositionLayerImpl): >+ (WebKit::contentLayerImpl): >+ (WebKit::backingStoreImpl): >+ (WebKit::imageBackingImpl): >+ (WebKit::texmapLayer): >+ (WebKit::updateBackingStore): >+ (WebKit::updateImageBacking): >+ (WebKit::removeLayer): >+ (WebKit::CoordinatedGraphicsScene::commitSceneState): >+ (WebKit::CoordinatedGraphicsScene::updateSceneState): >+ (WebKit::CoordinatedGraphicsScene::purgeGLResources): >+ (WebKit::CoordinatedGraphicsScene::syncPlatformLayerIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::setLayerChildrenIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::setLayerFiltersIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::setLayerState): Deleted. >+ (WebKit::CoordinatedGraphicsScene::getLayerByIDIfExists): Deleted. >+ (WebKit::CoordinatedGraphicsScene::createLayers): Deleted. >+ (WebKit::CoordinatedGraphicsScene::createLayer): Deleted. >+ (WebKit::CoordinatedGraphicsScene::deleteLayers): Deleted. >+ (WebKit::CoordinatedGraphicsScene::deleteLayer): Deleted. >+ (WebKit::CoordinatedGraphicsScene::setRootLayerID): Deleted. >+ (WebKit::CoordinatedGraphicsScene::prepareContentBackingStore): Deleted. >+ (WebKit::CoordinatedGraphicsScene::createBackingStoreIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::removeBackingStoreIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize): Deleted. >+ (WebKit::CoordinatedGraphicsScene::createTilesIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::removeTilesIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::updateTilesIfNeeded): Deleted. >+ (WebKit::CoordinatedGraphicsScene::syncImageBackings): Deleted. >+ (WebKit::CoordinatedGraphicsScene::createImageBacking): Deleted. >+ (WebKit::CoordinatedGraphicsScene::updateImageBacking): Deleted. >+ (WebKit::CoordinatedGraphicsScene::clearImageBackingContents): Deleted. >+ (WebKit::CoordinatedGraphicsScene::removeImageBacking): Deleted. >+ (WebKit::CoordinatedGraphicsScene::assignImageBackingToLayer): Deleted. >+ (WebKit::CoordinatedGraphicsScene::setLayerAnimationsIfNeeded): Deleted. >+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h: >+ (WebKit::CoordinatedGraphicsScene::layerByID): Deleted. >+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp: >+ (WebKit::ThreadedCompositor::renderLayerTree): >+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: >+ (WebKit::CompositingCoordinator::flushPendingLayerChanges): >+ > 2018-08-20 Michael Catanzaro <mcatanzaro@igalia.com> > > Use unified build for NetworkProcess >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >index 780aceb7274447d9e493588e09c843d7200e2994..49f22db4d1d7b9d72126fd3b86d6bacb123a971d 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >@@ -180,6 +180,88 @@ public: > functor(m_state.pending); > } > >+ template<typename T> >+ void flushState(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ auto& pending = m_state.pending; >+ auto& staging = m_state.staging; >+ >+ staging.delta.value |= pending.delta.value; >+ >+ if (pending.delta.positionChanged) >+ staging.position = pending.position; >+ if (pending.delta.anchorPointChanged) >+ staging.anchorPoint = pending.anchorPoint; >+ if (pending.delta.sizeChanged) >+ staging.size = pending.size; >+ >+ if (pending.delta.transformChanged) >+ staging.transform = pending.transform; >+ if (pending.delta.childrenTransformChanged) >+ staging.childrenTransform = pending.childrenTransform; >+ >+ if (pending.delta.contentsRectChanged) >+ staging.contentsRect = pending.contentsRect; >+ if (pending.delta.contentsTilingChanged) { >+ staging.contentsTilePhase = pending.contentsTilePhase; >+ staging.contentsTileSize = pending.contentsTileSize; >+ } >+ >+ if (pending.delta.opacityChanged) >+ staging.opacity = pending.opacity; >+ if (pending.delta.solidColorChanged) >+ staging.solidColor = pending.solidColor; >+ >+ if (pending.delta.filtersChanged) >+ staging.filters = pending.filters; >+ if (pending.delta.animationsChanged) >+ staging.animations = pending.animations; >+ >+ if (pending.delta.childrenChanged) >+ staging.children = pending.children; >+ if (pending.delta.maskChanged) >+ staging.mask = pending.mask; >+ if (pending.delta.replicaChanged) >+ staging.replica = pending.replica; >+ >+ if (pending.delta.flagsChanged) >+ staging.flags.value = pending.flags.value; >+ >+ if (pending.delta.repaintCounterChanged) >+ staging.repaintCounter = pending.repaintCounter; >+ if (pending.delta.debugBorderChanged) >+ staging.debugBorder = pending.debugBorder; >+ >+ if (pending.delta.backingStoreChanged) >+ staging.backingStore = pending.backingStore; >+ if (pending.delta.contentLayerChanged) >+ staging.contentLayer = pending.contentLayer; >+ if (pending.delta.imageBackingChanged) >+ staging.imageBacking = pending.imageBacking; >+ >+ pending.delta = { }; >+ >+ functor(staging); >+ } >+ >+ template<typename T> >+ void commitState(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ m_state.committed = m_state.staging; >+ m_state.staging.delta = { }; >+ >+ functor(m_state.committed); >+ } >+ >+ template<typename T> >+ void accessCommitted(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ functor(m_state.committed); >+ } >+ > private: > CompositionLayer(uint64_t, const Impl::Factory&); > >@@ -187,6 +269,8 @@ private: > > struct { > LayerState pending; >+ LayerState staging; >+ LayerState committed; > } m_state; > }; > >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h >index c3a363372a2953f1d9db4428895384256357d0ac..a8c38cefd7b4353de5f95209f2dab55b62cd871c 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h >@@ -51,6 +51,9 @@ public: > ~State(); > > uint32_t id { 0 }; >+ // FIXME: This is needed for a ThreadedCompositor oddity that might not even be >+ // necessary anymore. It that has to be checked and ideally removed. >+ bool platformLayerUpdated { false }; > HashSet<RefPtr<Nicosia::CompositionLayer>> layers; > RefPtr<Nicosia::CompositionLayer> rootLayer; > }; >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >index 68c4396bc82b697b89bb4d67ec08877efc1bf8cd..561728b5ef1f40d80c535992671066ad874819a7 100644 >--- a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >@@ -63,6 +63,12 @@ void ContentLayerTextureMapperImpl::invalidateClient() > m_client.client = nullptr; > } > >+bool ContentLayerTextureMapperImpl::flushUpdate() >+{ >+ LockHolder locker(m_client.lock); >+ return std::exchange(m_client.pendingUpdate, false); >+} >+ > void ContentLayerTextureMapperImpl::swapBuffersIfNeeded() > { > LockHolder locker(m_client.lock); >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h >index 2ef0da2027d772dfb04f1969c900ce7db862ae36..ef96a6083162de41c27de4bf357b8a4fcaf8d9cf 100644 >--- a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h >@@ -56,6 +56,8 @@ public: > > void invalidateClient(); > >+ bool flushUpdate(); >+ > WebCore::TextureMapperPlatformLayerProxy& proxy() const { return m_proxy; } > void swapBuffersIfNeeded(); > >@@ -64,6 +66,7 @@ private: > struct { > Lock lock; > Client* client { nullptr }; >+ bool pendingUpdate { true }; // Starts off with a pending update. > } m_client; > }; > >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index be21680fbd2b191939dae5a0ca5f29f4b69d80d0..7d102480d45f312be4b4e2e4a5366c655e8bdaf0 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -30,7 +30,11 @@ > #include "GraphicsContext.h" > #include "GraphicsLayer.h" > #include "GraphicsLayerFactory.h" >+#include "NicosiaBackingStoreTextureMapperImpl.h" > #include "NicosiaCompositionLayerTextureMapperImpl.h" >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#include "NicosiaImageBackingTextureMapperImpl.h" >+#include "NicosiaPaintingContext.h" > #include "NicosiaPaintingEngine.h" > #include "ScrollableArea.h" > #include "TextureMapperPlatformLayerProxyProvider.h" >@@ -160,6 +164,8 @@ CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer() > } > ASSERT(!m_coordinatedImageBacking); > ASSERT(!m_mainBackingStore); >+ ASSERT(!m_nicosia.imageBacking); >+ ASSERT(!m_nicosia.backingStore); > willBeDestroyed(); > } > >@@ -421,8 +427,13 @@ bool GraphicsLayer::supportsContentsTiling() > void CoordinatedGraphicsLayer::setContentsNeedsDisplay() > { > #if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+ if (m_nicosia.contentLayer) >+ m_shouldUpdatePlatformLayer = true; >+#else > if (m_platformLayer) > m_shouldUpdatePlatformLayer = true; >+#endif > #endif > > notifyFlushRequired(); >@@ -433,6 +444,13 @@ void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platfor > { > #if USE(COORDINATED_GRAPHICS_THREADED) > #if USE(NICOSIA) >+ auto* contentLayer = downcast<Nicosia::ContentLayer>(platformLayer); >+ if (m_nicosia.contentLayer != contentLayer) { >+ m_shouldSyncPlatformLayer = true; >+ m_nicosia.delta.contentLayerChanged = true; >+ } >+ >+ m_nicosia.contentLayer = contentLayer; > #else > if (m_platformLayer != platformLayer) > m_shouldSyncPlatformLayer = true; >@@ -767,6 +785,8 @@ void CoordinatedGraphicsLayer::updatePlatformLayer() > m_shouldUpdatePlatformLayer = false; > #if USE(COORDINATED_GRAPHICS_THREADED) > #if USE(NICOSIA) >+ if (m_nicosia.contentLayer) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosia.contentLayer->impl()).swapBuffersIfNeeded(); > #else > m_layerState.platformLayerUpdated = true; > if (m_platformLayer) >@@ -785,7 +805,10 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > // Sets the values. > computePixelAlignment(m_adjustedPosition, m_adjustedSize, m_adjustedAnchorPoint, m_pixelAlignmentOffset); > >- syncImageBacking(); >+ // FIXME: this is commented out to immediately disable any old-way image updates. >+ // It will soon be removed in a larger cleanup. >+ // syncImageBacking(); >+ > syncLayerState(); > syncAnimations(); > computeTransformedVisibleRect(); >@@ -798,6 +821,69 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > if (!hasActiveTransformAnimation) > m_movingVisibleRect = false; > >+ // Determine the backing store presence. Content is painted later, in the updateContentBuffers() traversal. >+ if (shouldHaveBackingStore()) { >+ if (!m_nicosia.backingStore) { >+ m_nicosia.backingStore = Nicosia::BackingStore::create(Nicosia::BackingStoreTextureMapperImpl::createFactory()); >+ m_nicosia.delta.backingStoreChanged = true; >+ } >+ } else { >+ if (m_nicosia.backingStore) { >+ auto& layerState = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()).layerState(); >+ layerState.isPurging = true; >+ layerState.mainBackingStore = nullptr; >+ layerState.previousBackingStore = nullptr; >+ >+ m_nicosia.backingStore = nullptr; >+ m_nicosia.delta.backingStoreChanged = true; >+ } >+ } >+ >+ // Determine image backing presence according to the composited image source. >+ if (m_compositedNativeImagePtr) { >+ ASSERT(m_compositedImage); >+ auto& image = *m_compositedImage; >+ uintptr_t imageID = reinterpret_cast<uintptr_t>(&image); >+ uintptr_t nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImagePtr.get()); >+ >+ // Respawn the ImageBacking object if the underlying image changed. >+ if (m_nicosia.imageBacking) { >+ auto& impl = downcast<Nicosia::ImageBackingTextureMapperImpl>(m_nicosia.imageBacking->impl()); >+ if (impl.layerState().imageID != imageID) { >+ impl.layerState().update = Nicosia::ImageBackingTextureMapperImpl::Update { }; >+ m_nicosia.imageBacking = nullptr; >+ } >+ } >+ if (!m_nicosia.imageBacking) { >+ m_nicosia.imageBacking = Nicosia::ImageBacking::create(Nicosia::ImageBackingTextureMapperImpl::createFactory()); >+ m_nicosia.delta.imageBackingChanged = true; >+ } >+ >+ // Update the image contents only when the image layer is visible and the native image changed. >+ auto& impl = downcast<Nicosia::ImageBackingTextureMapperImpl>(m_nicosia.imageBacking->impl()); >+ auto& layerState = impl.layerState(); >+ layerState.imageID = imageID; >+ layerState.update.isVisible = transformedVisibleRect().intersects(IntRect(contentsRect())); >+ if (layerState.update.isVisible && layerState.nativeImageID != nativeImageID) { >+ auto buffer = Nicosia::Buffer::create(IntSize(image.size()), >+ !image.currentFrameKnownToBeOpaque() ? Nicosia::Buffer::SupportsAlpha : Nicosia::Buffer::NoFlags); >+ Nicosia::PaintingContext::paint(buffer, >+ [&image](GraphicsContext& context) >+ { >+ IntRect rect { { }, IntSize { image.size() } }; >+ context.drawImage(image, rect, rect, ImagePaintingOptions(CompositeCopy)); >+ }); >+ layerState.nativeImageID = nativeImageID; >+ layerState.update.buffer = WTFMove(buffer); >+ m_nicosia.delta.imageBackingChanged = true; >+ } >+ } else if (m_nicosia.imageBacking) { >+ auto& layerState = downcast<Nicosia::ImageBackingTextureMapperImpl>(m_nicosia.imageBacking->impl()).layerState(); >+ layerState.update = Nicosia::ImageBackingTextureMapperImpl::Update { }; >+ m_nicosia.imageBacking = nullptr; >+ m_nicosia.delta.imageBackingChanged = true; >+ } >+ > { > m_nicosia.layer->updateState( > [this](Nicosia::CompositionLayer::LayerState& state) >@@ -867,17 +953,29 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > state.repaintCounter = m_nicosia.repaintCounter; > if (localDelta.debugBorderChanged) > state.debugBorder = m_nicosia.debugBorder; >+ >+ if (localDelta.backingStoreChanged) >+ state.backingStore = m_nicosia.backingStore; >+ if (localDelta.contentLayerChanged) >+ state.contentLayer = m_nicosia.contentLayer; >+ if (localDelta.imageBackingChanged) >+ state.imageBacking = m_nicosia.imageBacking; > }); >+ m_nicosia.performLayerSync = !!m_nicosia.delta.value; > m_nicosia.delta = { }; > } > } > > void CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers() > { >- if (m_layerState.hasPendingChanges()) { >+ // FIXME: For now the best way for layer state changes to trigger an update is to use >+ // the CoordinatedGraphicsLayerClient::syncLayerState() method. This should be simplified >+ // once the m_layerState member object is removed. >+ if (m_nicosia.performLayerSync || m_layerState.hasPendingChanges()) { > m_coordinator->syncLayerState(m_id, m_layerState); > resetLayerState(); > } >+ m_nicosia.performLayerSync = false; > > if (maskLayer()) > downcast<CoordinatedGraphicsLayer>(*maskLayer()).syncPendingStateChangesIncludingSubLayers(); >@@ -923,27 +1021,6 @@ float CoordinatedGraphicsLayer::effectiveContentsScale() > return selfOrAncestorHaveNonAffineTransforms() ? 1 : deviceScaleFactor() * pageScaleFactor(); > } > >-void CoordinatedGraphicsLayer::adjustContentsScale() >-{ >- ASSERT(shouldHaveBackingStore()); >- if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == effectiveContentsScale()) >- return; >- >- // Between creating the new backing store and painting the content, >- // we do not want to drop the previous one as that might result in >- // briefly seeing flickering as the old tiles may be dropped before >- // something replaces them. >- m_previousBackingStore = WTFMove(m_mainBackingStore); >- >- // No reason to save the previous backing store for non-visible areas. >- m_previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >-} >- >-void CoordinatedGraphicsLayer::createBackingStore() >-{ >- m_mainBackingStore = std::make_unique<TiledBackingStore>(*this, effectiveContentsScale()); >-} >- > void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation() > { > setNeedsVisibleRectAdjustment(); >@@ -1024,44 +1101,69 @@ void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers() > > void CoordinatedGraphicsLayer::updateContentBuffers() > { >- if (!shouldHaveBackingStore()) { >- m_mainBackingStore = nullptr; >- m_previousBackingStore = nullptr; >+ if (!m_nicosia.backingStore) > return; >- } > >+ // Prepare for painting on the impl-contained backing store. isFlushing is used there >+ // for internal sanity checks. >+ auto& impl = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()); >+ auto& layerState = impl.layerState(); >+ layerState.isFlushing = true; >+ >+ // Helper lambda that finished the flush update and determines layer sync necessity. >+ auto finishUpdate = >+ [this, &layerState] { >+ auto& update = layerState.update; >+ m_nicosia.performLayerSync = !update.tilesToCreate.isEmpty() >+ || !update.tilesToRemove.isEmpty() || !update.tilesToUpdate.isEmpty(); >+ layerState.isFlushing = false; >+ }; >+ >+ // Address the content scale adjustment. >+ // FIXME: the previousBackingStore logic is likely possible to remove. > if (m_pendingContentsScaleAdjustment) { >- adjustContentsScale(); >+ if (layerState.mainBackingStore && layerState.mainBackingStore->contentsScale() != effectiveContentsScale()) { >+ // Between creating the new backing store and painting the content, we do not >+ // want to drop the previous one as that might result in briefly seeing flickering >+ // as the old tiles may be dropped before something replaces them. >+ layerState.previousBackingStore = WTFMove(layerState.mainBackingStore); >+ >+ // No reason to save the previous backing store for non-visible areas. >+ layerState.previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >+ } > m_pendingContentsScaleAdjustment = false; > } > >- // This is the only place we (re)create the main tiled backing store, once we >- // have a remote client and we are ready to send our data to the UI process. >- if (!m_mainBackingStore) { >- createBackingStore(); >+ // Ensure the TiledBackingStore object, and enforce a complete repaint if it's not been present yet. >+ if (!layerState.mainBackingStore) { >+ layerState.mainBackingStore = std::make_unique<TiledBackingStore>(impl, effectiveContentsScale()); > m_pendingVisibleRectAdjustment = true; > } > >- if (!m_pendingVisibleRectAdjustment && !m_needsDisplay.completeLayer && m_needsDisplay.rects.isEmpty()) >+ // Bail if there's no painting recorded or enforced. >+ if (!m_pendingVisibleRectAdjustment && !m_needsDisplay.completeLayer && m_needsDisplay.rects.isEmpty()) { >+ finishUpdate(); > return; >+ } > > if (!m_needsDisplay.completeLayer) { > for (auto& rect : m_needsDisplay.rects) >- m_mainBackingStore->invalidate(IntRect { rect }); >+ layerState.mainBackingStore->invalidate(IntRect { rect }); > } else >- m_mainBackingStore->invalidate({ { }, IntSize { m_size } }); >+ layerState.mainBackingStore->invalidate({ { }, IntSize { m_size } }); > > m_needsDisplay.completeLayer = false; > m_needsDisplay.rects.clear(); > > if (m_pendingVisibleRectAdjustment) { > m_pendingVisibleRectAdjustment = false; >- m_mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >+ layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, m_size.width(), m_size.height())); > } > > ASSERT(m_coordinator && m_coordinator->isFlushingLayerChanges()); > >- auto dirtyTiles = m_mainBackingStore->dirtyTiles(); >+ // With all the affected tiles created and/or invalidated, we can finally paint them. >+ auto dirtyTiles = layerState.mainBackingStore->dirtyTiles(); > if (!dirtyTiles.isEmpty()) { > bool didUpdateTiles = false; > >@@ -1079,11 +1181,11 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > updateInfo.buffer = coordinatedBuffer.copyRef(); > > if (!m_coordinator->paintingEngine().paint(*this, WTFMove(coordinatedBuffer), >- dirtyRect, m_mainBackingStore->mapToContents(dirtyRect), >- IntRect { { 0, 0 }, dirtyRect.size() }, m_mainBackingStore->contentsScale())) >+ dirtyRect, layerState.mainBackingStore->mapToContents(dirtyRect), >+ IntRect { { 0, 0 }, dirtyRect.size() }, layerState.mainBackingStore->contentsScale())) > continue; > >- updateTile(tile.tileID(), updateInfo, tileRect); >+ impl.updateTile(tile.tileID(), updateInfo, tileRect); > > tile.markClean(); > didUpdateTiles |= true; >@@ -1096,8 +1198,16 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > // The previous backing store is kept around to avoid flickering between > // removing the existing tiles and painting the new ones. The first time > // the visibleRect is full painted we remove the previous backing store. >- if (m_previousBackingStore && m_mainBackingStore->visibleAreaIsCovered()) >- m_previousBackingStore = nullptr; >+ if (layerState.previousBackingStore && layerState.mainBackingStore->visibleAreaIsCovered()) >+ layerState.previousBackingStore = nullptr; >+ >+ // Request a second update immediately if some tiles are still pending creation. >+ if (layerState.hasPendingTileCreation) { >+ setNeedsVisibleRectAdjustment(); >+ notifyFlushRequired(); >+ } >+ >+ finishUpdate(); > } > > void CoordinatedGraphicsLayer::purgeBackingStores() >@@ -1107,6 +1217,14 @@ void CoordinatedGraphicsLayer::purgeBackingStores() > #endif > m_mainBackingStore = nullptr; > m_previousBackingStore = nullptr; >+ if (m_nicosia.backingStore) { >+ auto& layerState = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()).layerState(); >+ layerState.isPurging = true; >+ layerState.mainBackingStore = nullptr; >+ layerState.previousBackingStore = nullptr; >+ >+ m_nicosia.backingStore = nullptr; >+ } > > releaseImageBackingIfNeeded(); > >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >index 8b9f9a9227884b887f73e33ac3a7868767800171..7d6b66db3d2e19adc3e66c3da947112b8c894746 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >@@ -110,7 +110,7 @@ public: > void removeAnimation(const String&) override; > void suspendAnimations(MonotonicTime) override; > void resumeAnimations() override; >- bool usesContentsLayer() const override { return m_platformLayer || m_compositedImage; } >+ bool usesContentsLayer() const override { return m_platformLayer || m_nicosia.contentLayer || m_compositedImage; } > > void syncPendingStateChangesIncludingSubLayers(); > void updateContentBuffersIncludingSubLayers(); >@@ -161,7 +161,6 @@ private: > void computeTransformedVisibleRect(); > void updateContentBuffers(); > >- void createBackingStore(); > void releaseImageBackingIfNeeded(); > > void notifyFlushRequired(); >@@ -171,7 +170,6 @@ private: > bool shouldHaveBackingStore() const; > bool selfOrAncestorHasActiveTransformAnimation() const; > bool selfOrAncestorHaveNonAffineTransforms(); >- void adjustContentsScale(); > > void setShouldUpdateVisibleRect(); > float effectiveContentsScale(); >@@ -231,6 +229,11 @@ private: > Nicosia::CompositionLayer::LayerState::Delta delta; > Nicosia::CompositionLayer::LayerState::RepaintCounter repaintCounter; > Nicosia::CompositionLayer::LayerState::DebugBorder debugBorder; >+ bool performLayerSync { false }; >+ >+ RefPtr<Nicosia::BackingStore> backingStore; >+ RefPtr<Nicosia::ContentLayer> contentLayer; >+ RefPtr<Nicosia::ImageBacking> imageBacking; > } m_nicosia; > }; > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >index fea28ea0b06f58fa38d3916081fcaaa1b3728e3c..56926a2f4b69cd88943bb8e1cb8b09c0da782a82 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >@@ -25,7 +25,12 @@ > #if USE(COORDINATED_GRAPHICS) > > #include <WebCore/CoordinatedBackingStore.h> >+#include <WebCore/NicosiaBackingStoreTextureMapperImpl.h> > #include <WebCore/NicosiaBuffer.h> >+#include <WebCore/NicosiaCompositionLayerTextureMapperImpl.h> >+#include <WebCore/NicosiaContentLayerTextureMapperImpl.h> >+#include <WebCore/NicosiaImageBackingTextureMapperImpl.h> >+#include <WebCore/NicosiaScene.h> > #include <WebCore/TextureMapper.h> > #include <WebCore/TextureMapperBackingStore.h> > #include <WebCore/TextureMapperGL.h> >@@ -57,20 +62,17 @@ void CoordinatedGraphicsScene::applyStateChanges(const Vector<CoordinatedGraphic > ensureRootLayer(); > > for (auto& state : states) >- commitSceneState(state); >+ commitSceneState(state.nicosia); > } > > void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, TextureMapper::PaintFlags PaintFlags) > { >+ updateSceneState(); >+ > TextureMapperLayer* currentRootLayer = rootLayer(); > if (!currentRootLayer) > return; > >-#if USE(COORDINATED_GRAPHICS_THREADED) >- for (auto& proxy : m_platformLayerProxies.values()) >- proxy->swapBuffer(); >-#endif >- > currentRootLayer->setTextureMapper(m_textureMapper.get()); > bool sceneHasRunningAnimations = currentRootLayer->applyAnimationsRecursively(MonotonicTime::now()); > m_textureMapper->beginPainting(PaintFlags); >@@ -104,23 +106,6 @@ void CoordinatedGraphicsScene::updateViewport() > m_client->updateViewport(); > } > >-void CoordinatedGraphicsScene::syncPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >-#if USE(COORDINATED_GRAPHICS_THREADED) >- if (!state.platformLayerChanged) >- return; >- >- if (state.platformLayerProxy) { >- m_platformLayerProxies.set(layer, state.platformLayerProxy); >- state.platformLayerProxy->activateOnCompositingThread(this, layer); >- } else >- m_platformLayerProxies.remove(layer); >-#else >- UNUSED_PARAM(layer); >- UNUSED_PARAM(state); >-#endif >-} >- > #if USE(COORDINATED_GRAPHICS_THREADED) > void CoordinatedGraphicsScene::onNewBufferAvailable() > { >@@ -128,320 +113,305 @@ void CoordinatedGraphicsScene::onNewBufferAvailable() > } > #endif > >-void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >+Nicosia::CompositionLayerTextureMapperImpl& compositionLayerImpl(Nicosia::CompositionLayer& compositionLayer) > { >- if (!state.childrenChanged) >- return; >- >- Vector<TextureMapperLayer*> children; >- children.reserveCapacity(state.children.size()); >- for (auto& child : state.children) >- children.append(layerByID(child)); >- >- layer->setChildren(children); >+ return downcast<Nicosia::CompositionLayerTextureMapperImpl>(compositionLayer.impl()); > } > >-void CoordinatedGraphicsScene::setLayerFiltersIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >+Nicosia::ContentLayerTextureMapperImpl& contentLayerImpl(Nicosia::ContentLayer& contentLayer) > { >- if (!state.filtersChanged) >- return; >- >- layer->setFilters(state.filters); >+ return downcast<Nicosia::ContentLayerTextureMapperImpl>(contentLayer.impl()); > } > >-void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState, CommitScope& commitScope) >+Nicosia::BackingStoreTextureMapperImpl& backingStoreImpl(Nicosia::BackingStore& backingStore) > { >- ASSERT(m_rootLayerID != InvalidCoordinatedLayerID); >- TextureMapperLayer* layer = layerByID(id); >- >- if (layerState.positionChanged) >- layer->setPosition(layerState.pos); >- >- if (layerState.anchorPointChanged) >- layer->setAnchorPoint(layerState.anchorPoint); >- >- if (layerState.sizeChanged) >- layer->setSize(layerState.size); >- >- if (layerState.transformChanged) >- layer->setTransform(layerState.transform); >- >- if (layerState.childrenTransformChanged) >- layer->setChildrenTransform(layerState.childrenTransform); >- >- if (layerState.contentsRectChanged) >- layer->setContentsRect(layerState.contentsRect); >- >- if (layerState.contentsTilingChanged) { >- layer->setContentsTilePhase(layerState.contentsTilePhase); >- layer->setContentsTileSize(layerState.contentsTileSize); >- } >- >- if (layerState.opacityChanged) >- layer->setOpacity(layerState.opacity); >- >- if (layerState.solidColorChanged) >- layer->setSolidColor(layerState.solidColor); >- >- if (layerState.debugVisualsChanged) >- layer->setDebugVisuals(layerState.debugVisuals.showDebugBorders, layerState.debugVisuals.debugBorderColor, layerState.debugVisuals.debugBorderWidth); >- if (layerState.repaintCountChanged) >- layer->setRepaintCounter(layerState.repaintCount.showRepaintCounter, layerState.repaintCount.count); >- >- if (layerState.replicaChanged) >- layer->setReplicaLayer(getLayerByIDIfExists(layerState.replica)); >- >- if (layerState.maskChanged) >- layer->setMaskLayer(getLayerByIDIfExists(layerState.mask)); >- >- if (layerState.imageChanged) >- assignImageBackingToLayer(layer, layerState.imageID); >- >- if (layerState.flagsChanged) { >- layer->setContentsOpaque(layerState.contentsOpaque); >- layer->setDrawsContent(layerState.drawsContent); >- layer->setContentsVisible(layerState.contentsVisible); >- layer->setBackfaceVisibility(layerState.backfaceVisible); >- >- // Never clip the root layer. >- layer->setMasksToBounds(id == m_rootLayerID ? false : layerState.masksToBounds); >- layer->setPreserves3D(layerState.preserves3D); >- } >- >- // Apply Operations. >- setLayerChildrenIfNeeded(layer, layerState); >- setLayerFiltersIfNeeded(layer, layerState); >- setLayerAnimationsIfNeeded(layer, layerState); >- prepareContentBackingStore(layer, commitScope); >- createTilesIfNeeded(layer, layerState); >- removeTilesIfNeeded(layer, layerState, commitScope); >- updateTilesIfNeeded(layer, layerState, commitScope); >- syncPlatformLayerIfNeeded(layer, layerState); >+ return downcast<Nicosia::BackingStoreTextureMapperImpl>(backingStore.impl()); > } > >-TextureMapperLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLayerID id) >+Nicosia::ImageBackingTextureMapperImpl& imageBackingImpl(Nicosia::ImageBacking& imageBacking) > { >- return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0; >+ return downcast<Nicosia::ImageBackingTextureMapperImpl>(imageBacking.impl()); > } > >-void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& layerIDs) >+TextureMapperLayer& texmapLayer(Nicosia::CompositionLayer& compositionLayer) > { >- for (auto& layerID : layerIDs) >- createLayer(layerID); >-} >- >-void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id) >-{ >- std::unique_ptr<TextureMapperLayer> newLayer = std::make_unique<TextureMapperLayer>(); >- newLayer->setID(id); >- m_layers.add(id, WTFMove(newLayer)); >-} >- >-void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs) >-{ >- for (auto& layerID : layerIDs) >- deleteLayer(layerID); >+ auto& compositionState = compositionLayerImpl(compositionLayer).compositionState(); >+ if (!compositionState.layer) { >+ compositionState.layer = std::make_unique<TextureMapperLayer>(); >+ compositionState.layer->setID(compositionLayer.id()); >+ } >+ return *compositionState.layer; > } > >-void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID) >+void updateBackingStore(TextureMapperLayer& layer, >+ Nicosia::BackingStoreTextureMapperImpl::CompositionState& compositionState, >+ const Nicosia::BackingStoreTextureMapperImpl::TileUpdate& update) > { >- std::unique_ptr<TextureMapperLayer> layer = m_layers.take(layerID); >- ASSERT(layer); >- >- m_backingStores.remove(layer.get()); >-#if USE(COORDINATED_GRAPHICS_THREADED) >- if (auto platformLayerProxy = m_platformLayerProxies.take(layer.get())) >- platformLayerProxy->invalidate(); >-#endif >-} >+ if (!layerShouldHaveBackingStore(&layer)) { >+ layer.setBackingStore(nullptr); >+ compositionState.backingStore = nullptr; >+ return; >+ } > >-void CoordinatedGraphicsScene::setRootLayerID(CoordinatedLayerID layerID) >-{ >- ASSERT(layerID != InvalidCoordinatedLayerID); >- ASSERT(m_rootLayerID == InvalidCoordinatedLayerID); >+ if (!compositionState.backingStore) >+ compositionState.backingStore = CoordinatedBackingStore::create(); >+ auto& backingStore = *compositionState.backingStore; > >- m_rootLayerID = layerID; >+ layer.setBackingStore(&backingStore); >+ backingStore.setSize(layer.size()); > >- TextureMapperLayer* layer = layerByID(layerID); >- ASSERT(m_rootLayer->children().isEmpty()); >- m_rootLayer->addChild(layer); >+ for (auto& tile : update.tilesToCreate) >+ backingStore.createTile(tile.tileID, tile.scale); >+ for (auto& tile : update.tilesToRemove) >+ backingStore.removeTile(tile.tileID); >+ for (auto& tile : update.tilesToUpdate) { >+ backingStore.updateTile(tile.tileID, tile.updateInfo.updateRect, >+ tile.tileRect, tile.updateInfo.buffer.copyRef(), { 0, 0 }); >+ } > } > >-void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer, CommitScope& commitScope) >+void updateImageBacking(TextureMapperLayer& layer, >+ Nicosia::ImageBackingTextureMapperImpl::CompositionState& compositionState, >+ Nicosia::ImageBackingTextureMapperImpl::Update& update) > { >- if (!layerShouldHaveBackingStore(layer)) { >- removeBackingStoreIfNeeded(layer); >+ if (!update.isVisible) { >+ layer.setBackingStore(nullptr); > return; > } > >- createBackingStoreIfNeeded(layer); >- resetBackingStoreSizeToLayerSize(layer, commitScope); >-} >+ if (!compositionState.backingStore) >+ compositionState.backingStore = CoordinatedBackingStore::create(); >+ auto& backingStore = *compositionState.backingStore; >+ layer.setContentsLayer(&backingStore); > >-void CoordinatedGraphicsScene::createBackingStoreIfNeeded(TextureMapperLayer* layer) >-{ >- if (m_backingStores.contains(layer)) >+ if (!update.buffer) > return; > >- auto backingStore = CoordinatedBackingStore::create(); >- m_backingStores.add(layer, backingStore.copyRef()); >- layer->setBackingStore(backingStore.ptr()); >-} >- >-void CoordinatedGraphicsScene::removeBackingStoreIfNeeded(TextureMapperLayer* layer) >-{ >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.take(layer); >- if (!backingStore) >- return; >- >- layer->setBackingStore(nullptr); >+ backingStore.createTile(1, 1.0); >+ WebCore::IntRect rect { { }, update.buffer->size() }; >+ ASSERT(2000 >= std::max(rect.width(), rect.height())); >+ backingStore.setSize(rect.size()); >+ backingStore.updateTile(1, rect, rect, WTFMove(update.buffer), rect.location()); > } > >-void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer, CommitScope& commitScope) >+void removeLayer(Nicosia::CompositionLayer& layer) > { >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore); >- backingStore->setSize(layer->size()); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} >+ layer.accessCommitted( >+ [](const Nicosia::CompositionLayer::LayerState& committed) >+ { >+ if (committed.backingStore) { >+ auto& compositionState = backingStoreImpl(*committed.backingStore).compositionState(); >+ compositionState.backingStore = nullptr; >+ } > >-void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (state.tilesToCreate.isEmpty()) >- return; >+ if (committed.contentLayer) >+ contentLayerImpl(*committed.contentLayer).proxy().invalidate(); > >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); >- if (!backingStore) >- return; >+ if (committed.imageBacking) { >+ auto& compositionState = imageBackingImpl(*committed.imageBacking).compositionState(); >+ compositionState.backingStore = nullptr; >+ } >+ }); > >- for (auto& tile : state.tilesToCreate) >- backingStore->createTile(tile.tileID, tile.scale); >+ auto& compositionState = compositionLayerImpl(layer).compositionState(); >+ compositionState.layer = nullptr; > } > >-void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) >+void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState::NicosiaState& state) > { >- if (state.tilesToRemove.isEmpty()) >- return; >- >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- if (!backingStore) >+ if (!m_client) > return; > >- for (auto& tile : state.tilesToRemove) >- backingStore->removeTile(tile); >- >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >+ m_nicosia.scene = state.scene; > } > >-void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) >+void CoordinatedGraphicsScene::updateSceneState() > { >- if (state.tilesToUpdate.isEmpty()) >+ if (!m_nicosia.scene) > return; > >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); >- if (!backingStore) >- return; >- >- for (auto& tile : state.tilesToUpdate) { >- const SurfaceUpdateInfo& surfaceUpdateInfo = tile.updateInfo; >- >- backingStore->updateTile(tile.tileID, surfaceUpdateInfo.updateRect, tile.tileRect, surfaceUpdateInfo.buffer.copyRef(), { 0, 0 }); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >+ // Store layer and impl references along with the corresponding update >+ // for each type of possible layer backing. >+ struct { >+ struct BackingStore { >+ std::reference_wrapper<TextureMapperLayer> layer; >+ std::reference_wrapper<Nicosia::BackingStoreTextureMapperImpl> backingStore; >+ Nicosia::BackingStoreTextureMapperImpl::TileUpdate update; >+ }; >+ Vector<BackingStore> backingStore; >+ >+ struct ContentLayer { >+ std::reference_wrapper<TextureMapperLayer> layer; >+ std::reference_wrapper<TextureMapperPlatformLayerProxy> proxy; >+ bool needsActivation { false }; >+ }; >+ Vector<ContentLayer> contentLayer; >+ >+ struct ImageBacking { >+ std::reference_wrapper<TextureMapperLayer> layer; >+ std::reference_wrapper<Nicosia::ImageBackingTextureMapperImpl> imageBacking; >+ Nicosia::ImageBackingTextureMapperImpl::Update update; >+ }; >+ Vector<ImageBacking> imageBacking; >+ } layersByBacking; >+ >+ // Access the scene state and perform state update for each layer. >+ m_nicosia.scene->accessState( >+ [this, &layersByBacking](Nicosia::Scene::State& state) >+ { >+ // Bail if the scene didn't change. >+ if (state.id == m_nicosia.state.id) >+ return; >+ >+ // Handle the root layer, adding it to the TextureMapperLayer tree >+ // on the first update. No such change is expected later. >+ { >+ auto& rootLayer = texmapLayer(*state.rootLayer); >+ if (rootLayer.id() != m_rootLayerID) { >+ m_rootLayerID = rootLayer.id(); >+ RELEASE_ASSERT(m_rootLayer->children().isEmpty()); >+ m_rootLayer->addChild(&rootLayer); >+ } >+ } >+ >+ // Gather all the to-be-removed layers so that composition-side state >+ // can be properly purged after the current state's set of layers is adopted. >+ HashSet<RefPtr<Nicosia::CompositionLayer>> removedLayers; >+ for (auto& layer : m_nicosia.state.layers) { >+ if (!state.layers.contains(layer)) >+ removedLayers.add(layer); >+ } >+ >+ m_nicosia.state = state; >+ >+ for (auto& layer : removedLayers) >+ removeLayer(*layer); >+ removedLayers = { }; >+ >+ // Iterate the current state's set of layers, updating state values according to >+ // the incoming state changes. Layer backings are stored so that the updates >+ // (possibly time-consuming) can be done outside of this scene update. >+ for (auto& compositionLayer : m_nicosia.state.layers) { >+ auto& layer = texmapLayer(*compositionLayer); >+ compositionLayer->commitState( >+ [this, &layer, &compositionLayer, &layersByBacking] >+ (const Nicosia::CompositionLayer::LayerState& layerState) >+ { >+ if (layerState.delta.positionChanged) >+ layer.setPosition(layerState.position); >+ if (layerState.delta.anchorPointChanged) >+ layer.setAnchorPoint(layerState.anchorPoint); >+ if (layerState.delta.sizeChanged) >+ layer.setSize(layerState.size); >+ >+ if (layerState.delta.transformChanged) >+ layer.setTransform(layerState.transform); >+ if (layerState.delta.childrenTransformChanged) >+ layer.setChildrenTransform(layerState.childrenTransform); >+ >+ if (layerState.delta.contentsRectChanged) >+ layer.setContentsRect(layerState.contentsRect); >+ if (layerState.delta.contentsTilingChanged) { >+ layer.setContentsTilePhase(layerState.contentsTilePhase); >+ layer.setContentsTileSize(layerState.contentsTileSize); >+ } >+ >+ if (layerState.delta.opacityChanged) >+ layer.setOpacity(layerState.opacity); >+ if (layerState.delta.solidColorChanged) >+ layer.setSolidColor(layerState.solidColor); >+ >+ if (layerState.delta.filtersChanged) >+ layer.setFilters(layerState.filters); >+ if (layerState.delta.animationsChanged) >+ layer.setAnimations(layerState.animations); >+ >+ if (layerState.delta.childrenChanged) { >+ layer.setChildren(WTF::map(layerState.children, >+ [](auto& child) { return &texmapLayer(*child); })); >+ } >+ >+ if (layerState.delta.maskChanged) >+ layer.setMaskLayer(layerState.mask ? &texmapLayer(*layerState.mask) : nullptr); >+ if (layerState.delta.replicaChanged) >+ layer.setReplicaLayer(layerState.replica ? &texmapLayer(*layerState.replica) : nullptr); >+ >+ if (layerState.delta.flagsChanged) { >+ layer.setContentsOpaque(layerState.flags.contentsOpaque); >+ layer.setDrawsContent(layerState.flags.drawsContent); >+ layer.setContentsVisible(layerState.flags.contentsVisible); >+ layer.setBackfaceVisibility(layerState.flags.backfaceVisible); >+ layer.setMasksToBounds(layerState.flags.masksToBounds); >+ layer.setPreserves3D(layerState.flags.preserves3D); >+ } >+ >+ if (layerState.backingStore) { >+ auto& impl = backingStoreImpl(*layerState.backingStore); >+ layersByBacking.backingStore.append( >+ { std::ref(layer), std::ref(impl), impl.takeUpdate() }); >+ } else >+ layer.setBackingStore(nullptr); >+ >+ if (layerState.contentLayer) { >+ auto& impl = contentLayerImpl(*layerState.contentLayer); >+ layersByBacking.contentLayer.append( >+ { std::ref(layer), std::ref(impl.proxy()), layerState.delta.contentLayerChanged }); >+ } else if (layerState.imageBacking) { >+ auto& impl = imageBackingImpl(*layerState.imageBacking); >+ layersByBacking.imageBacking.append( >+ { std::ref(layer), std::ref(impl), impl.takeUpdate() }); >+ } else >+ layer.setContentsLayer(nullptr); >+ }); >+ } >+ }); >+ >+ // Iterate through each backing type of layers and gather backing store >+ // or proxy objects that need an update. >+ // FIXME: HashSet<std::reference_wrapper<>> would be ideal, but doesn't work (yet). >+ HashSet<Ref<WebCore::CoordinatedBackingStore>> backingStoresWithPendingBuffers; >+ HashSet<Ref<WebCore::TextureMapperPlatformLayerProxy>> proxiesForSwapping; >+ >+ { >+ for (auto& entry : layersByBacking.backingStore) { >+ auto& compositionState = entry.backingStore.get().compositionState(); >+ updateBackingStore(entry.layer.get(), compositionState, entry.update); >+ >+ if (compositionState.backingStore) >+ backingStoresWithPendingBuffers.add(makeRef(*compositionState.backingStore)); >+ } >+ >+ layersByBacking.backingStore = { }; > } >-} >- >-void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state, CommitScope& commitScope) >-{ >- for (auto& image : state.imagesToRemove) >- removeImageBacking(image, commitScope); >- >- for (auto& image : state.imagesToCreate) >- createImageBacking(image); >- >- for (auto& image : state.imagesToUpdate) >- updateImageBacking(image.first, image.second.copyRef(), commitScope); >- >- for (auto& image : state.imagesToClear) >- clearImageBackingContents(image, commitScope); >-} >- >-void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID) >-{ >- ASSERT(!m_imageBackings.contains(imageID)); >- m_imageBackings.add(imageID, CoordinatedBackingStore::create()); >-} >- >-void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<Nicosia::Buffer>&& buffer, CommitScope& commitScope) >-{ >- ASSERT(m_imageBackings.contains(imageID)); >- auto it = m_imageBackings.find(imageID); >- RefPtr<CoordinatedBackingStore> backingStore = it->value; >- >- // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process. >- backingStore->createTile(1 /* id */, 1 /* scale */); >- IntRect rect(IntPoint::zero(), buffer->size()); >- // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage() >- ASSERT(2000 >= std::max(rect.width(), rect.height())); >- backingStore->setSize(rect.size()); >- backingStore->updateTile(1 /* id */, rect, rect, WTFMove(buffer), rect.location()); >- >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} > >-void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID, CommitScope& commitScope) >-{ >- ASSERT(m_imageBackings.contains(imageID)); >- auto it = m_imageBackings.find(imageID); >- RefPtr<CoordinatedBackingStore> backingStore = it->value; >- backingStore->removeAllTiles(); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} >- >-void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID, CommitScope& commitScope) >-{ >- ASSERT(m_imageBackings.contains(imageID)); >+ { >+ for (auto& entry : layersByBacking.contentLayer) { >+ auto& proxy = entry.proxy.get(); >+ if (entry.needsActivation) >+ proxy.activateOnCompositingThread(this, &entry.layer.get()); >+ proxiesForSwapping.add(makeRef(proxy)); >+ } > >- // We don't want TextureMapperLayer refers a dangling pointer. >- commitScope.releasedImageBackings.append(m_imageBackings.take(imageID)); >-} >- >-void CoordinatedGraphicsScene::assignImageBackingToLayer(TextureMapperLayer* layer, CoordinatedImageBackingID imageID) >-{ >- if (imageID == InvalidCoordinatedImageBackingID) { >- layer->setContentsLayer(0); >- return; >+ layersByBacking.contentLayer = { }; > } > >- auto it = m_imageBackings.find(imageID); >- ASSERT(it != m_imageBackings.end()); >- layer->setContentsLayer(it->value.get()); >-} >- >-void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state) >-{ >- if (!m_client) >- return; >- >- m_nicosia = state.nicosia; >- // FIXME: Start using the Nicosia layer state for updates. >+ { >+ for (auto& entry : layersByBacking.imageBacking) { >+ auto& compositionState = entry.imageBacking.get().compositionState(); >+ updateImageBacking(entry.layer.get(), compositionState, entry.update); > >- CommitScope commitScope; >+ if (compositionState.backingStore) >+ backingStoresWithPendingBuffers.add(makeRef(*compositionState.backingStore)); >+ } > >- createLayers(state.layersToCreate); >- deleteLayers(state.layersToRemove); >- >- if (state.rootCompositingLayer != m_rootLayerID) >- setRootLayerID(state.rootCompositingLayer); >- >- syncImageBackings(state, commitScope); >- >- for (auto& layer : state.layersToUpdate) >- setLayerState(layer.first, layer.second, commitScope); >+ layersByBacking.imageBacking = { }; >+ } > >- for (auto& backingStore : commitScope.backingStoresWithPendingBuffers) >+ for (auto& backingStore : backingStoresWithPendingBuffers) > backingStore->commitTileOperations(*m_textureMapper); >+ >+ for (auto& proxy : proxiesForSwapping) >+ proxy->swapBuffer(); > } > > void CoordinatedGraphicsScene::ensureRootLayer() >@@ -465,26 +435,22 @@ void CoordinatedGraphicsScene::purgeGLResources() > { > ASSERT(!m_client); > >- m_imageBackings.clear(); >-#if USE(COORDINATED_GRAPHICS_THREADED) >- for (auto& proxy : m_platformLayerProxies.values()) >- proxy->invalidate(); >- m_platformLayerProxies.clear(); >-#endif >+ if (m_nicosia.scene) { >+ m_nicosia.scene->accessState( >+ [this](const Nicosia::Scene::State& state) >+ { >+ ASSERT(state.id == m_nicosia.state.id); >+ for (auto& layer : m_nicosia.state.layers) >+ removeLayer(*layer); >+ m_nicosia.state.layers = { }; >+ m_nicosia.state.rootLayer = nullptr; >+ }); >+ m_nicosia.scene = nullptr; >+ } > > m_rootLayer = nullptr; > m_rootLayerID = InvalidCoordinatedLayerID; >- m_layers.clear(); > m_textureMapper = nullptr; >- m_backingStores.clear(); >-} >- >-void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (!state.animationsChanged) >- return; >- >- layer->setAnimations(state.animations); > } > > void CoordinatedGraphicsScene::detach() >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >index 2f3b4f339753fdc7ddcb711020396002a1a92afb..40b8b63110e99fb24e30749bceaa029cf0f3b98e 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >@@ -81,83 +81,36 @@ public: > bool isActive() const { return m_isActive; } > void setActive(bool active) { m_isActive = active; } > >- void commitSceneState(const WebCore::CoordinatedGraphicsState&); >- > void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; } > WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; } > > private: >- struct CommitScope { >- CommitScope() = default; >- CommitScope(CommitScope&) = delete; >- CommitScope& operator=(const CommitScope&) = delete; >- >- Vector<RefPtr<WebCore::CoordinatedBackingStore>> releasedImageBackings; >- HashSet<RefPtr<WebCore::CoordinatedBackingStore>> backingStoresWithPendingBuffers; >- }; >- >- void setRootLayerID(WebCore::CoordinatedLayerID); >- void createLayers(const Vector<WebCore::CoordinatedLayerID>&); >- void deleteLayers(const Vector<WebCore::CoordinatedLayerID>&); >- void setLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void setLayerChildrenIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void updateTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void createTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void removeTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void setLayerFiltersIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void setLayerAnimationsIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void syncPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- >- void syncImageBackings(const WebCore::CoordinatedGraphicsState&, CommitScope&); >- void createImageBacking(WebCore::CoordinatedImageBackingID); >- void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<Nicosia::Buffer>&&, CommitScope&); >- void clearImageBackingContents(WebCore::CoordinatedImageBackingID, CommitScope&); >- void removeImageBacking(WebCore::CoordinatedImageBackingID, CommitScope&); >- >- WebCore::TextureMapperLayer* layerByID(WebCore::CoordinatedLayerID id) >- { >- ASSERT(m_layers.contains(id)); >- ASSERT(id != WebCore::InvalidCoordinatedLayerID); >- return m_layers.get(id); >- } >- WebCore::TextureMapperLayer* getLayerByIDIfExists(WebCore::CoordinatedLayerID); >+ void commitSceneState(const WebCore::CoordinatedGraphicsState::NicosiaState&); >+ void updateSceneState(); >+ > WebCore::TextureMapperLayer* rootLayer() { return m_rootLayer.get(); } > > void updateViewport(); > >- void createLayer(WebCore::CoordinatedLayerID); >- void deleteLayer(WebCore::CoordinatedLayerID); >- >- void assignImageBackingToLayer(WebCore::TextureMapperLayer*, WebCore::CoordinatedImageBackingID); > void ensureRootLayer(); > >- void prepareContentBackingStore(WebCore::TextureMapperLayer*, CommitScope&); >- void createBackingStoreIfNeeded(WebCore::TextureMapperLayer*); >- void removeBackingStoreIfNeeded(WebCore::TextureMapperLayer*); >- void resetBackingStoreSizeToLayerSize(WebCore::TextureMapperLayer*, CommitScope&); >- > #if USE(COORDINATED_GRAPHICS_THREADED) > void onNewBufferAvailable() override; > #endif > >- WebCore::CoordinatedGraphicsState::NicosiaState m_nicosia; >+ struct { >+ RefPtr<Nicosia::Scene> scene; >+ Nicosia::Scene::State state; >+ } m_nicosia; > > std::unique_ptr<WebCore::TextureMapper> m_textureMapper; > >- HashMap<WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedBackingStore>> m_imageBackings; >- HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::CoordinatedBackingStore>> m_backingStores; >- >-#if USE(COORDINATED_GRAPHICS_THREADED) >- HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::TextureMapperPlatformLayerProxy>> m_platformLayerProxies; >-#endif >- > // Below two members are accessed by only the main thread. The painting thread must lock the main thread to access both members. > CoordinatedGraphicsSceneClient* m_client; > bool m_isActive { false }; > > std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer; > >- HashMap<WebCore::CoordinatedLayerID, std::unique_ptr<WebCore::TextureMapperLayer>> m_layers; > WebCore::CoordinatedLayerID m_rootLayerID { WebCore::InvalidCoordinatedLayerID }; > WebCore::Color m_viewBackgroundColor { WebCore::Color::white }; > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >index 6f1ff2c93e7a619853a2a687a86186c1d6a55756..de833a57197f2c5c5675b0d78a9d4cfcdea66f05 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >@@ -215,11 +215,20 @@ void ThreadedCompositor::renderLayerTree() > // Coordinate scene update completion with the client in case of changed or updated platform layers. > // But do not change coordinateUpdateCompletionWithClient while in force repaint because that > // demands immediate scene update completion regardless of platform layers. >+ // FIXME: Check whether we still need all this coordinateUpdateCompletionWithClient logic. >+ // Relatedly, we should only ever operate with a single Nicosia::Scene object, not with a Vector >+ // of CoordinatedGraphicsState instances (which at this time will all contain RefPtr to the same >+ // Nicosia::State object anyway). > if (!m_inForceRepaint) { > bool coordinateUpdate = false; >- for (auto& state : states) >- coordinateUpdate |= std::any_of(state.layersToUpdate.begin(), state.layersToUpdate.end(), >- [](auto& it) { return it.second.platformLayerChanged || it.second.platformLayerUpdated; }); >+ for (auto& state : states) { >+ state.nicosia.scene->accessState( >+ [&coordinateUpdate](Nicosia::Scene::State& state) >+ { >+ coordinateUpdate |= state.platformLayerUpdated; >+ state.platformLayerUpdated = false; >+ }); >+ } > m_attributes.coordinateUpdateCompletionWithClient = coordinateUpdate; > } > } >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >index 4ec0f5ea1a318c18c8ade2cd9b82c3fd75bfb7b2..6ba95758c09d9d5a94d2e23ac2e891290b61d886 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -35,6 +35,9 @@ > #include <WebCore/FrameView.h> > #include <WebCore/GraphicsContext.h> > #include <WebCore/InspectorController.h> >+#include <WebCore/NicosiaBackingStoreTextureMapperImpl.h> >+#include <WebCore/NicosiaContentLayerTextureMapperImpl.h> >+#include <WebCore/NicosiaImageBackingTextureMapperImpl.h> > #include <WebCore/NicosiaPaintingEngine.h> > #include <WebCore/Page.h> > #include <wtf/MemoryPressureHandler.h> >@@ -130,7 +133,31 @@ bool CompositingCoordinator::flushPendingLayerChanges() > m_state.nicosia.scene->accessState( > [this](Nicosia::Scene::State& state) > { >+ bool platformLayerUpdated = false; >+ for (auto& compositionLayer : m_nicosia.state.layers) { >+ compositionLayer->flushState( >+ [&platformLayerUpdated] >+ (const Nicosia::CompositionLayer::LayerState& state) >+ { >+ if (state.backingStore) { >+ auto& impl = downcast<Nicosia::BackingStoreTextureMapperImpl>(state.backingStore->impl()); >+ impl.flushUpdate(); >+ } >+ >+ if (state.imageBacking) { >+ auto& impl = downcast<Nicosia::ImageBackingTextureMapperImpl>(state.imageBacking->impl()); >+ impl.flushUpdate(); >+ } >+ >+ if (state.contentLayer) { >+ auto& impl = downcast<Nicosia::ContentLayerTextureMapperImpl>(state.contentLayer->impl()); >+ platformLayerUpdated |= impl.flushUpdate(); >+ } >+ }); >+ } >+ > ++state.id; >+ state.platformLayerUpdated = platformLayerUpdated; > state.layers = m_nicosia.state.layers; > state.rootLayer = m_nicosia.state.rootLayer; > }); >diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake >index 945dedec22eff04197728abd5a6e501a950d507f..452451084ebb154583376c2358b49ab9b29a8a67 100644 >--- a/Source/cmake/OptionsGTK.cmake >+++ b/Source/cmake/OptionsGTK.cmake >@@ -277,6 +277,7 @@ if (ENABLE_OPENGL) > > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS_THREADED TRUE) >+ SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE) > endif () > > if (ENABLE_PLUGIN_PROCESS_GTK2) >diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake >index e87011d52d6e8c7c312ce7ec936ce7c2ad48970c..fcb59d8808e22beb6678a48b27fd5803905392f9 100644 >--- a/Source/cmake/OptionsWPE.cmake >+++ b/Source/cmake/OptionsWPE.cmake >@@ -134,6 +134,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS_THREADED TRUE) >+SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE) > > set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders) > set(FORWARDING_HEADERS_WPE_DIR ${FORWARDING_HEADERS_DIR}/wpe) >diff --git a/ChangeLog b/ChangeLog >index 3eecbe1e940da57b102e943f271c25344c1bb6c9..70d7a30eb517a9421b1726764bddf941efbe9689 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,14 @@ >+2018-08-21 Zan Dobersek <zdobersek@igalia.com> >+ >+ [CoordGraphics] Switch to Nicosia::CompositionLayer state tracking >+ https://bugs.webkit.org/show_bug.cgi?id=188693 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/cmake/OptionsGTK.cmake: Enable USE_NICOSIA alongside >+ USE_COORDINATED_GRAPHICS and USE_COORDINATED_GRAPHICS_THREADED. >+ * Source/cmake/OptionsWPE.cmake: Ditto. >+ > 2018-08-18 Michael Catanzaro <mcatanzaro@igalia.com> > > Adjust CMAKE_MODULE_LINKER_FLAGS for asan
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188693
:
347355
|
347444
|
347483
|
347487
|
347494
|
347502
|
347514
|
347616
|
347627
|
347678
|
347779