Diff
Modified: trunk/Source/WebKit/ChangeLog (287287 => 287288)
--- trunk/Source/WebKit/ChangeLog 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/ChangeLog 2021-12-21 00:33:43 UTC (rev 287288)
@@ -1,3 +1,78 @@
+2021-12-20 Fujii Hironori <hironori.fu...@sony.com>
+
+ WC variant RemoteGraphicsContextGL::platformLayer() should be removed
+ https://bugs.webkit.org/show_bug.cgi?id=233756
+ <rdar://problem/86261919>
+
+ Reviewed by Kimmo Kinnunen.
+
+ WinCairo is using TextureMapperGCGLPlatformLayer as the WebGL
+ PlatformLayer at the moment, that is using only a single output
+ buffer. And, WinCairo doesn't transfer the WebGL output buffer
+ cross-process boundary even in GPU process mode. Based on these
+ assumptions, r285099 added platformLayer() method to
+ RemoteGraphicsContextGL to get a PlatformLayer and pass it to the
+ compositor in GPU process.
+
+ However, this is not appropriate. The output buffer identifier
+ should be transferred to web process by using the completion
+ handler of RemoteGraphicsContextGL::PrepareForDisplay message.
+ Then, the identifier will be passed back to GPU process.
+
+ Added WCContentBufferManager to manage the WebGL output buffer
+ identifiers. However, because TextureMapperGCGLPlatformLayer has
+ only a single output buffer, the maximum number of identifiers is
+ one for each PlatformLayer now.
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::didClose):
+ (WebKit::GPUConnectionToWebProcess::releaseWCLayerTreeHost):
+ (WebKit::GPUConnectionToWebProcess::findRemoteGraphicsContextGL): Deleted.
+ * GPUProcess/GPUConnectionToWebProcess.h:
+ * GPUProcess/graphics/RemoteGraphicsContextGL.h:
+ * GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
+ * GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp:
+ (WebKit::RemoteGraphicsContextGLWin::prepareForDisplay):
+ (WebKit::RemoteGraphicsContextGL::prepareForDisplay): Deleted.
+ (WebKit::RemoteGraphicsContextGL::platformLayer const): Deleted.
+ * GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp:
+ (WebKit::RemoteWCLayerTreeHost::RemoteWCLayerTreeHost):
+ (WebKit::RemoteWCLayerTreeHost::update):
+ * GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h:
+ * GPUProcess/graphics/wc/WCContentBuffer.h: Added.
+ * GPUProcess/graphics/wc/WCContentBufferManager.cpp: Added.
+ (WebKit::WCContentBufferManager::ProcessInfo::ProcessInfo):
+ (WebKit::WCContentBufferManager::ProcessInfo::acquireContentBufferIdentifier):
+ (WebKit::WCContentBufferManager::ProcessInfo::releaseContentBufferIdentifier):
+ (WebKit::WCContentBufferManager::ProcessInfo::removeContentBuffer):
+ (WebKit::WCContentBufferManager::singleton):
+ (WebKit::WCContentBufferManager::acquireContentBufferIdentifier):
+ (WebKit::WCContentBufferManager::releaseContentBufferIdentifier):
+ (WebKit::WCContentBufferManager::removeContentBuffer):
+ (WebKit::WCContentBufferManager::removeAllContentBuffersForProcess):
+ * GPUProcess/graphics/wc/WCContentBufferManager.h: Added.
+ * GPUProcess/graphics/wc/WCScene.cpp:
+ (WebKit::WCScene::WCScene):
+ (WebKit::WCScene::update):
+ * GPUProcess/graphics/wc/WCScene.h:
+ * PlatformWin.cmake:
+ * Scripts/webkit/messages.py:
+ (types_that_cannot_be_forward_declared):
+ (conditions_for_header):
+ * Shared/wc/WCContentBufferIdentifier.h: Added.
+ * WebProcess/GPU/graphics/wc/RemoteGraphicsContextGLProxyWC.cpp:
+ * WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h:
+ (WebKit::WCPlatformLayerGCGL::takeContentBufferIdentifiers):
+ (WebKit::WCPlatformLayerGCGL::addContentBufferIdentifier):
+ (WebKit::WCPlatformLayerGCGL::WCPlatformLayerGCGL): Deleted.
+ (WebKit::WCPlatformLayerGCGL::graphicsContextGLIdentifier): Deleted.
+ * WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
+ (WebKit::GraphicsLayerWC::setContentsNeedsDisplay):
+ (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
+ * WebProcess/WebPage/wc/WCUpateInfo.h:
+ (WebKit::WCLayerUpateInfo::encode const):
+ (WebKit::WCLayerUpateInfo::decode):
+
2021-12-20 Wenson Hsieh <wenson_hs...@apple.com>
Add some missing API availability macros around some WebXR SPI
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -146,6 +146,7 @@
#if USE(GRAPHICS_LAYER_WC)
#include "RemoteWCLayerTreeHost.h"
+#include "WCContentBufferManager.h"
#endif
namespace WebKit {
@@ -303,6 +304,11 @@
// RemoteGraphicsContextsGL objects are unneeded after connection closes.
m_remoteGraphicsContextGLMap.clear();
#endif
+#if USE(GRAPHICS_LAYER_WC)
+ remoteGraphicsContextGLStreamWorkQueue().dispatch([webProcessIdentifier = m_webProcessIdentifier] {
+ WCContentBufferManager::singleton().removeAllContentBuffersForProcess(webProcessIdentifier);
+ });
+#endif
gpuProcess().connectionToWebProcessClosed(connection);
gpuProcess().removeGPUConnectionToWebProcess(*this); // May destroy |this|.
@@ -359,12 +365,6 @@
{
m_remoteWCLayerTreeHostMap.remove(identifier);
}
-
-RefPtr<RemoteGraphicsContextGL> GPUConnectionToWebProcess::findRemoteGraphicsContextGL(GraphicsContextGLIdentifier identifier)
-{
- ASSERT(RunLoop::isMain());
- return m_remoteGraphicsContextGLMap.get(identifier);
-}
#endif
bool GPUConnectionToWebProcess::allowsExitUnderMemoryPressure() const
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -175,10 +175,6 @@
RemoteImageDecoderAVFProxy& imageDecoderAVFProxy();
#endif
-#if USE(GRAPHICS_LAYER_WC)
- RefPtr<RemoteGraphicsContextGL> findRemoteGraphicsContextGL(GraphicsContextGLIdentifier);
-#endif
-
void updateSupportedRemoteCommands();
bool allowsExitUnderMemoryPressure() const;
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -50,6 +50,10 @@
#include <CoreGraphics/CGDisplayConfiguration.h>
#endif
+#if USE(GRAPHICS_LAYER_WC)
+#include "WCContentBufferIdentifier.h"
+#endif
+
#if PLATFORM(COCOA)
namespace WTF {
class MachSendRight;
@@ -73,11 +77,6 @@
void displayWasReconfigured();
#endif
-#if USE(GRAPHICS_LAYER_WC)
- // FIXME: This is layering violation and should be removed.
- PlatformLayer* platformLayer() const;
-#endif
-
protected:
RemoteGraphicsContextGL(GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&);
void initialize(WebCore::GraphicsContextGLAttributes&&);
@@ -100,6 +99,8 @@
void notifyMarkContextChanged();
#if PLATFORM(COCOA)
virtual void prepareForDisplay(CompletionHandler<void(WTF::MachSendRight&&)>&&) = 0;
+#elif USE(GRAPHICS_LAYER_WC)
+ virtual void prepareForDisplay(CompletionHandler<void(std::optional<WCContentBufferIdentifier>)>&&) = 0;
#else
void prepareForDisplay(CompletionHandler<void()>&&);
#endif
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in 2021-12-21 00:33:43 UTC (rev 287288)
@@ -29,7 +29,10 @@
#if PLATFORM(COCOA)
void PrepareForDisplay() -> (MachSendRight displayBuffer) Synchronous NotStreamEncodableReply
#endif
-#if !PLATFORM(COCOA)
+#if USE(GRAPHICS_LAYER_WC)
+ void PrepareForDisplay() -> (std::optional<WebKit::WCContentBufferIdentifier> contentBuffer) Synchronous
+#endif
+#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC)
void PrepareForDisplay() -> () Synchronous
#endif
void EnsureExtensionEnabled(String extension)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -29,6 +29,7 @@
#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && PLATFORM(WIN)
#include "GPUConnectionToWebProcess.h"
+#include "WCContentBufferManager.h"
#include <WebCore/GraphicsContextGLTextureMapper.h>
namespace WebKit {
@@ -40,6 +41,7 @@
// RemoteGraphicsContextGL overrides.
void platformWorkQueueInitialize(WebCore::GraphicsContextGLAttributes&&) final;
+ void prepareForDisplay(CompletionHandler<void(std::optional<WCContentBufferIdentifier>)>&&) final;
};
Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, WebCore::GraphicsContextGLAttributes&& attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream)
@@ -59,19 +61,13 @@
m_context = WebCore::GraphicsContextGLTextureMapper::create(WTFMove(attributes));
}
-void RemoteGraphicsContextGL::prepareForDisplay(CompletionHandler<void()>&& completionHandler)
+void RemoteGraphicsContextGLWin::prepareForDisplay(CompletionHandler<void(std::optional<WCContentBufferIdentifier>)>&& completionHandler)
{
m_context->prepareForDisplay();
- completionHandler();
+ auto identifier = WCContentBufferManager::singleton().acquireContentBufferIdentifier(m_webProcessIdentifier, m_context->layerContentsDisplayDelegate()->platformLayer());
+ completionHandler(identifier);
}
-#if USE(GRAPHICS_LAYER_WC)
-PlatformLayer* RemoteGraphicsContextGL::platformLayer() const
-{
- return m_context->layerContentsDisplayDelegate()->platformLayer();
}
-#endif
-}
-
#endif
Modified: trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -46,11 +46,12 @@
RemoteWCLayerTreeHost::RemoteWCLayerTreeHost(GPUConnectionToWebProcess& connectionToWebProcess, WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow)
: m_connectionToWebProcess(connectionToWebProcess)
+ , m_webProcessIdentifier(connectionToWebProcess.webProcessIdentifier())
, m_identifier(identifier)
, m_sharedSceneContextHolder(connectionToWebProcess.gpuProcess().sharedSceneContext().ensureHolderForWindow(nativeWindow))
{
m_connectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteWCLayerTreeHost::messageReceiverName(), m_identifier.toUInt64(), *this);
- m_scene = makeUnique<WCScene>();
+ m_scene = makeUnique<WCScene>(m_webProcessIdentifier);
remoteGraphicsContextGLStreamWorkQueue().dispatch([scene = m_scene.get(), sceneContextHolder = m_sharedSceneContextHolder.get(), nativeWindow] {
if (!sceneContextHolder->context)
sceneContextHolder->context.emplace(nativeWindow);
@@ -82,17 +83,8 @@
void RemoteWCLayerTreeHost::update(WCUpateInfo&& update)
{
- // findRemoteGraphicsContextGL should be called on the main thread
- auto remoteGCGL = WTF::map(update.changedLayers, [this](auto& layerUpdate) -> RefPtr<RemoteGraphicsContextGL> {
- if (layerUpdate.changes & WCLayerChange::PlatformLayer) {
- if (layerUpdate.graphicsContextGLIdentifier)
- return m_connectionToWebProcess->findRemoteGraphicsContextGL(makeObjectIdentifier<GraphicsContextGLIdentifierType>(layerUpdate.graphicsContextGLIdentifier));
- }
- return nullptr;
- });
-
- remoteGraphicsContextGLStreamWorkQueue().dispatch([this, weakThis = WeakPtr(*this), scene = m_scene.get(), update = WTFMove(update), remoteGCGL = WTFMove(remoteGCGL)]() mutable {
- scene->update(WTFMove(update), WTFMove(remoteGCGL));
+ remoteGraphicsContextGLStreamWorkQueue().dispatch([this, weakThis = WeakPtr(*this), scene = m_scene.get(), update = WTFMove(update)]() mutable {
+ scene->update(WTFMove(update));
RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis)] {
if (!weakThis)
return;
Modified: trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -32,6 +32,7 @@
#include "MessageSender.h"
#include "WCLayerTreeHostIdentifier.h"
#include "WCSharedSceneContextHolder.h"
+#include <WebCore/ProcessIdentifier.h>
namespace WebKit {
class GPUConnectionToWebProcess;
@@ -55,6 +56,7 @@
uint64_t messageSenderDestinationID() const override;
WeakPtr<GPUConnectionToWebProcess> m_connectionToWebProcess;
+ WebCore::ProcessIdentifier m_webProcessIdentifier;
WCLayerTreeHostIdentifier m_identifier;
RefPtr<WCSharedSceneContextHolder::Holder> m_sharedSceneContextHolder;
std::unique_ptr<WCScene> m_scene;
Added: trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBuffer.h (0 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBuffer.h (rev 0)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBuffer.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(GRAPHICS_LAYER_WC)
+
+#include "WCContentBufferIdentifier.h"
+#include "WCContentBufferManager.h"
+#include <WebCore/ProcessIdentifier.h>
+#include <WebCore/TextureMapperPlatformLayer.h>
+
+namespace WebKit {
+
+class WCContentBuffer final : WebCore::TextureMapperPlatformLayer::Client {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ class Client {
+ public:
+ virtual void platformLayerWillBeDestroyed() = 0;
+ };
+
+ WCContentBuffer(WCContentBufferManager& manager, WebCore::ProcessIdentifier processIdentifier, WebCore::TextureMapperPlatformLayer* platformLayer)
+ : m_manager(manager)
+ , m_processIdentifier(processIdentifier)
+ , m_platformLayer(platformLayer)
+ {
+ m_platformLayer->setClient(this);
+ }
+
+ ~WCContentBuffer()
+ {
+ m_platformLayer->setClient(nullptr);
+ }
+
+ void setClient(Client* client)
+ {
+ m_client = client;
+ }
+
+ WebCore::TextureMapperPlatformLayer* platformLayer() const
+ {
+ return m_platformLayer;
+ }
+
+ WCContentBufferIdentifier identifier()
+ {
+ return m_identifier;
+ }
+
+private:
+ void platformLayerWillBeDestroyed() override
+ {
+ if (m_client)
+ m_client->platformLayerWillBeDestroyed();
+ m_manager.removeContentBuffer(m_processIdentifier, *this);
+ }
+ void setPlatformLayerNeedsDisplay() override { }
+
+ WCContentBufferManager& m_manager;
+ WebCore::ProcessIdentifier m_processIdentifier;
+ WCContentBufferIdentifier m_identifier { WCContentBufferIdentifier::generate() };
+ WebCore::TextureMapperPlatformLayer* m_platformLayer;
+ Client* m_client { nullptr };
+};
+
+} // namespace WebKit
+
+#endif // USE(GRAPHICS_LAYER_WC)
Added: trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.cpp (0 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.cpp (rev 0)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WCContentBufferManager.h"
+
+#if USE(GRAPHICS_LAYER_WC)
+
+#include "WCContentBuffer.h"
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WCContentBufferManager::ProcessInfo {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ProcessInfo(WCContentBufferManager& manager, WebCore::ProcessIdentifier processIdentifier)
+ : m_manager(manager)
+ , m_processIdentifier(processIdentifier) { }
+
+ std::optional<WCContentBufferIdentifier> acquireContentBufferIdentifier(WebCore::TextureMapperPlatformLayer* platformLayer)
+ {
+ // FIXME: TextureMapperGCGLPlatformLayer doesn't support double buffering yet.
+ // TextureMapperPlatformLayer can acquire a single WCContentBufferIdentifier.
+ auto contentBufferAddResult = m_contentBuffers.ensure(platformLayer, [&] {
+ return makeUnique<WCContentBuffer>(m_manager, m_processIdentifier, platformLayer);
+ });
+ WCContentBuffer* buffer = contentBufferAddResult.iterator->value.get();
+ auto identifier = buffer->identifier();
+ auto identifierAddResult = m_validIdentifiers.add(identifier, buffer);
+ if (!identifierAddResult.isNewEntry)
+ return std::nullopt;
+ return identifier;
+ }
+
+ WCContentBuffer* releaseContentBufferIdentifier(WCContentBufferIdentifier identifier)
+ {
+ return m_validIdentifiers.take(identifier);
+ }
+
+ void removeContentBuffer(WCContentBuffer& contentBuffer)
+ {
+ m_validIdentifiers.remove(contentBuffer.identifier());
+ m_contentBuffers.remove(contentBuffer.platformLayer());
+ }
+
+private:
+ WCContentBufferManager& m_manager;
+ WebCore::ProcessIdentifier m_processIdentifier;
+ HashMap<WebCore::TextureMapperPlatformLayer*, std::unique_ptr<WCContentBuffer>> m_contentBuffers;
+ HashMap<WCContentBufferIdentifier, WCContentBuffer*> m_validIdentifiers;
+};
+
+WCContentBufferManager& WCContentBufferManager::singleton()
+{
+ static NeverDestroyed<WCContentBufferManager> contentBufferManager;
+ return contentBufferManager;
+}
+
+std::optional<WCContentBufferIdentifier> WCContentBufferManager::acquireContentBufferIdentifier(WebCore::ProcessIdentifier processIdentifier, WebCore::TextureMapperPlatformLayer* platformLayer)
+{
+ auto processAddResult = m_processMap.ensure(processIdentifier, [&] {
+ return makeUnique<ProcessInfo>(*this, processIdentifier);
+ });
+ return processAddResult.iterator->value->acquireContentBufferIdentifier(platformLayer);
+}
+
+WCContentBuffer* WCContentBufferManager::releaseContentBufferIdentifier(WebCore::ProcessIdentifier processIdentifier, WCContentBufferIdentifier contentBufferIdentifier)
+{
+ ASSERT(m_processMap.contains(processIdentifier));
+ return m_processMap.get(processIdentifier)->releaseContentBufferIdentifier(contentBufferIdentifier);
+}
+
+void WCContentBufferManager::removeContentBuffer(WebCore::ProcessIdentifier processIdentifier, WCContentBuffer& contentBuffer)
+{
+ ASSERT(m_processMap.contains(processIdentifier));
+ m_processMap.get(processIdentifier)->removeContentBuffer(contentBuffer);
+}
+
+void WCContentBufferManager::removeAllContentBuffersForProcess(WebCore::ProcessIdentifier processIdentifier)
+{
+ m_processMap.remove(processIdentifier);
+}
+
+} // namespace WebKit
+
+#endif // USE(GRAPHICS_LAYER_WC)
Copied: trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.h (from rev 287286, trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.h) (0 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.h (rev 0)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCContentBufferManager.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(GRAPHICS_LAYER_WC)
+
+#include "WCContentBufferIdentifier.h"
+#include <WebCore/PlatformLayer.h>
+#include <WebCore/ProcessIdentifier.h>
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+class TextureMapperPlatformLayer;
+}
+
+namespace WebKit {
+
+class WCContentBuffer;
+
+class WCContentBufferManager {
+public:
+ class ProcessInfo;
+
+ static WCContentBufferManager& singleton();
+
+ std::optional<WCContentBufferIdentifier> acquireContentBufferIdentifier(WebCore::ProcessIdentifier, WebCore::TextureMapperPlatformLayer*);
+ WCContentBuffer* releaseContentBufferIdentifier(WebCore::ProcessIdentifier, WCContentBufferIdentifier);
+ void removeContentBuffer(WebCore::ProcessIdentifier, WCContentBuffer&);
+ void removeAllContentBuffersForProcess(WebCore::ProcessIdentifier);
+
+private:
+ HashMap<WebCore::ProcessIdentifier, std::unique_ptr<ProcessInfo>> m_processMap;
+};
+
+} // namespace WebKit
+
+#endif // USE(GRAPHICS_LAYER_WC)
Modified: trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -29,25 +29,27 @@
#if USE(GRAPHICS_LAYER_WC)
#include "RemoteGraphicsContextGL.h"
+#include "WCContentBuffer.h"
+#include "WCContentBufferManager.h"
#include "WCSceneContext.h"
#include "WCUpateInfo.h"
#include <WebCore/GraphicsContextGLOpenGL.h>
#include <WebCore/TextureMapperLayer.h>
+#include <WebCore/TextureMapperPlatformLayer.h>
#include <WebCore/TextureMapperTiledBackingStore.h>
namespace WebKit {
-struct WCScene::Layer : public WebCore::TextureMapperPlatformLayer::Client {
+struct WCScene::Layer final : public WCContentBuffer::Client {
WTF_MAKE_FAST_ALLOCATED;
public:
Layer() = default;
- // TextureMapperPlatformLayer::Client
+ // WCContentBuffer::Client
void platformLayerWillBeDestroyed() override
{
texmapLayer.setContentsLayer(nullptr);
}
- void setPlatformLayerNeedsDisplay() override { }
WebCore::TextureMapperLayer texmapLayer;
RefPtr<WebCore::TextureMapperTiledBackingStore> backingStore;
@@ -62,7 +64,10 @@
m_textureMapper = m_context->createTextureMapper();
}
-WCScene::WCScene() = default;
+WCScene::WCScene(WebCore::ProcessIdentifier webProcessIdentifier)
+ : m_webProcessIdentifier(webProcessIdentifier)
+{
+}
WCScene::~WCScene()
{
@@ -70,7 +75,7 @@
m_textureMapper = nullptr;
}
-void WCScene::update(WCUpateInfo&& update, Vector<RefPtr<RemoteGraphicsContextGL>>&& remoteGCGL)
+void WCScene::update(WCUpateInfo&& update)
{
if (!m_context->makeContextCurrent())
return;
@@ -80,8 +85,6 @@
m_layers.add(id, WTFMove(layer));
}
- auto remoteGCGLIterator = remoteGCGL.begin();
-
for (auto& layerUpdate : update.changedLayers) {
auto layer = m_layers.get(layerUpdate.id);
if (layerUpdate.changes & WCLayerChange::Children) {
@@ -165,16 +168,19 @@
layer->texmapLayer.setBackdropFiltersRect(layerUpdate.backdropFiltersRect);
}
if (layerUpdate.changes & WCLayerChange::PlatformLayer) {
- if (*remoteGCGLIterator) {
- auto platformLayer = (*remoteGCGLIterator)->platformLayer();
- platformLayer->setClient(layer);
- layer->texmapLayer.setContentsLayer(platformLayer);
- } else
+ if (!layerUpdate.hasPlatformLayer)
layer->texmapLayer.setContentsLayer(nullptr);
+ else {
+ WCContentBuffer* contentBuffer = nullptr;
+ for (auto identifier : layerUpdate.contentBufferIdentifiers)
+ contentBuffer = WCContentBufferManager::singleton().releaseContentBufferIdentifier(m_webProcessIdentifier, identifier);
+ if (contentBuffer) {
+ contentBuffer->setClient(layer);
+ layer->texmapLayer.setContentsLayer(contentBuffer->platformLayer());
+ }
+ }
}
- remoteGCGLIterator++;
}
- ASSERT(remoteGCGLIterator == remoteGCGL.end());
for (auto id : update.removedLayers)
m_layers.remove(id);
Modified: trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.h (287287 => 287288)
--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -27,6 +27,7 @@
#if USE(GRAPHICS_LAYER_WC)
+#include <WebCore/ProcessIdentifier.h>
#include <WebCore/TextureMapperFPSCounter.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
@@ -34,12 +35,12 @@
namespace WebCore {
class TextureMapper;
class TextureMapperLayer;
+class TextureMapperPlatformLayer;
class TextureMapperTiledBackingStore;
}
namespace WebKit {
-class RemoteGraphicsContextGL;
class WCSceneContext;
struct WCUpateInfo;
@@ -46,15 +47,16 @@
class WCScene {
WTF_MAKE_FAST_ALLOCATED;
public:
- WCScene();
+ WCScene(WebCore::ProcessIdentifier);
~WCScene();
void initialize(WCSceneContext&);
- void update(WCUpateInfo&&, Vector<RefPtr<RemoteGraphicsContextGL>>&&);
+ void update(WCUpateInfo&&);
private:
struct Layer;
using LayerMap = HashMap<uint64_t, std::unique_ptr<Layer>>;
+ WebCore::ProcessIdentifier m_webProcessIdentifier;
WCSceneContext* m_context { nullptr };
std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
WebCore::TextureMapperFPSCounter m_fpsCounter;
Modified: trunk/Source/WebKit/PlatformWin.cmake (287287 => 287288)
--- trunk/Source/WebKit/PlatformWin.cmake 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/PlatformWin.cmake 2021-12-21 00:33:43 UTC (rev 287288)
@@ -12,6 +12,7 @@
GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp
GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp
+ GPUProcess/graphics/wc/WCContentBufferManager.cpp
GPUProcess/graphics/wc/WCScene.cpp
GPUProcess/graphics/wc/WCSceneContext.cpp
@@ -120,6 +121,7 @@
"${WEBKIT_DIR}/Shared/CoordinatedGraphics"
"${WEBKIT_DIR}/Shared/CoordinatedGraphics/threadedcompositor"
"${WEBKIT_DIR}/Shared/Plugins/win"
+ "${WEBKIT_DIR}/Shared/wc"
"${WEBKIT_DIR}/Shared/win"
"${WEBKIT_DIR}/UIProcess/API/C/cairo"
"${WEBKIT_DIR}/UIProcess/API/C/curl"
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (287287 => 287288)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2021-12-21 00:33:43 UTC (rev 287288)
@@ -362,6 +362,7 @@
'WebKit::TransactionID',
'WebKit::UserContentControllerIdentifier',
'WebKit::WCLayerTreeHostIdentifier',
+ 'WebKit::WCContentBufferIdentifier',
'WebKit::WebGPUIdentifier',
'WebKit::WebPageProxyIdentifier',
'WebKit::WebURLSchemeHandlerIdentifier',
@@ -374,6 +375,7 @@
'"InputMethodState.h"': ["PLATFORM(GTK)", "PLATFORM(WPE)"],
'"LayerHostingContext.h"': ["PLATFORM(COCOA)", ],
'"GestureTypes.h"': ["PLATFORM(IOS_FAMILY)"],
+ '"WCContentBufferIdentifier.h"': ["USE(GRAPHICS_LAYER_WC)"],
'"WCLayerTreeHostIdentifier.h"': ["USE(GRAPHICS_LAYER_WC)"],
'<WebCore/CVUtilities.h>': ["PLATFORM(COCOA)", ],
'<WebCore/DataDetectorType.h>': ["ENABLE(DATA_DETECTION)"],
Copied: trunk/Source/WebKit/Shared/wc/WCContentBufferIdentifier.h (from rev 287286, trunk/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h) (0 => 287288)
--- trunk/Source/WebKit/Shared/wc/WCContentBufferIdentifier.h (rev 0)
+++ trunk/Source/WebKit/Shared/wc/WCContentBufferIdentifier.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(GRAPHICS_LAYER_WC)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum WCContentBufferIdentifierType { };
+using WCContentBufferIdentifier = ObjectIdentifier<WCContentBufferIdentifierType>;
+
+} // namespace WebKit
+
+#endif // USE(GRAPHICS_LAYER_WC)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteGraphicsContextGLProxyWC.cpp (287287 => 287288)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteGraphicsContextGLProxyWC.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteGraphicsContextGLProxyWC.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -72,7 +72,7 @@
private:
RemoteGraphicsContextGLProxyWC(GPUProcessConnection& gpuProcessConnection, const WebCore::GraphicsContextGLAttributes& attributes, RenderingBackendIdentifier renderingBackend)
: RemoteGraphicsContextGLProxy(gpuProcessConnection, attributes, renderingBackend)
- , m_layerContentsDisplayDelegate(PlatformLayerDisplayDelegate::create(makeUnique<WCPlatformLayerGCGL>(m_graphicsContextGLIdentifier)))
+ , m_layerContentsDisplayDelegate(PlatformLayerDisplayDelegate::create(makeUnique<WCPlatformLayerGCGL>()))
{
}
@@ -84,11 +84,14 @@
{
if (isContextLost())
return;
- auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::PrepareForDisplay(), Messages::RemoteGraphicsContextGL::PrepareForDisplay::Reply());
+ std::optional<WCContentBufferIdentifier> contentBuffer;
+ auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::PrepareForDisplay(), Messages::RemoteGraphicsContextGL::PrepareForDisplay::Reply(contentBuffer));
if (!sendResult) {
markContextLost();
return;
}
+ if (contentBuffer)
+ static_cast<WCPlatformLayerGCGL*>(m_layerContentsDisplayDelegate->platformLayer())->addContentBufferIdentifier(*contentBuffer);
markLayerComposited();
}
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h (287287 => 287288)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -26,6 +26,7 @@
#pragma once
#include "GraphicsContextGLIdentifier.h"
+#include "WCContentBufferIdentifier.h"
#include <WebCore/WCPlatformLayer.h>
namespace WebKit {
@@ -32,14 +33,20 @@
class WCPlatformLayerGCGL : public WebCore::WCPlatformLayer {
public:
- WCPlatformLayerGCGL(GraphicsContextGLIdentifier identifier)
- : m_graphicsContextGLIdentifier(identifier)
+ Vector<WCContentBufferIdentifier> takeContentBufferIdentifiers()
{
+ return std::exchange(m_contentBufferIdentifiers, { });
}
- GraphicsContextGLIdentifier& graphicsContextGLIdentifier() { return m_graphicsContextGLIdentifier; }
+ void addContentBufferIdentifier(WCContentBufferIdentifier contentBuffer)
+ {
+ m_contentBufferIdentifiers.append(contentBuffer);
+ // FIXME: TextureMapperGCGLPlatformLayer doesn't support double buffering yet.
+ ASSERT(m_contentBufferIdentifiers.size() == 1);
+ }
+
private:
- GraphicsContextGLIdentifier m_graphicsContextGLIdentifier;
+ Vector<WCContentBufferIdentifier> m_contentBufferIdentifiers;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp (287287 => 287288)
--- trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp 2021-12-21 00:33:43 UTC (rev 287288)
@@ -76,7 +76,7 @@
void GraphicsLayerWC::setContentsNeedsDisplay()
{
// For example, if WebGL canvas changed, it needs flush to display.
- noteLayerPropertyChanged({ });
+ noteLayerPropertyChanged(WCLayerChange::PlatformLayer);
}
bool GraphicsLayerWC::setChildren(Vector<Ref<GraphicsLayer>>&& children)
@@ -475,10 +475,9 @@
update.backdropFiltersRect = backdropFiltersRect();
}
if (update.changes & WCLayerChange::PlatformLayer) {
+ update.hasPlatformLayer = m_platformLayer;
if (m_platformLayer)
- update.graphicsContextGLIdentifier = static_cast<WCPlatformLayerGCGL*>(m_platformLayer)->graphicsContextGLIdentifier().toUInt64();
- else
- update.graphicsContextGLIdentifier = 0;
+ update.contentBufferIdentifiers = static_cast<WCPlatformLayerGCGL*>(m_platformLayer)->takeContentBufferIdentifiers();
}
m_observer->commitLayerUpateInfo(WTFMove(update));
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h (287287 => 287288)
--- trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h 2021-12-21 00:33:19 UTC (rev 287287)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h 2021-12-21 00:33:43 UTC (rev 287288)
@@ -26,6 +26,7 @@
#pragma once
#include "WCBackingStore.h"
+#include "WCContentBufferIdentifier.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/GraphicsLayer.h>
#include <optional>
@@ -74,6 +75,7 @@
bool contentsVisible;
bool backfaceVisibility;
bool preserves3D;
+ bool hasPlatformLayer;
WebCore::Color solidColor;
WebCore::Color backgroundColor;
WebCore::Color debugBorderColor;
@@ -88,7 +90,7 @@
WebCore::FilterOperations backdropFilters;
WebCore::FloatRoundedRect backdropFiltersRect;
WebCore::FloatRoundedRect contentsClippingRect;
- uint64_t graphicsContextGLIdentifier;
+ Vector<WCContentBufferIdentifier> contentBufferIdentifiers;
template<class Encoder>
void encode(Encoder& encoder) const
@@ -136,7 +138,7 @@
if (changes & WCLayerChange::BackdropFilters)
encoder << backdropFilters << backdropFiltersRect;
if (changes & WCLayerChange::PlatformLayer)
- encoder << graphicsContextGLIdentifier;
+ encoder << hasPlatformLayer << contentBufferIdentifiers;
}
template <class Decoder>
@@ -241,8 +243,10 @@
return false;
}
if (result.changes & WCLayerChange::PlatformLayer) {
- if (!decoder.decode(result.graphicsContextGLIdentifier))
+ if (!decoder.decode(result.hasPlatformLayer))
return false;
+ if (!decoder.decode(result.contentBufferIdentifiers))
+ return false;
}
return true;
}