- Revision
- 291178
- Author
- simon.fra...@apple.com
- Date
- 2022-03-11 10:42:03 -0800 (Fri, 11 Mar 2022)
Log Message
Some minor refactoring in RemoteLayerBackingStore
https://bugs.webkit.org/show_bug.cgi?id=237749
Reviewed by Tim Horton.
Simplify RemoteLayerBackingStore a little, primarily to push the setNeedsDisplay() calls
when swapToValidFrontBuffer() returns WebCore::SetNonVolatileResult::Empty out to the
callers, so it's clearer when m_dirtyRegion gets mutated.
In order to pass SetNonVolatileResult around more, change setBufferVolatility(bool) into
setBufferVolatile() and setFrontBufferNonVolatile(), which makes it clear that we only ever
set the front buffer to non-volatile.
Also move the call to clearBackendHandle() into
RemoteLayerWithRemoteRenderingBackingStoreCollection, since it's about GPU process.
* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
(WebKit::RemoteLayerBackingStore::applySwappedBuffers):
(WebKit::RemoteLayerBackingStore::swapBuffers):
(WebKit::RemoteLayerBackingStore::setContents):
(WebKit::RemoteLayerBackingStore::display):
(WebKit::RemoteLayerBackingStore::paintContents):
(WebKit::RemoteLayerBackingStore::setBufferVolatile):
(WebKit::RemoteLayerBackingStore::setFrontBufferNonVolatile):
(WebKit::RemoteLayerBackingStore::willMakeBufferVolatile): Deleted.
(WebKit::RemoteLayerBackingStore::didMakeFrontBufferNonVolatile): Deleted.
(WebKit::RemoteLayerBackingStore::setBufferVolatility): Deleted.
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
(WebKit::RemoteLayerBackingStoreCollection::makeFrontBufferNonVolatile):
(WebKit::RemoteLayerBackingStoreCollection::swapToValidFrontBuffer):
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
* Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h:
* Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm:
(WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::makeFrontBufferNonVolatile):
(WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::swapToValidFrontBuffer):
(WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::collectBackingStoreBufferIdentifiersToMarkVolatile):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (291177 => 291178)
--- trunk/Source/WebKit/ChangeLog 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/ChangeLog 2022-03-11 18:42:03 UTC (rev 291178)
@@ -1,3 +1,45 @@
+2022-03-11 Simon Fraser <simon.fra...@apple.com>
+
+ Some minor refactoring in RemoteLayerBackingStore
+ https://bugs.webkit.org/show_bug.cgi?id=237749
+
+ Reviewed by Tim Horton.
+
+ Simplify RemoteLayerBackingStore a little, primarily to push the setNeedsDisplay() calls
+ when swapToValidFrontBuffer() returns WebCore::SetNonVolatileResult::Empty out to the
+ callers, so it's clearer when m_dirtyRegion gets mutated.
+
+ In order to pass SetNonVolatileResult around more, change setBufferVolatility(bool) into
+ setBufferVolatile() and setFrontBufferNonVolatile(), which makes it clear that we only ever
+ set the front buffer to non-volatile.
+
+ Also move the call to clearBackendHandle() into
+ RemoteLayerWithRemoteRenderingBackingStoreCollection, since it's about GPU process.
+
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
+ (WebKit::RemoteLayerBackingStore::applySwappedBuffers):
+ (WebKit::RemoteLayerBackingStore::swapBuffers):
+ (WebKit::RemoteLayerBackingStore::setContents):
+ (WebKit::RemoteLayerBackingStore::display):
+ (WebKit::RemoteLayerBackingStore::paintContents):
+ (WebKit::RemoteLayerBackingStore::setBufferVolatile):
+ (WebKit::RemoteLayerBackingStore::setFrontBufferNonVolatile):
+ (WebKit::RemoteLayerBackingStore::willMakeBufferVolatile): Deleted.
+ (WebKit::RemoteLayerBackingStore::didMakeFrontBufferNonVolatile): Deleted.
+ (WebKit::RemoteLayerBackingStore::setBufferVolatility): Deleted.
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
+ (WebKit::RemoteLayerBackingStoreCollection::makeFrontBufferNonVolatile):
+ (WebKit::RemoteLayerBackingStoreCollection::swapToValidFrontBuffer):
+ (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
+ * Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h:
+ * Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm:
+ (WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::makeFrontBufferNonVolatile):
+ (WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::swapToValidFrontBuffer):
+ (WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::collectBackingStoreBufferIdentifiersToMarkVolatile):
+
2022-03-11 J Pascoe <j_pas...@apple.com>
[WebAuthn] Cancel running operations in ASA on navigation
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h 2022-03-11 18:42:03 UTC (rev 291178)
@@ -67,6 +67,7 @@
void setContents(WTF::MachSendRight&& surfaceHandle);
// Returns true if the backing store changed.
bool display();
+ void paintContents();
WebCore::FloatSize size() const { return m_size; }
float scale() const { return m_scale; }
@@ -91,8 +92,8 @@
}
// Just for RemoteBackingStoreCollection.
- void applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack, bool frontBufferNeedsDisplay);
- void swapToValidFrontBuffer();
+ void applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack);
+ WebCore::SetNonVolatileResult swapToValidFrontBuffer();
Vector<std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher>> takePendingFlushers();
@@ -102,13 +103,11 @@
SecondaryBack
};
- void willMakeBufferVolatile(BufferType);
- void didMakeFrontBufferNonVolatile(WebCore::SetNonVolatileResult);
-
RefPtr<WebCore::ImageBuffer> bufferForType(BufferType) const;
// Returns true if it was able to fulfill the request. This can fail when trying to mark an in-use surface as volatile.
- bool setBufferVolatility(BufferType, bool isVolatile);
+ bool setBufferVolatile(BufferType);
+ WebCore::SetNonVolatileResult setFrontBufferNonVolatile();
MonotonicTime lastDisplayTime() const { return m_lastDisplayTime; }
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2022-03-11 18:42:03 UTC (rev 291178)
@@ -212,7 +212,7 @@
return 4;
}
-void RemoteLayerBackingStore::swapToValidFrontBuffer()
+WebCore::SetNonVolatileResult RemoteLayerBackingStore::swapToValidFrontBuffer()
{
ASSERT(!WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM));
@@ -233,12 +233,11 @@
m_contentsBufferHandle = std::nullopt;
std::swap(m_frontBuffer, m_backBuffer);
- auto result = setBufferNonVolatile(m_frontBuffer);
- didMakeFrontBufferNonVolatile(result);
+ return setBufferNonVolatile(m_frontBuffer);
}
// Called after buffer swapping in the GPU process.
-void RemoteLayerBackingStore::applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack, bool frontBufferNeedsDisplay)
+void RemoteLayerBackingStore::applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack)
{
ASSERT(WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM));
@@ -245,9 +244,6 @@
m_frontBuffer.imageBuffer = WTFMove(front);
m_backBuffer.imageBuffer = WTFMove(back);
m_secondaryBackBuffer.imageBuffer = WTFMove(secondaryBack);
-
- if (frontBufferNeedsDisplay)
- setNeedsDisplay();
}
void RemoteLayerBackingStore::swapBuffers()
@@ -258,7 +254,10 @@
if (!collection)
return;
- collection->swapToValidFrontBuffer(*this);
+ auto result = collection->swapToValidFrontBuffer(*this);
+ if (result == WebCore::SetNonVolatileResult::Empty)
+ setNeedsDisplay();
+
if (m_frontBuffer.imageBuffer)
return;
@@ -280,7 +279,7 @@
void RemoteLayerBackingStore::setContents(WTF::MachSendRight&& contents)
{
m_contentsBufferHandle = WTFMove(contents);
- m_dirtyRegion = WebCore::Region();
+ m_dirtyRegion = { };
m_paintingRects.clear();
}
@@ -298,9 +297,11 @@
bool needToEncodeBackingStore = collection->backingStoreWillBeDisplayed(*this);
- if (m_layer->owner()->platformCALayerDelegatesDisplay(m_layer)) {
- m_layer->owner()->platformCALayerLayerDisplay(m_layer);
- m_layer->owner()->platformCALayerLayerDidDisplay(m_layer);
+ auto& layerOwner = *m_layer->owner();
+ if (layerOwner.platformCALayerDelegatesDisplay(m_layer)) {
+ // This can call back to setContents(), setting m_contentsBufferHandle.
+ layerOwner.platformCALayerLayerDisplay(m_layer);
+ layerOwner.platformCALayerLayerDidDisplay(m_layer);
return true;
}
@@ -307,7 +308,8 @@
LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore::display()");
// Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty.
- collection->makeFrontBufferNonVolatile(*this);
+ if (collection->makeFrontBufferNonVolatile(*this) == WebCore::SetNonVolatileResult::Empty)
+ setNeedsDisplay();
if (m_dirtyRegion.isEmpty() || m_size.isEmpty()) {
LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << " no dirty region");
@@ -314,19 +316,30 @@
return needToEncodeBackingStore;
}
- WebCore::IntRect layerBounds(WebCore::IntPoint(), WebCore::expandedIntSize(m_size));
if (!hasFrontBuffer() || !supportsPartialRepaint())
- m_dirtyRegion.unite(layerBounds);
+ setNeedsDisplay();
- if (m_layer->owner()->platformCALayerShowRepaintCounter(m_layer)) {
+ if (layerOwner.platformCALayerShowRepaintCounter(m_layer)) {
WebCore::IntRect indicatorRect(0, 0, 52, 27);
m_dirtyRegion.unite(indicatorRect);
}
swapBuffers();
- if (!m_frontBuffer.imageBuffer)
- return true;
+ paintContents();
+ return true;
+}
+
+void RemoteLayerBackingStore::paintContents()
+{
+ if (!m_frontBuffer.imageBuffer) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ if (m_dirtyRegion.isEmpty() || m_size.isEmpty())
+ return;
+
if (m_includeDisplayList == IncludeDisplayList::Yes) {
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
auto& displayListContext = m_frontBuffer.displayListImageBuffer->context();
@@ -354,7 +367,7 @@
drawInContext(context);
}
- m_dirtyRegion = WebCore::Region();
+ m_dirtyRegion = { };
m_paintingRects.clear();
m_layer->owner()->platformCALayerLayerDidDisplay(m_layer);
@@ -366,8 +379,6 @@
if (m_includeDisplayList == IncludeDisplayList::Yes)
m_frontBufferFlushers.append(m_frontBuffer.displayListImageBuffer->createFlusher());
#endif
-
- return true;
}
void RemoteLayerBackingStore::drawInContext(WebCore::GraphicsContext& context)
@@ -549,59 +560,31 @@
return buffer.imageBuffer->setNonVolatile();
}
-void RemoteLayerBackingStore::willMakeBufferVolatile(BufferType bufferType)
+bool RemoteLayerBackingStore::setBufferVolatile(BufferType bufferType)
{
- ASSERT(WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM));
+ if (m_type != Type::IOSurface)
+ return true;
- auto buffer = bufferForType(bufferType);
- if (!buffer)
- return;
+ switch (bufferType) {
+ case BufferType::Front:
+ return setBufferVolatile(m_frontBuffer);
- auto* backend = buffer->ensureBackendCreated();
- if (!backend)
- return;
+ case BufferType::Back:
+ return setBufferVolatile(m_backBuffer);
- // Clearing the backend handle in the webcontent process is necessary to have the surface in-use count drop to zero.
- auto* sharing = backend->toBackendSharing();
- if (is<ImageBufferBackendHandleSharing>(sharing))
- downcast<ImageBufferBackendHandleSharing>(*sharing).clearBackendHandle();
-}
+ case BufferType::SecondaryBack:
+ return setBufferVolatile(m_secondaryBackBuffer);
+ }
-void RemoteLayerBackingStore::didMakeFrontBufferNonVolatile(WebCore::SetNonVolatileResult result)
-{
- if (result == WebCore::SetNonVolatileResult::Empty)
- setNeedsDisplay();
+ return true;
}
-bool RemoteLayerBackingStore::setBufferVolatility(BufferType bufferType, bool isVolatile)
+WebCore::SetNonVolatileResult RemoteLayerBackingStore::setFrontBufferNonVolatile()
{
if (m_type != Type::IOSurface)
- return true;
+ return WebCore::SetNonVolatileResult::Valid;
- switch (bufferType) {
- case BufferType::Front: {
- if (isVolatile)
- return setBufferVolatile(m_frontBuffer);
-
- // Becoming non-volatile and the front buffer was purged, so we need to repaint.
- auto result = setBufferNonVolatile(m_frontBuffer);
- didMakeFrontBufferNonVolatile(result);
- break;
- }
- case BufferType::Back:
- if (isVolatile)
- return setBufferVolatile(m_backBuffer);
-
- setBufferNonVolatile(m_backBuffer);
- break;
- case BufferType::SecondaryBack:
- if (isVolatile)
- return setBufferVolatile(m_secondaryBackBuffer);
-
- setBufferNonVolatile(m_secondaryBackBuffer);
- break;
- }
- return true;
+ return setBufferNonVolatile(m_frontBuffer);
}
RefPtr<WebCore::ImageBuffer> RemoteLayerBackingStore::bufferForType(BufferType bufferType) const
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-03-11 18:42:03 UTC (rev 291178)
@@ -33,6 +33,7 @@
namespace WebCore {
class ImageBuffer;
+enum class SetNonVolatileResult : uint8_t;
}
namespace WebKit {
@@ -55,8 +56,8 @@
bool backingStoreWillBeDisplayed(RemoteLayerBackingStore&);
void backingStoreBecameUnreachable(RemoteLayerBackingStore&);
- virtual void makeFrontBufferNonVolatile(RemoteLayerBackingStore&);
- virtual void swapToValidFrontBuffer(RemoteLayerBackingStore&);
+ virtual WebCore::SetNonVolatileResult makeFrontBufferNonVolatile(RemoteLayerBackingStore&);
+ virtual WebCore::SetNonVolatileResult swapToValidFrontBuffer(RemoteLayerBackingStore&);
void willFlushLayers();
void willCommitLayerTree(RemoteLayerTreeTransaction&);
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-03-11 18:42:03 UTC (rev 291178)
@@ -106,14 +106,14 @@
return true;
}
-void RemoteLayerBackingStoreCollection::makeFrontBufferNonVolatile(RemoteLayerBackingStore& backingStore)
+WebCore::SetNonVolatileResult RemoteLayerBackingStoreCollection::makeFrontBufferNonVolatile(RemoteLayerBackingStore& backingStore)
{
- backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Front, false);
+ return backingStore.setFrontBufferNonVolatile();
}
-void RemoteLayerBackingStoreCollection::swapToValidFrontBuffer(RemoteLayerBackingStore& backingStore)
+WebCore::SetNonVolatileResult RemoteLayerBackingStoreCollection::swapToValidFrontBuffer(RemoteLayerBackingStore& backingStore)
{
- backingStore.swapToValidFrontBuffer();
+ return backingStore.swapToValidFrontBuffer();
}
bool RemoteLayerBackingStoreCollection::markBackingStoreVolatile(RemoteLayerBackingStore& backingStore, OptionSet<VolatilityMarkingBehavior> markingBehavior, MonotonicTime now)
@@ -124,7 +124,7 @@
auto timeSinceLastDisplay = now - backingStore.lastDisplayTime();
if (timeSinceLastDisplay < volatileBackingStoreAgeThreshold) {
if (timeSinceLastDisplay >= volatileSecondaryBackingStoreAgeThreshold)
- backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true);
+ backingStore.setBufferVolatile(RemoteLayerBackingStore::BufferType::SecondaryBack);
return false;
}
@@ -132,14 +132,14 @@
bool successfullyMadeBackingStoreVolatile = true;
- if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true))
+ if (!backingStore.setBufferVolatile(RemoteLayerBackingStore::BufferType::SecondaryBack))
successfullyMadeBackingStoreVolatile = false;
- if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Back, true))
+ if (!backingStore.setBufferVolatile(RemoteLayerBackingStore::BufferType::Back))
successfullyMadeBackingStoreVolatile = false;
if (!m_reachableBackingStoreInLatestFlush.contains(&backingStore) || markingBehavior.contains(VolatilityMarkingBehavior::IgnoreReachability)) {
- if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Front, true))
+ if (!backingStore.setBufferVolatile(RemoteLayerBackingStore::BufferType::Front))
successfullyMadeBackingStoreVolatile = false;
}
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h 2022-03-11 18:42:03 UTC (rev 291178)
@@ -43,8 +43,8 @@
RemoteRenderingBackendProxy& remoteRenderingBackendProxy();
- void makeFrontBufferNonVolatile(RemoteLayerBackingStore&) final;
- void swapToValidFrontBuffer(RemoteLayerBackingStore&) final;
+ WebCore::SetNonVolatileResult makeFrontBufferNonVolatile(RemoteLayerBackingStore&) final;
+ WebCore::SetNonVolatileResult swapToValidFrontBuffer(RemoteLayerBackingStore&) final;
bool collectBackingStoreBufferIdentifiersToMarkVolatile(RemoteLayerBackingStore&, OptionSet<VolatilityMarkingBehavior>, MonotonicTime now, Vector<WebCore::RenderingResourceIdentifier>&);
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm (291177 => 291178)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm 2022-03-11 18:25:39 UTC (rev 291177)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm 2022-03-11 18:42:03 UTC (rev 291178)
@@ -43,11 +43,11 @@
return layerTreeContext().ensureRemoteRenderingBackendProxy();
}
-void RemoteLayerWithRemoteRenderingBackingStoreCollection::makeFrontBufferNonVolatile(RemoteLayerBackingStore& backingStore)
+WebCore::SetNonVolatileResult RemoteLayerWithRemoteRenderingBackingStoreCollection::makeFrontBufferNonVolatile(RemoteLayerBackingStore& backingStore)
{
auto frontBuffer = backingStore.bufferForType(RemoteLayerBackingStore::BufferType::Front);
if (!frontBuffer)
- return;
+ return WebCore::SetNonVolatileResult::Empty;
auto hasBackendHandle = [](const WebCore::ImageBuffer& buffer) {
if (auto* backend = buffer.ensureBackendCreated()) {
@@ -61,14 +61,13 @@
LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerWithRemoteRenderingBackingStoreCollection::makeFrontBufferNonVolatile - front buffer " << frontBuffer->renderingResourceIdentifier() << " is non volatile " << (frontBuffer->volatilityState() == WebCore::VolatilityState::NonVolatile));
if (frontBuffer->volatilityState() == WebCore::VolatilityState::NonVolatile && hasBackendHandle(*frontBuffer))
- return;
+ return WebCore::SetNonVolatileResult::Valid;
auto& remoteRenderingBackend = layerTreeContext().ensureRemoteRenderingBackendProxy();
- auto result = remoteRenderingBackend.markSurfaceNonVolatile(frontBuffer->renderingResourceIdentifier());
- backingStore.didMakeFrontBufferNonVolatile(result);
+ return remoteRenderingBackend.markSurfaceNonVolatile(frontBuffer->renderingResourceIdentifier());
}
-void RemoteLayerWithRemoteRenderingBackingStoreCollection::swapToValidFrontBuffer(RemoteLayerBackingStore& backingStore)
+WebCore::SetNonVolatileResult RemoteLayerWithRemoteRenderingBackingStoreCollection::swapToValidFrontBuffer(RemoteLayerBackingStore& backingStore)
{
auto& remoteRenderingBackend = layerTreeContext().ensureRemoteRenderingBackendProxy();
@@ -78,7 +77,8 @@
backingStore.bufferForType(RemoteLayerBackingStore::BufferType::SecondaryBack)
};
auto swapResult = remoteRenderingBackend.swapToValidFrontBuffer(WTFMove(identifiers));
- backingStore.applySwappedBuffers(WTFMove(swapResult.buffers.front), WTFMove(swapResult.buffers.back), WTFMove(swapResult.buffers.secondaryBack), swapResult.frontBufferWasEmpty);
+ backingStore.applySwappedBuffers(WTFMove(swapResult.buffers.front), WTFMove(swapResult.buffers.back), WTFMove(swapResult.buffers.secondaryBack));
+ return swapResult.frontBufferWasEmpty ? WebCore::SetNonVolatileResult::Empty : WebCore::SetNonVolatileResult::Valid;
}
RefPtr<WebCore::ImageBuffer> RemoteLayerWithRemoteRenderingBackingStoreCollection::allocateBufferForBackingStore(const RemoteLayerBackingStore& backingStore)
@@ -99,7 +99,13 @@
if (buffer->volatilityState() != WebCore::VolatilityState::NonVolatile)
return;
- backingStore.willMakeBufferVolatile(bufferType);
+ // Clearing the backend handle in the webcontent process is necessary to have the surface in-use count drop to zero.
+ if (auto* backend = buffer->ensureBackendCreated()) {
+ auto* sharing = backend->toBackendSharing();
+ if (is<ImageBufferBackendHandleSharing>(sharing))
+ downcast<ImageBufferBackendHandleSharing>(*sharing).clearBackendHandle();
+ }
+
identifiers.append(buffer->renderingResourceIdentifier());
};