- Revision
- 292683
- Author
- [email protected]
- Date
- 2022-04-09 15:42:11 -0700 (Sat, 09 Apr 2022)
Log Message
Put layer backing store buffers into the per-RemoteRenderingBackend IOSurfacePool
https://bugs.webkit.org/show_bug.cgi?id=238972
<rdar://83437978>
Reviewed by Tim Horton.
Source/WebCore:
Add IOSurfacePool::create().
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::create):
* platform/graphics/cg/IOSurfacePool.h:
Source/WebKit:
Give each RemoteRenderingBackend its own IOSurfacePool. RemoteImageBuffer gets surfaces
from this pool, and RemoteRenderingBackend::willDestroyImageBuffer() puts surfaces in,
if they are layer backing store surfaces.
The low memory handler removes all surfaces from the pool.
* GPUProcess/graphics/RemoteImageBuffer.h:
(WebKit::RemoteImageBuffer::create):
(WebKit::RemoteImageBuffer::~RemoteImageBuffer):
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
(WebKit::RemoteRenderingBackend::willDestroyImageBuffer):
(WebKit::RemoteRenderingBackend::lowMemoryHandler):
* GPUProcess/graphics/RemoteRenderingBackend.h:
(WebKit::RemoteRenderingBackend::ioSurfacePool const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (292682 => 292683)
--- trunk/Source/WebCore/ChangeLog 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebCore/ChangeLog 2022-04-09 22:42:11 UTC (rev 292683)
@@ -1,3 +1,17 @@
+2022-04-09 Simon Fraser <[email protected]>
+
+ Put layer backing store buffers into the per-RemoteRenderingBackend IOSurfacePool
+ https://bugs.webkit.org/show_bug.cgi?id=238972
+ <rdar://83437978>
+
+ Reviewed by Tim Horton.
+
+ Add IOSurfacePool::create().
+
+ * platform/graphics/cg/IOSurfacePool.cpp:
+ (WebCore::IOSurfacePool::create):
+ * platform/graphics/cg/IOSurfacePool.h:
+
2022-04-09 Chris Dumez <[email protected]>
The Youtube plugin replacement should only work for actual Youtube URLs
Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (292682 => 292683)
--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp 2022-04-09 22:42:11 UTC (rev 292683)
@@ -61,6 +61,11 @@
return pool;
}
+std::unique_ptr<IOSurfacePool> IOSurfacePool::create()
+{
+ return std::unique_ptr<IOSurfacePool>(new IOSurfacePool());
+}
+
static bool surfaceMatchesParameters(IOSurface& surface, IntSize requestedSize, const DestinationColorSpace& colorSpace, IOSurface::Format format)
{
if (format != surface.format())
Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (292682 => 292683)
--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h 2022-04-09 22:42:11 UTC (rev 292683)
@@ -48,11 +48,12 @@
public:
WEBCORE_EXPORT static IOSurfacePool& sharedPool();
+ WEBCORE_EXPORT static std::unique_ptr<IOSurfacePool> create();
std::unique_ptr<IOSurface> takeSurface(IntSize, const DestinationColorSpace&, IOSurface::Format);
WEBCORE_EXPORT void addSurface(std::unique_ptr<IOSurface>&&);
- void discardAllSurfaces();
+ WEBCORE_EXPORT void discardAllSurfaces();
WEBCORE_EXPORT void setPoolSize(size_t);
Modified: trunk/Source/WebKit/ChangeLog (292682 => 292683)
--- trunk/Source/WebKit/ChangeLog 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebKit/ChangeLog 2022-04-09 22:42:11 UTC (rev 292683)
@@ -1,3 +1,27 @@
+2022-04-09 Simon Fraser <[email protected]>
+
+ Put layer backing store buffers into the per-RemoteRenderingBackend IOSurfacePool
+ https://bugs.webkit.org/show_bug.cgi?id=238972
+ <rdar://83437978>
+
+ Reviewed by Tim Horton.
+
+ Give each RemoteRenderingBackend its own IOSurfacePool. RemoteImageBuffer gets surfaces
+ from this pool, and RemoteRenderingBackend::willDestroyImageBuffer() puts surfaces in,
+ if they are layer backing store surfaces.
+
+ The low memory handler removes all surfaces from the pool.
+
+ * GPUProcess/graphics/RemoteImageBuffer.h:
+ (WebKit::RemoteImageBuffer::create):
+ (WebKit::RemoteImageBuffer::~RemoteImageBuffer):
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
+ (WebKit::RemoteRenderingBackend::willDestroyImageBuffer):
+ (WebKit::RemoteRenderingBackend::lowMemoryHandler):
+ * GPUProcess/graphics/RemoteRenderingBackend.h:
+ (WebKit::RemoteRenderingBackend::ioSurfacePool const):
+
2022-04-09 Adrian Perez de Castro <[email protected]>
[GTK][WPE] Missing inter-module documentation links
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (292682 => 292683)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h 2022-04-09 22:42:11 UTC (rev 292683)
@@ -49,7 +49,12 @@
public:
static auto create(const WebCore::FloatSize& size, float resolutionScale, const WebCore::DestinationColorSpace& colorSpace, WebCore::PixelFormat pixelFormat, WebCore::RenderingPurpose purpose, RemoteRenderingBackend& remoteRenderingBackend, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
{
- return BaseConcreteImageBuffer::template create<RemoteImageBuffer>(size, resolutionScale, colorSpace, pixelFormat, purpose, { nullptr }, remoteRenderingBackend, renderingResourceIdentifier);
+ auto context = ImageBuffer::CreationContext { nullptr
+#if HAVE(IOSURFACE)
+ , &remoteRenderingBackend.ioSurfacePool()
+#endif
+ };
+ return BaseConcreteImageBuffer::template create<RemoteImageBuffer>(size, resolutionScale, colorSpace, pixelFormat, purpose, context, remoteRenderingBackend, renderingResourceIdentifier);
}
RemoteImageBuffer(const WebCore::ImageBufferBackend::Parameters& parameters, std::unique_ptr<BackendType>&& backend, RemoteRenderingBackend& remoteRenderingBackend, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
@@ -67,6 +72,8 @@
// been flushed yet, or the web process may have terminated.
while (context().stackSize())
context().restore();
+
+ m_remoteRenderingBackend.willDestroyImageBuffer(*this);
}
void setOwnershipIdentity(const WebCore::ProcessIdentity& resourceOwner)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (292682 => 292683)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-04-09 22:42:11 UTC (rev 292683)
@@ -47,6 +47,10 @@
#include <wtf/StdLibExtras.h>
#include <wtf/SystemTracing.h>
+#if HAVE(IOSURFACE)
+#include <WebCore/IOSurfacePool.h>
+#endif
+
#if ENABLE(IPC_TESTING_API)
#define WEB_PROCESS_TERMINATE_CONDITION !m_gpuConnectionToWebProcess->connection().ignoreInvalidMessageForTesting()
#else
@@ -90,6 +94,9 @@
, m_gpuConnectionToWebProcess(gpuConnectionToWebProcess)
, m_resourceOwner(gpuConnectionToWebProcess.webProcessIdentity())
, m_renderingBackendIdentifier(creationParameters.identifier)
+#if HAVE(IOSURFACE)
+ , m_ioSurfacePool(IOSurfacePool::create())
+#endif
{
ASSERT(RunLoop::isMain());
send(Messages::RemoteRenderingBackendProxy::DidCreateWakeUpSemaphoreForDisplayListStream(m_workQueue->wakeUpSemaphore()), m_renderingBackendIdentifier);
@@ -161,6 +168,14 @@
send(Messages::RemoteRenderingBackendProxy::DidCreateImageBufferBackend(WTFMove(handle), renderingResourceIdentifier.object()), m_renderingBackendIdentifier);
}
+void RemoteRenderingBackend::willDestroyImageBuffer(ImageBuffer& imageBuffer)
+{
+#if HAVE(IOSURFACE)
+ if (imageBuffer.renderingPurpose() == RenderingPurpose::LayerBacking)
+ imageBuffer.releaseBufferToPool(m_ioSurfacePool.get());
+#endif
+}
+
void RemoteRenderingBackend::didFlush(GraphicsContextFlushIdentifier flushIdentifier, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
{
MESSAGE_CHECK(renderingResourceIdentifier.processIdentifier() == m_gpuConnectionToWebProcess->webProcessIdentifier(), "Sending didFlush() message to the wrong web process.");
@@ -543,7 +558,9 @@
void RemoteRenderingBackend::lowMemoryHandler(Critical, Synchronous)
{
ASSERT(isMainRunLoop());
- // This will clear the IOSurfacePool.
+#if HAVE(IOSURFACE)
+ m_ioSurfacePool->discardAllSurfaces();
+#endif
}
} // namespace WebKit
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (292682 => 292683)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2022-04-09 22:25:24 UTC (rev 292682)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2022-04-09 22:42:11 UTC (rev 292683)
@@ -100,6 +100,11 @@
void lowMemoryHandler(WTF::Critical, WTF::Synchronous);
+ void willDestroyImageBuffer(WebCore::ImageBuffer&);
+#if HAVE(IOSURFACE)
+ WebCore::IOSurfacePool& ioSurfacePool() const { return *m_ioSurfacePool; }
+#endif
+
private:
RemoteRenderingBackend(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&, IPC::StreamConnectionBuffer&&);
void startListeningForIPC();
@@ -149,6 +154,9 @@
RenderingBackendIdentifier m_renderingBackendIdentifier;
RefPtr<SharedMemory> m_getPixelBufferSharedMemory;
ScopedRenderingResourcesRequest m_renderingResourcesRequest;
+#if HAVE(IOSURFACE)
+ std::unique_ptr<WebCore::IOSurfacePool> m_ioSurfacePool;
+#endif
Lock m_remoteDisplayListsLock;
bool m_canRegisterRemoteDisplayLists WTF_GUARDED_BY_LOCK(m_remoteDisplayListsLock) { false };