WebKit Bugzilla
Attachment 347355 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]
WIP
bug-188693-20180817105911.patch (text/plain), 60.21 KB, created by
Zan Dobersek
on 2018-08-17 01:59:13 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2018-08-17 01:59:13 PDT
Size:
60.21 KB
patch
obsolete
>Subversion Revision: 234976 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1e7bca7c295c97ee918c03586d16fa274dfb2490..70960c6bab900486522c76cff41741e6618b5cc4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2018-08-17 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!). >+ >+ No new tests (OOPS!). >+ >+ * platform/graphics/nicosia/NicosiaPlatformLayer.h: >+ (Nicosia::CompositionLayer::flushState): >+ (Nicosia::CompositionLayer::commitState): >+ (Nicosia::CompositionLayer::accessCommitted): >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: >+ (WebCore::CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer): >+ (WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay): >+ (WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer): >+ (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly): >+ (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers): >+ (WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers): >+ (WebCore::CoordinatedGraphicsLayer::updateContentBuffers): >+ (WebCore::CoordinatedGraphicsLayer::updateContentBuffers2): >+ (WebCore::CoordinatedGraphicsLayer::purgeBackingStores): >+ (WebCore::CoordinatedGraphicsLayer::adjustContentsScale): Deleted. >+ (WebCore::CoordinatedGraphicsLayer::createBackingStore): Deleted. >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h: >+ > 2018-08-16 Devin Rousso <drousso@apple.com> > > Web Inspector: support breakpoints for arbitrary event names >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index c24d48bc6cba2304b420faf873f3c549ae140c57..078e2a262ead1d4c248d0072267aa1cab35c5ffb 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,53 @@ >+2018-08-17 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!). >+ >+ * 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. >+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: >+ (WebKit::CompositingCoordinator::flushPendingLayerChanges): >+ > 2018-08-16 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r234958. >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >index 780aceb7274447d9e493588e09c843d7200e2994..2b87bcec413d8869d5d4a6062e356d53993594fd 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >@@ -180,6 +180,92 @@ 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.contentLayerChanged) >+ staging.contentLayer = pending.contentLayer; >+ if (pending.delta.backingStoreChanged) >+ staging.backingStore = pending.backingStore; >+ if (pending.delta.imageBackingChanged) >+ staging.imageBacking = pending.imageBacking; >+ >+ pending.delta = { }; >+ >+ functor(staging); >+ } >+ >+ template<typename T> >+ void commitState(const T& functor) >+ { >+ const LayerState& state = >+ [this] { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ m_state.committed = m_state.staging; >+ m_state.staging.delta = { }; >+ return m_state.committed; >+ }(); >+ >+ functor(state); >+ } >+ >+ 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 +273,8 @@ private: > > struct { > LayerState pending; >+ LayerState staging; >+ LayerState committed; > } m_state; > }; > >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index be21680fbd2b191939dae5a0ca5f29f4b69d80d0..5f6048187f35d87525e32e4f1ebec3acb8407395 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; >@@ -798,6 +816,69 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > if (!hasActiveTransformAnimation) > m_movingVisibleRect = false; > >+ if (m_nicosia.contentLayer) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosia.contentLayer->impl()).swapBuffersIfNeeded(); >+ >+ if (!shouldHaveBackingStore()) { >+ 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; >+ } >+ } else { >+ if (!m_nicosia.backingStore) { >+ m_nicosia.backingStore = Nicosia::BackingStore::create(Nicosia::BackingStoreTextureMapperImpl::createFactory()); >+ m_nicosia.delta.backingStoreChanged = true; >+ } >+ } >+ >+ 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()); >+ >+ 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; >+ } >+ >+ 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 +948,26 @@ 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()) { >+ 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 +1013,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(); >@@ -1011,12 +1080,12 @@ void CoordinatedGraphicsLayer::removeTile(uint32_t tileID) > void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers() > { > if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer())) >- mask->updateContentBuffers(); >+ mask->updateContentBuffers2(); > > if (CoordinatedGraphicsLayer* replica = downcast<CoordinatedGraphicsLayer>(replicaLayer())) >- replica->updateContentBuffers(); >+ replica->updateContentBuffers2(); > >- updateContentBuffers(); >+ updateContentBuffers2(); > > for (auto& child : children()) > downcast<CoordinatedGraphicsLayer>(*child).updateContentBuffersIncludingSubLayers(); >@@ -1031,14 +1100,22 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > } > > if (m_pendingContentsScaleAdjustment) { >- adjustContentsScale(); >+ if (m_mainBackingStore && m_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. >+ 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())); >+ } > 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(); >+ m_mainBackingStore = std::make_unique<TiledBackingStore>(*this, effectiveContentsScale()); > m_pendingVisibleRectAdjustment = true; > } > >@@ -1100,6 +1177,107 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > m_previousBackingStore = nullptr; > } > >+void CoordinatedGraphicsLayer::updateContentBuffers2() >+{ >+ if (!m_nicosia.backingStore) >+ return; >+ >+ auto& impl = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()); >+ auto& layerState = impl.layerState(); >+ layerState.isFlushing = true; >+ >+ auto finishUpdate = >+ [this, &layerState] { >+ auto& update = layerState.update; >+ m_nicosia.performLayerSync = !update.tilesToCreate.isEmpty() >+ || !update.tilesToRemove.isEmpty() || !update.tilesToUpdate.isEmpty(); >+ layerState.isFlushing = false; >+ }; >+ >+ if (m_pendingContentsScaleAdjustment) { >+ 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; >+ } >+ >+ if (!layerState.mainBackingStore) { >+ layerState.mainBackingStore = std::make_unique<TiledBackingStore>(impl, effectiveContentsScale()); >+ m_pendingVisibleRectAdjustment = true; >+ } >+ >+ if (!m_pendingVisibleRectAdjustment && !m_needsDisplay.completeLayer && m_needsDisplay.rects.isEmpty()) { >+ finishUpdate(); >+ return; >+ } >+ >+ if (!m_needsDisplay.completeLayer) { >+ for (auto& rect : m_needsDisplay.rects) >+ layerState.mainBackingStore->invalidate(IntRect { rect }); >+ } else >+ layerState.mainBackingStore->invalidate({ { }, IntSize { m_size } }); >+ >+ m_needsDisplay.completeLayer = false; >+ m_needsDisplay.rects.clear(); >+ >+ if (m_pendingVisibleRectAdjustment) { >+ m_pendingVisibleRectAdjustment = false; >+ layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, m_size.width(), m_size.height())); >+ } >+ >+ ASSERT(m_coordinator && m_coordinator->isFlushingLayerChanges()); >+ >+ auto dirtyTiles = layerState.mainBackingStore->dirtyTiles(); >+ if (!dirtyTiles.isEmpty()) { >+ bool didUpdateTiles = false; >+ >+ for (auto& tileReference : dirtyTiles) { >+ auto& tile = tileReference.get(); >+ tile.ensureTileID(); >+ >+ auto& tileRect = tile.rect(); >+ auto& dirtyRect = tile.dirtyRect(); >+ >+ auto coordinatedBuffer = Nicosia::Buffer::create(dirtyRect.size(), contentsOpaque() ? Nicosia::Buffer::NoFlags : Nicosia::Buffer::SupportsAlpha); >+ SurfaceUpdateInfo updateInfo; >+ updateInfo.updateRect = dirtyRect; >+ updateInfo.updateRect.move(-tileRect.x(), -tileRect.y()); >+ updateInfo.buffer = coordinatedBuffer.copyRef(); >+ >+ if (!m_coordinator->paintingEngine().paint(*this, WTFMove(coordinatedBuffer), >+ dirtyRect, layerState.mainBackingStore->mapToContents(dirtyRect), >+ IntRect { { 0, 0 }, dirtyRect.size() }, layerState.mainBackingStore->contentsScale())) >+ continue; >+ >+ impl.updateTile(tile.tileID(), updateInfo, tileRect); >+ >+ tile.markClean(); >+ didUpdateTiles |= true; >+ } >+ >+ if (didUpdateTiles) >+ didUpdateTileBuffers(); >+ } >+ >+ // 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 (layerState.previousBackingStore && layerState.mainBackingStore->visibleAreaIsCovered()) >+ layerState.previousBackingStore = nullptr; >+ >+ if (layerState.hasPendingTileCreation) { >+ setNeedsVisibleRectAdjustment(); >+ notifyFlushRequired(); >+ } >+ finishUpdate(); >+} >+ > void CoordinatedGraphicsLayer::purgeBackingStores() > { > #ifndef NDEBUG >@@ -1107,6 +1285,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..391e667f2d676f391d4222c32d9db13d73e2321c 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(); >@@ -160,8 +160,8 @@ private: > void syncImageBacking(); > void computeTransformedVisibleRect(); > void updateContentBuffers(); >+ void updateContentBuffers2(); > >- void createBackingStore(); > void releaseImageBackingIfNeeded(); > > void notifyFlushRequired(); >@@ -171,7 +171,6 @@ private: > bool shouldHaveBackingStore() const; > bool selfOrAncestorHasActiveTransformAnimation() const; > bool selfOrAncestorHaveNonAffineTransforms(); >- void adjustContentsScale(); > > void setShouldUpdateVisibleRect(); > float effectiveContentsScale(); >@@ -231,6 +230,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..abc27c4ef32339930be496aea69f5ff2f8ac1718 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,290 @@ 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.contentLayer) >+ contentLayerImpl(*committed.contentLayer).proxy().invalidate(); > >-void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (state.tilesToCreate.isEmpty()) >- return; >+ if (committed.backingStore) { >+ auto& compositionState = backingStoreImpl(*committed.backingStore).compositionState(); >+ compositionState.backingStore = nullptr; >+ } > >- 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); >+ 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; >+ >+ m_nicosia.scene->accessState( >+ [this, &layersByBacking](Nicosia::Scene::State& state) >+ { >+ if (state.id == m_nicosia.state.id) >+ return; >+ >+ { >+ auto& rootLayer = texmapLayer(*state.rootLayer); >+ if (rootLayer.id() != m_rootLayerID) { >+ m_rootLayerID = rootLayer.id(); >+ RELEASE_ASSERT(m_rootLayer->children().isEmpty()); >+ m_rootLayer->addChild(&rootLayer); >+ } >+ } >+ >+ 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); >+ >+ 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); >+ }); >+ } >+ }); >+ >+ 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 +420,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/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >index 4ec0f5ea1a318c18c8ade2cd9b82c3fd75bfb7b2..794204f65b6953ce723f6bb023a4bdfbaedf4d24 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -35,6 +35,8 @@ > #include <WebCore/FrameView.h> > #include <WebCore/GraphicsContext.h> > #include <WebCore/InspectorController.h> >+#include <WebCore/NicosiaBackingStoreTextureMapperImpl.h> >+#include <WebCore/NicosiaImageBackingTextureMapperImpl.h> > #include <WebCore/NicosiaPaintingEngine.h> > #include <WebCore/Page.h> > #include <wtf/MemoryPressureHandler.h> >@@ -130,6 +132,22 @@ bool CompositingCoordinator::flushPendingLayerChanges() > m_state.nicosia.scene->accessState( > [this](Nicosia::Scene::State& state) > { >+ for (auto& compositionLayer : m_nicosia.state.layers) { >+ compositionLayer->flushState( >+ [](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(); >+ } >+ }); >+ } >+ > ++state.id; > 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 22dfeddbb58b3a3b4b5dbd18c54e631e34920674..b001897907ccf0d9d81f1cc93f8ce41e3f2cd7fb 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-17 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: >+ * Source/cmake/OptionsWPE.cmake: >+ > 2018-07-30 Thibault Saunier <tsaunier@igalia.com> > > [GStreamer] Make codecparsers optionnal
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