WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
wc-2021-10-27.diff (text/plain), 150.17 KB, created by
Fujii Hironori
on 2021-10-26 22:35:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2021-10-26 22:35:52 PDT
Size:
150.17 KB
patch
obsolete
>diff --git a/ChangeLog b/ChangeLog >index 33a50b4fa74e..2cf485fef67a 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,12 @@ >+2021-10-26 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] New GraphicsLayer for GPU process mode >+ https://bugs.webkit.org/show_bug.cgi?id=228308 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/cmake/OptionsWinCairo.cmake: >+ > 2021-10-26 Adrian Perez de Castro <aperez@igalia.com> > > Unreviewed. [WPE] Bump version numbers >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index cad668c648d2..b25e31f6004a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2021-10-26 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] New GraphicsLayer for GPU process mode >+ https://bugs.webkit.org/show_bug.cgi?id=228308 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * PlatformWinCairo.cmake: >+ * platform/graphics/RemoteGraphicsContextGLProxyBase.cpp: >+ * platform/graphics/RemoteGraphicsContextGLProxyBase.h: >+ * platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp: Added. >+ (WebCore::RemoteGraphicsContextGLProxyBase::platformInitialize): >+ (WebCore::RemoteGraphicsContextGLProxyBase::platformLayer const): >+ (WebCore::RemoteGraphicsContextGLProxyBase::setPlatformLayer): >+ * platform/graphics/wc/WCPlatformLayer.h: Added. >+ * platform/graphics/win/GraphicsContextWin.cpp: >+ (WebCore::GraphicsContext::getWindowsContext): DisplayList >+ GraphicsContext doesn't have a HDC. Do nothing for DisplayList >+ context. >+ * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: >+ (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame): >+ Paint a frame by using GraphicsContext::drawNativeImage instead of >+ Cairo API for DisplayList. >+ > 2021-10-26 Tim Horton <timothy_horton@apple.com> > > [GPU Process] `DisplayList::Recorder::getCTM` should include the device scale factor >diff --git a/Source/WebCore/PlatformWinCairo.cmake b/Source/WebCore/PlatformWinCairo.cmake >index d225690f5e04..5ddad9c258e1 100644 >--- a/Source/WebCore/PlatformWinCairo.cmake >+++ b/Source/WebCore/PlatformWinCairo.cmake >@@ -12,6 +12,7 @@ list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES > "${WEBKIT_LIBRARIES_DIR}/include" > "${WEBCORE_DIR}/loader/archive/cf" > "${WEBCORE_DIR}/platform/cf" >+ "${WEBCORE_DIR}/platform/graphics/wc" > ) > > list(APPEND WebCore_SOURCES >@@ -24,6 +25,8 @@ list(APPEND WebCore_SOURCES > > platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp > >+ platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp >+ > platform/graphics/win/FontCustomPlatformDataCairo.cpp > platform/graphics/win/FontPlatformDataCairoWin.cpp > platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp >@@ -44,6 +47,10 @@ list(APPEND WebCore_SOURCES > platform/win/PEImage.cpp > ) > >+list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS >+ platform/graphics/wc/WCPlatformLayer.h >+) >+ > list(APPEND WebCore_LIBRARIES > comctl32 > crypt32 >diff --git a/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.cpp b/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.cpp >index f0c8e4e454d3..8c8cc288f28c 100644 >--- a/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.cpp >+++ b/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.cpp >@@ -33,6 +33,10 @@ > #include "IOSurface.h" > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+#include "TextureMapperPlatformLayer.h" >+#endif >+ > namespace WebCore { > > RemoteGraphicsContextGLProxyBase::RemoteGraphicsContextGLProxyBase(const GraphicsContextGLAttributes& attrs) >@@ -130,7 +134,7 @@ void RemoteGraphicsContextGLProxyBase::initialize(const String& availableExtensi > m_requestableExtensions.add(extension); > } > >-#if !PLATFORM(COCOA) >+#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) > void RemoteGraphicsContextGLProxyBase::platformInitialize() > { > } >diff --git a/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.h b/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.h >index d9c733b6c34e..f1eed5f4c46c 100644 >--- a/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.h >+++ b/Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.h >@@ -96,6 +96,9 @@ protected: > #if PLATFORM(COCOA) > RetainPtr<WebGLLayer> m_webGLLayer; > std::unique_ptr<IOSurface> m_displayBuffer; >+#elif USE(GRAPHICS_LAYER_WC) >+ void setPlatformLayer(PlatformLayerContainer&&); >+ PlatformLayerContainer m_platformLayer; > #endif > private: > void platformInitialize(); >diff --git a/Source/WebCore/platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp b/Source/WebCore/platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp >new file mode 100644 >index 000000000000..c31972c141ca >--- /dev/null >+++ b/Source/WebCore/platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp >@@ -0,0 +1,51 @@ >+/* >+ * 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. ``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 >+ * 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 "RemoteGraphicsContextGLProxyBase.h" >+ >+#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GRAPHICS_LAYER_WC) >+ >+#include "TextureMapperPlatformLayer.h" >+ >+namespace WebCore { >+ >+void RemoteGraphicsContextGLProxyBase::platformInitialize() >+{ >+} >+ >+PlatformLayer* RemoteGraphicsContextGLProxyBase::platformLayer() const >+{ >+ return m_platformLayer.get(); >+} >+ >+void RemoteGraphicsContextGLProxyBase::setPlatformLayer(PlatformLayerContainer&& platformLayer) >+{ >+ m_platformLayer = WTFMove(platformLayer); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/wc/WCPlatformLayer.h b/Source/WebCore/platform/graphics/wc/WCPlatformLayer.h >new file mode 100644 >index 000000000000..ca39e08ccce0 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/wc/WCPlatformLayer.h >@@ -0,0 +1,40 @@ >+/* >+ * 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 >+ >+#include "TextureMapperPlatformLayer.h" >+ >+namespace WebCore { >+ >+class WCPlatformLayer : public TextureMapperPlatformLayer { >+ WTF_MAKE_FAST_ALLOCATED; >+ >+private: >+ // TextureMapperPlatformLayer >+ void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix&, float) final { } >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp >index d5a3ba9438a9..2a1209492d59 100644 >--- a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp >+++ b/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp >@@ -53,6 +53,8 @@ static void fillWithClearColor(HBITMAP bitmap) > > HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend) > { >+ if (!hasPlatformContext()) >+ return nullptr; > HDC hdc = nullptr; > #if !USE(CAIRO) > hdc = deprecatedPrivateContext()->m_hdc; >diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >index e6deb5ec1038..c9d08c7be25e 100644 >--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >@@ -2857,15 +2857,11 @@ void MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame(Web > ASSERT(cairoFormat != CAIRO_FORMAT_INVALID); > > cairo_surface_t* image = nullptr; >- if (cairoFormat != CAIRO_FORMAT_INVALID) >- image = cairo_image_surface_create_for_data(static_cast<unsigned char*>(data), cairoFormat, width, height, pitch); >- >- FloatRect srcRect(0, 0, width, height); >- if (image) { >- ASSERT(context.hasPlatformContext()); >- auto& state = context.state(); >- Cairo::drawSurface(*context.platformContext(), image, destRect, srcRect, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state)); >- cairo_surface_destroy(image); >+ if (cairoFormat != CAIRO_FORMAT_INVALID) { >+ auto surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data), cairoFormat, width, height, pitch)); >+ auto image = NativeImage::create(WTFMove(surface)); >+ FloatRect srcRect(0, 0, width, height); >+ context.drawNativeImage(*image, srcRect.size(), destRect, srcRect); > } > #else > #error "Platform needs to implement drawing of Direct3D surface to graphics context!" >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index e47466249b1f..1d5cae7ae325 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,207 @@ >+2021-10-26 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] New GraphicsLayer for GPU process mode >+ https://bugs.webkit.org/show_bug.cgi?id=228308 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added a new GraphicsLayer implementation GraphicsLayerWC which >+ transfers GraphicsLayer tree to GPU process and runs the >+ compositor (TextureMapper) in GPU process. >+ >+ In GPU process mode, WebGL is run in GPU process. So, the >+ compositor should be run in GPU process. Otherwise, the output >+ texture of WebGL has to be transferred from GPU process to the >+ compositor process (UI process or web process). >+ >+ Because ANGLE isn't thread-safe, the compositor and WebGL should >+ be run in the same thread in GPU process. >+ >+ Enabling gpu_process_webgl also enables GPU process compositing now. >+ > reg add HKEY_CURRENT_USER\Software\WebKit /v gpu_process_webgl /t REG_DWORD /d 1 /f >+ >+ gpu_process_canvas_rendering can also be enabled. >+ > reg add HKEY_CURRENT_USER\Software\WebKit /v gpu_process_canvas_rendering /t REG_DWORD /d 1 /f >+ >+ Enabling gpu_process_dom_rendering is still experimental. >+ > reg add HKEY_CURRENT_USER\Software\WebKit /v gpu_process_dom_rendering /t REG_DWORD /d 1 /f >+ >+ The following commands restore the non-GPU process mode. >+ > reg delete HKEY_CURRENT_USER\Software\WebKit /v gpu_process_canvas_rendering /f >+ > reg delete HKEY_CURRENT_USER\Software\WebKit /v gpu_process_webgl /f >+ > reg delete HKEY_CURRENT_USER\Software\WebKit /v gpu_process_dom_rendering /f >+ >+ * GPUProcess/GPUConnectionToWebProcess.cpp: >+ (WebKit::GPUConnectionToWebProcess::createWCLayerTreeHost): >+ (WebKit::GPUConnectionToWebProcess::releaseWCLayerTreeHost): >+ (WebKit::GPUConnectionToWebProcess::findRemoteGraphicsContextGL): >+ * GPUProcess/GPUConnectionToWebProcess.h: >+ * GPUProcess/GPUConnectionToWebProcess.messages.in: >+ * GPUProcess/GPUProcess.h: >+ (WebKit::GPUProcess::sharedSceneContext): >+ * GPUProcess/graphics/RemoteGraphicsContextGL.h: >+ (WebKit::RemoteGraphicsContextGL::platformLayer const): >+ * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp: >+ (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources): >+ * GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp: Added. >+ (WebKit::RemoteWCLayerTreeHost::create): >+ (WebKit::RemoteWCLayerTreeHost::RemoteWCLayerTreeHost): >+ (WebKit::RemoteWCLayerTreeHost::~RemoteWCLayerTreeHost): >+ (WebKit::RemoteWCLayerTreeHost::messageSenderConnection const): >+ (WebKit::RemoteWCLayerTreeHost::messageSenderDestinationID const): >+ (WebKit::RemoteWCLayerTreeHost::update): >+ * GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h: Added. >+ * GPUProcess/graphics/wc/RemoteWCLayerTreeHost.messages.in: Added. >+ * GPUProcess/graphics/wc/WCScene.cpp: Added. >+ (WebKit::WCScene::initialize): >+ (WebKit::WCScene::~WCScene): >+ (WebKit::WCScene::update): >+ * GPUProcess/graphics/wc/WCScene.h: Added. >+ * GPUProcess/graphics/wc/WCSceneContext.cpp: Added. >+ (WebKit::WCSceneContext::WCSceneContext): >+ (WebKit::WCSceneContext::makeContextCurrent): >+ (WebKit::WCSceneContext::createTextureMapper): >+ (WebKit::WCSceneContext::swapBuffers): >+ * GPUProcess/graphics/wc/WCSceneContext.h: Added. >+ * GPUProcess/graphics/wc/WCSharedSceneContextHolder.h: Added. >+ (WebKit::WCSharedSceneContextHolder::ensureHolderForWindow): >+ (WebKit::WCSharedSceneContextHolder::removeHolder): >+ * GPUProcess/win/GPUProcessMainWin.cpp: >+ (WebKit::GPUProcessMain): >+ * PlatformWin.cmake: >+ * Scripts/webkit/messages.py: >+ (types_that_cannot_be_forward_declared): >+ (conditions_for_header): >+ * Shared/DrawingAreaInfo.h: >+ * UIProcess/wc/DrawingAreaProxyWC.cpp: Added. >+ (WebKit::DrawingAreaProxyWC::DrawingAreaProxyWC): >+ (WebKit::DrawingAreaProxyWC::paint): >+ (WebKit::DrawingAreaProxyWC::sizeDidChange): >+ (WebKit::DrawingAreaProxyWC::update): >+ (WebKit::DrawingAreaProxyWC::enterAcceleratedCompositingMode): >+ (WebKit::DrawingAreaProxyWC::incorporateUpdate): >+ (WebKit::DrawingAreaProxyWC::discardBackingStore): >+ * UIProcess/wc/DrawingAreaProxyWC.h: Added. >+ * UIProcess/win/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::createDrawingAreaProxy): >+ * UIProcess/win/WebView.cpp: >+ (WebKit::WebView::paint): >+ * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: >+ (WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy): >+ * WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp: Added. >+ (WebKit::RemoteWCLayerTreeHostProxy::RemoteWCLayerTreeHostProxy): >+ (WebKit::RemoteWCLayerTreeHostProxy::~RemoteWCLayerTreeHostProxy): >+ (WebKit::RemoteWCLayerTreeHostProxy::messageSenderConnection const): >+ (WebKit::RemoteWCLayerTreeHostProxy::ensureGPUProcessConnection): >+ (WebKit::RemoteWCLayerTreeHostProxy::disconnectGpuProcessIfNeeded): >+ (WebKit::RemoteWCLayerTreeHostProxy::gpuProcessConnectionDidClose): >+ (WebKit::RemoteWCLayerTreeHostProxy::messageSenderDestinationID const): >+ (WebKit::RemoteWCLayerTreeHostProxy::update): >+ (WebKit::RemoteWCLayerTreeHostProxy::didUpdate): >+ * WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.h: Added. >+ (WebKit::RemoteWCLayerTreeHostProxy::wcLayerTreeHostIdentifier const): >+ * WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.messages.in: Added. >+ * WebProcess/GPU/graphics/wc/WCLayerTreeHostIdentifier.h: Added. >+ * WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h: Added. >+ (WebKit::WCPlatformLayerGCGL::WCPlatformLayerGCGL): >+ (WebKit::WCPlatformLayerGCGL::graphicsContextGLIdentifier): >+ * WebProcess/WebPage/DrawingArea.cpp: >+ (WebKit::DrawingArea::create): >+ (WebKit::DrawingArea::supportsGPUProcessRendering): >+ * WebProcess/WebPage/DrawingArea.h: >+ (WebKit::DrawingArea::updateGeometry): >+ * WebProcess/WebPage/DrawingArea.messages.in: >+ * WebProcess/WebPage/wc/DrawingAreaWC.cpp: Added. >+ (WebKit::DrawingAreaWC::DrawingAreaWC): >+ (WebKit::DrawingAreaWC::~DrawingAreaWC): >+ (WebKit::DrawingAreaWC::graphicsLayerFactory): >+ (WebKit::DrawingAreaWC::updateRootLayers): >+ (WebKit::DrawingAreaWC::setRootCompositingLayer): >+ (WebKit::DrawingAreaWC::attachViewOverlayGraphicsLayer): >+ (WebKit::DrawingAreaWC::setLayerTreeStateIsFrozen): >+ (WebKit::DrawingAreaWC::updateGeometry): >+ (WebKit::DrawingAreaWC::setNeedsDisplay): >+ (WebKit::DrawingAreaWC::setNeedsDisplayInRect): >+ (WebKit::DrawingAreaWC::scroll): >+ (WebKit::DrawingAreaWC::triggerRenderingUpdate): >+ (WebKit::flushLayerImageBuffers): >+ (WebKit::DrawingAreaWC::isCompositingMode): >+ (WebKit::DrawingAreaWC::updateRendering): >+ (WebKit::DrawingAreaWC::sendUpdateAC): >+ (WebKit::shouldPaintBoundsRect): >+ (WebKit::DrawingAreaWC::sendUpdateNonAC): >+ (WebKit::DrawingAreaWC::graphicsLayerAdded): >+ (WebKit::DrawingAreaWC::graphicsLayerRemoved): >+ (WebKit::DrawingAreaWC::commitLayerUpateInfo): >+ (WebKit::DrawingAreaWC::createImageBuffer): >+ (WebKit::DrawingAreaWC::didUpdate): >+ (WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): >+ (WebKit::DrawingAreaWC::RootLayerClient::paintContents): >+ (WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): >+ * WebProcess/WebPage/wc/DrawingAreaWC.h: Added. >+ * WebProcess/WebPage/wc/GraphicsLayerWC.cpp: Added. >+ (WebKit::GraphicsLayerWC::GraphicsLayerWC): >+ (WebKit::GraphicsLayerWC::~GraphicsLayerWC): >+ (WebKit::GraphicsLayerWC::generateLayerID): >+ (WebKit::GraphicsLayerWC::primaryLayerID const): >+ (WebKit::GraphicsLayerWC::setNeedsDisplay): >+ (WebKit::GraphicsLayerWC::setNeedsDisplayInRect): >+ (WebKit::GraphicsLayerWC::setContentsNeedsDisplay): >+ (WebKit::GraphicsLayerWC::setChildren): >+ (WebKit::GraphicsLayerWC::addChild): >+ (WebKit::GraphicsLayerWC::addChildAtIndex): >+ (WebKit::GraphicsLayerWC::addChildBelow): >+ (WebKit::GraphicsLayerWC::addChildAbove): >+ (WebKit::GraphicsLayerWC::replaceChild): >+ (WebKit::GraphicsLayerWC::removeFromParent): >+ (WebKit::GraphicsLayerWC::setMaskLayer): >+ (WebKit::GraphicsLayerWC::setReplicatedLayer): >+ (WebKit::GraphicsLayerWC::setReplicatedByLayer): >+ (WebKit::GraphicsLayerWC::setPosition): >+ (WebKit::GraphicsLayerWC::setAnchorPoint): >+ (WebKit::GraphicsLayerWC::setSize): >+ (WebKit::GraphicsLayerWC::setBoundsOrigin): >+ (WebKit::GraphicsLayerWC::setTransform): >+ (WebKit::GraphicsLayerWC::setChildrenTransform): >+ (WebKit::GraphicsLayerWC::setPreserves3D): >+ (WebKit::GraphicsLayerWC::setMasksToBounds): >+ (WebKit::GraphicsLayerWC::setOpacity): >+ (WebKit::GraphicsLayerWC::setContentsRect): >+ (WebKit::GraphicsLayerWC::setContentsClippingRect): >+ (WebKit::GraphicsLayerWC::setDrawsContent): >+ (WebKit::GraphicsLayerWC::setContentsVisible): >+ (WebKit::GraphicsLayerWC::setBackfaceVisibility): >+ (WebKit::GraphicsLayerWC::setContentsToSolidColor): >+ (WebKit::GraphicsLayerWC::setContentsToPlatformLayer): >+ (WebKit::GraphicsLayerWC::usesContentsLayer const): >+ (WebKit::GraphicsLayerWC::setShowDebugBorder): >+ (WebKit::GraphicsLayerWC::setDebugBorder): >+ (WebKit::GraphicsLayerWC::setShowRepaintCounter): >+ (WebKit::filtersCanBeComposited): >+ (WebKit::GraphicsLayerWC::setFilters): >+ (WebKit::GraphicsLayerWC::setBackdropFilters): >+ (WebKit::GraphicsLayerWC::setBackdropFiltersRect): >+ (WebKit::GraphicsLayerWC::noteLayerPropertyChanged): >+ (WebKit::GraphicsLayerWC::flushCompositingState): >+ (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly): >+ * WebProcess/WebPage/wc/GraphicsLayerWC.h: Added. >+ * WebProcess/WebPage/wc/WCBackingStore.h: Added. >+ (WebKit::WCBackingStore::WCBackingStore): >+ (WebKit::WCBackingStore::imageBuffer): >+ (WebKit::WCBackingStore::setImageBuffer): >+ (WebKit::WCBackingStore::bitmap const): >+ (WebKit::WCBackingStore::encode const): >+ (WebKit::WCBackingStore::decode): >+ * WebProcess/WebPage/wc/WCLayerFactory.cpp: Added. >+ (WebKit::WCLayerFactory::WCLayerFactory): >+ (WebKit::WCLayerFactory::createGraphicsLayer): >+ * WebProcess/WebPage/wc/WCLayerFactory.h: Added. >+ * WebProcess/WebPage/wc/WCUpateInfo.h: Added. >+ (WebKit::WCLayerUpateInfo::encode const): >+ (WebKit::WCLayerUpateInfo::decode): >+ (WebKit::WCUpateInfo::encode const): >+ (WebKit::WCUpateInfo::decode): >+ > 2021-10-26 Alex Christensen <achristensen@webkit.org> > > Remove properties set by NSURLProtocol on NSURLRequest before serializing >diff --git a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp >index 870e37e05e05..72833d72ea26 100644 >--- a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp >+++ b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp >@@ -143,6 +143,10 @@ > #include <WebCore/SecurityOrigin.h> > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+#include "RemoteWCLayerTreeHost.h" >+#endif >+ > namespace WebKit { > using namespace WebCore; > >@@ -336,6 +340,28 @@ void GPUConnectionToWebProcess::configureLoggingChannel(const String& channelNam > #endif > } > >+#if USE(GRAPHICS_LAYER_WC) >+void GPUConnectionToWebProcess::createWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow) >+{ >+ auto addResult = m_remoteWCLayerTreeHostMap.add(identifier, RemoteWCLayerTreeHost::create(*this, WTFMove(identifier), nativeWindow)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+} >+ >+void GPUConnectionToWebProcess::releaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier) >+{ >+ m_remoteWCLayerTreeHostMap.remove(identifier); >+} >+ >+RefPtr<RemoteGraphicsContextGL> GPUConnectionToWebProcess::findRemoteGraphicsContextGL(GraphicsContextGLIdentifier identifier) >+{ >+ ASSERT(RunLoop::isMain()); >+ auto iter = m_remoteGraphicsContextGLMap.find(identifier); >+ if (iter == m_remoteGraphicsContextGLMap.end()) >+ return nullptr; >+ return iter->value.get(); >+} >+#endif >+ > bool GPUConnectionToWebProcess::allowsExitUnderMemoryPressure() const > { > for (auto& remoteRenderingBackend : m_remoteRenderingBackendMap.values()) { >diff --git a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h >index 21aab5cc82c6..ac2b1ced82e4 100644 >--- a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h >+++ b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h >@@ -57,6 +57,10 @@ > #include <pal/spi/cocoa/TCCSPI.h> > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+#include "WCLayerTreeHostIdentifier.h" >+#endif >+ > namespace WebCore { > class SecurityOrigin; > struct SecurityOriginData; >@@ -91,6 +95,10 @@ struct MediaOverridesForTesting; > struct RemoteAudioSessionConfiguration; > struct RemoteRenderingBackendCreationParameters; > >+#if USE(GRAPHICS_LAYER_WC) >+class RemoteWCLayerTreeHost; >+#endif >+ > class GPUConnectionToWebProcess > : public ThreadSafeRefCounted<GPUConnectionToWebProcess, WTF::DestructionThread::Main> > , public WebCore::NowPlayingManager::Client >@@ -161,6 +169,10 @@ public: > RemoteImageDecoderAVFProxy& imageDecoderAVFProxy(); > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ RefPtr<RemoteGraphicsContextGL> findRemoteGraphicsContextGL(GraphicsContextGLIdentifier); >+#endif >+ > void updateSupportedRemoteCommands(); > > bool allowsExitUnderMemoryPressure() const; >@@ -228,6 +240,11 @@ private: > void setUserPreferredLanguages(const Vector<String>&); > void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel); > >+#if USE(GRAPHICS_LAYER_WC) >+ void createWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow); >+ void releaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier); >+#endif >+ > // IPC::Connection::Client > void didClose(IPC::Connection&) final; > void didReceiveInvalidMessage(IPC::Connection&, IPC::MessageName) final; >@@ -309,6 +326,11 @@ private: > using RemoteAudioHardwareListenerMap = HashMap<RemoteAudioHardwareListenerIdentifier, std::unique_ptr<RemoteAudioHardwareListenerProxy>>; > RemoteAudioHardwareListenerMap m_remoteAudioHardwareListenerMap; > >+#if USE(GRAPHICS_LAYER_WC) >+ using RemoteWCLayerTreeHostMap = HashMap<WCLayerTreeHostIdentifier, std::unique_ptr<RemoteWCLayerTreeHost>>; >+ RemoteWCLayerTreeHostMap m_remoteWCLayerTreeHostMap; >+#endif >+ > RefPtr<RemoteRemoteCommandListenerProxy> m_remoteRemoteCommandListener; > bool m_isActiveNowPlayingProcess { false }; > >diff --git a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in >index c1bf8019ceab..391c19fe9d85 100644 >--- a/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in >+++ b/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in >@@ -51,6 +51,10 @@ messages -> GPUConnectionToWebProcess WantsDispatchMessage { > ReleaseRemoteCommandListener(WebKit::RemoteRemoteCommandListenerIdentifier identifier) > SetUserPreferredLanguages(Vector<String> languages) > ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level) >+#if USE(GRAPHICS_LAYER_WC) >+ CreateWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow) >+ ReleaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier) >+#endif > } > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/GPUProcess/GPUProcess.h b/Source/WebKit/GPUProcess/GPUProcess.h >index 0af4982784a8..1a39a8da1f88 100644 >--- a/Source/WebKit/GPUProcess/GPUProcess.h >+++ b/Source/WebKit/GPUProcess/GPUProcess.h >@@ -42,6 +42,10 @@ > #include <CoreGraphics/CGDisplayConfiguration.h> > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+#include "WCSharedSceneContextHolder.h" >+#endif >+ > namespace WebCore { > class NowPlayingManager; > struct MockMediaDevice; >@@ -92,6 +96,10 @@ public: > WorkQueue& libWebRTCCodecsQueue(); > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ WCSharedSceneContextHolder& sharedSceneContext() { return m_sharedSceneContext; } >+#endif >+ > #if ENABLE(VP9) > void enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder); > #endif >@@ -186,6 +194,10 @@ private: > RefPtr<WorkQueue> m_libWebRTCCodecsQueue; > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ WCSharedSceneContextHolder m_sharedSceneContext; >+#endif >+ > struct GPUSession { > String mediaCacheDirectory; > #if ENABLE(LEGACY_ENCRYPTED_MEDIA) >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h >index ef41ea6082ba..a0729765cb5d 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h >@@ -67,6 +67,10 @@ public: > void displayWasReconfigured(); > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ PlatformLayer* platformLayer() const { return m_context->platformLayer(); } >+#endif >+ > protected: > RemoteGraphicsContextGL(GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&); > void initialize(WebCore::GraphicsContextGLAttributes&&); >diff --git a/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp b/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp >index 326b07f2ebde..5a6ce65e7447 100644 >--- a/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp >+++ b/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp >@@ -42,10 +42,12 @@ static bool didScheduleFreeWebGLRenderingResources; > > void ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources() > { >+#if !USE(GRAPHICS_LAYER_WC) > if (didScheduleFreeWebGLRenderingResources) > return; > RunLoop::main().dispatchAfter(freeWebGLRenderingResourcesTimeout, freeWebGLRenderingResources); > didScheduleFreeWebGLRenderingResources = true; >+#endif > } > > void ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources() >diff --git a/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp >new file mode 100644 >index 000000000000..fd3d29fc4e00 >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp >@@ -0,0 +1,106 @@ >+/* >+ * 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 "RemoteWCLayerTreeHost.h" >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+#include "GPUConnectionToWebProcess.h" >+#include "GPUProcess.h" >+#include "RemoteGraphicsContextGL.h" >+#include "RemoteWCLayerTreeHostMessages.h" >+#include "RemoteWCLayerTreeHostProxyMessages.h" >+#include "StreamConnectionWorkQueue.h" >+#include "WCScene.h" >+#include "WCUpateInfo.h" >+ >+namespace WebKit { >+ >+std::unique_ptr<RemoteWCLayerTreeHost> RemoteWCLayerTreeHost::create(GPUConnectionToWebProcess& connectionToWebProcess, WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow) >+{ >+ return makeUnique<RemoteWCLayerTreeHost>(connectionToWebProcess, identifier, nativeWindow); >+} >+ >+RemoteWCLayerTreeHost::RemoteWCLayerTreeHost(GPUConnectionToWebProcess& connectionToWebProcess, WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow) >+ : m_connectionToWebProcess(connectionToWebProcess) >+ , 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>(); >+ remoteGraphicsContextGLStreamWorkQueue().dispatch([scene = m_scene.get(), sceneContextHolder = m_sharedSceneContextHolder.get(), nativeWindow] { >+ if (!sceneContextHolder->context) >+ sceneContextHolder->context.emplace(nativeWindow); >+ scene->initialize(*sceneContextHolder->context); >+ }); >+} >+ >+RemoteWCLayerTreeHost::~RemoteWCLayerTreeHost() >+{ >+ ASSERT(m_connectionToWebProcess); >+ m_connectionToWebProcess->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHost::messageReceiverName(), m_identifier.toUInt64()); >+ auto sceneContextHolder = m_connectionToWebProcess->gpuProcess().sharedSceneContext().removeHolder(m_sharedSceneContextHolder.releaseNonNull()); >+ remoteGraphicsContextGLStreamWorkQueue().dispatch([sceneContextHolder = WTFMove(sceneContextHolder), scene = WTFMove(m_scene)]() mutable { >+ // Destroy scene on the StreamWorkQueue thread. >+ scene = nullptr; >+ // sceneContextHolder can be destroyed on the StreamWorkQueue thread because it hasOneRef. >+ }); >+} >+ >+IPC::Connection* RemoteWCLayerTreeHost::messageSenderConnection() const >+{ >+ return &m_connectionToWebProcess->connection(); >+} >+ >+uint64_t RemoteWCLayerTreeHost::messageSenderDestinationID() const >+{ >+ return m_identifier.toUInt64(); >+} >+ >+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)); >+ RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis)] { >+ if (!weakThis) >+ return; >+ send(Messages::RemoteWCLayerTreeHostProxy::DidUpdate()); >+ }); >+ }); >+} >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h >new file mode 100644 >index 000000000000..edc4fbb410a6 >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h >@@ -0,0 +1,65 @@ >+/* >+ * 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 "Connection.h" >+#include "MessageReceiver.h" >+#include "MessageSender.h" >+#include "WCLayerTreeHostIdentifier.h" >+#include "WCSharedSceneContextHolder.h" >+ >+namespace WebKit { >+class GPUConnectionToWebProcess; >+class WCScene; >+struct WCUpateInfo; >+ >+class RemoteWCLayerTreeHost : public IPC::MessageReceiver, private IPC::MessageSender { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ static std::unique_ptr<RemoteWCLayerTreeHost> create(GPUConnectionToWebProcess&, WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow); >+ RemoteWCLayerTreeHost(GPUConnectionToWebProcess&, WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow); >+ ~RemoteWCLayerTreeHost(); >+ // message handlers >+ void update(WCUpateInfo&&); >+ >+private: >+ // IPC::MessageReceiver >+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; >+ // IPC::MessageSender >+ IPC::Connection* messageSenderConnection() const override; >+ uint64_t messageSenderDestinationID() const override; >+ >+ WeakPtr<GPUConnectionToWebProcess> m_connectionToWebProcess; >+ WCLayerTreeHostIdentifier m_identifier; >+ RefPtr<WCSharedSceneContextHolder::Holder> m_sharedSceneContextHolder; >+ std::unique_ptr<WCScene> m_scene; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.messages.in b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.messages.in >new file mode 100644 >index 000000000000..2516fda4191d >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.messages.in >@@ -0,0 +1,29 @@ >+# 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. >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+messages -> RemoteWCLayerTreeHost NotRefCounted { >+ Update(struct WebKit::WCUpateInfo updateInfo) >+} >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp b/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp >new file mode 100644 >index 000000000000..804e90bf1c63 >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp >@@ -0,0 +1,196 @@ >+/* >+ * 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 "WCScene.h" >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+#include "RemoteGraphicsContextGL.h" >+#include "WCSceneContext.h" >+#include "WCUpateInfo.h" >+#include <WebCore/GraphicsContextGLOpenGL.h> >+#include <WebCore/TextureMapperLayer.h> >+#include <WebCore/TextureMapperTiledBackingStore.h> >+ >+namespace WebKit { >+ >+struct WCScene::Layer : public WebCore::TextureMapperPlatformLayer::Client { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ Layer() = default; >+ >+ // TextureMapperPlatformLayer::Client >+ void platformLayerWillBeDestroyed() override >+ { >+ texmapLayer.setContentsLayer(nullptr); >+ } >+ void setPlatformLayerNeedsDisplay() override { } >+ >+ WebCore::TextureMapperLayer texmapLayer; >+ RefPtr<WebCore::TextureMapperTiledBackingStore> backingStore; >+ std::unique_ptr<WebCore::TextureMapperLayer> backdropLayer; >+}; >+ >+void WCScene::initialize(WCSceneContext& context) >+{ >+ // The creation of the TextureMapper needs an active OpenGL context. >+ m_context = &context; >+ m_context->makeContextCurrent(); >+ m_textureMapper = m_context->createTextureMapper(); >+} >+ >+WCScene::WCScene() = default; >+ >+WCScene::~WCScene() >+{ >+ m_context->makeContextCurrent(); >+ m_textureMapper = nullptr; >+} >+ >+void WCScene::update(WCUpateInfo&& update, Vector<RefPtr<RemoteGraphicsContextGL>>&& remoteGCGL) >+{ >+ if (!m_context->makeContextCurrent()) >+ return; >+ >+ for (auto id : update.addedLayers) { >+ auto layer = makeUnique<Layer>(); >+ 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) { >+ layer->texmapLayer.setChildren(WTF::map(layerUpdate.children, [&](auto id) { >+ return &m_layers.get(id)->texmapLayer; >+ })); >+ } >+ if (layerUpdate.changes & WCLayerChange::MaskLayer) { >+ WebCore::TextureMapperLayer* maskLayer = nullptr; >+ if (layerUpdate.maskLayer) >+ maskLayer = &m_layers.get(*layerUpdate.maskLayer)->texmapLayer; >+ layer->texmapLayer.setMaskLayer(maskLayer); >+ } >+ if (layerUpdate.changes & WCLayerChange::ReplicaLayer) { >+ WebCore::TextureMapperLayer* replicaLayer = nullptr; >+ if (layerUpdate.replicaLayer) >+ replicaLayer = &m_layers.get(*layerUpdate.replicaLayer)->texmapLayer; >+ layer->texmapLayer.setReplicaLayer(replicaLayer); >+ } >+ if (layerUpdate.changes & WCLayerChange::Geometry) { >+ layer->texmapLayer.setPosition(layerUpdate.position); >+ layer->texmapLayer.setAnchorPoint(layerUpdate.anchorPoint); >+ layer->texmapLayer.setSize(layerUpdate.size); >+ layer->texmapLayer.setBoundsOrigin(layerUpdate.boundsOrigin); >+ } >+ if (layerUpdate.changes & WCLayerChange::Preserves3D) >+ layer->texmapLayer.setPreserves3D(layerUpdate.preserves3D); >+ if (layerUpdate.changes & WCLayerChange::ContentsRect) >+ layer->texmapLayer.setContentsRect(layerUpdate.contentsRect); >+ if (layerUpdate.changes & WCLayerChange::ContentsClippingRect) >+ layer->texmapLayer.setContentsClippingRect(layerUpdate.contentsClippingRect); >+ if (layerUpdate.changes & WCLayerChange::ContentsVisible) >+ layer->texmapLayer.setContentsVisible(layerUpdate.contentsVisible); >+ if (layerUpdate.changes & WCLayerChange::BackfaceVisibility) >+ layer->texmapLayer.setBackfaceVisibility(layerUpdate.backfaceVisibility); >+ if (layerUpdate.changes & WCLayerChange::MasksToBounds) >+ layer->texmapLayer.setMasksToBounds(layerUpdate.masksToBounds); >+ if (layerUpdate.changes & WCLayerChange::BackingStore) { >+ auto bitmap = layerUpdate.backingStore.bitmap(); >+ if (bitmap) { >+ layer->backingStore = WebCore::TextureMapperTiledBackingStore::create(); >+ auto image = bitmap->createImage(); >+ layer->backingStore->updateContents(*m_textureMapper, image.get(), bitmap->size(), { { }, bitmap->size() }); >+ layer->texmapLayer.setBackingStore(layer->backingStore.get()); >+ } else { >+ layer->texmapLayer.setBackingStore(nullptr); >+ layer->backingStore = nullptr; >+ } >+ } >+ if (layerUpdate.changes & WCLayerChange::SolidColor) >+ layer->texmapLayer.setSolidColor(layerUpdate.solidColor); >+ if (layerUpdate.changes & WCLayerChange::DebugVisuals) >+ layer->texmapLayer.setDebugVisuals(layerUpdate.showDebugBorder, layerUpdate.debugBorderColor, layerUpdate.debugBorderWidth); >+ if (layerUpdate.changes & WCLayerChange::RepaintCount) >+ layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount); >+ if (layerUpdate.changes & WCLayerChange::Opacity) >+ layer->texmapLayer.setOpacity(layerUpdate.opacity); >+ if (layerUpdate.changes & WCLayerChange::Transform) >+ layer->texmapLayer.setTransform(layerUpdate.transform); >+ if (layerUpdate.changes & WCLayerChange::ChildrenTransform) >+ layer->texmapLayer.setChildrenTransform(layerUpdate.childrenTransform); >+ if (layerUpdate.changes & WCLayerChange::Filters) >+ layer->texmapLayer.setFilters(layerUpdate.filters); >+ if (layerUpdate.changes & WCLayerChange::BackdropFilters) { >+ if (layerUpdate.backdropFilters.isEmpty()) >+ layer->backdropLayer.reset(); >+ else { >+ if (!layer->backdropLayer) { >+ layer->backdropLayer = makeUnique<WebCore::TextureMapperLayer>(); >+ layer->backdropLayer->setAnchorPoint({ }); >+ layer->backdropLayer->setContentsVisible(true); >+ layer->backdropLayer->setMasksToBounds(true); >+ } >+ layer->backdropLayer->setFilters(layerUpdate.backdropFilters); >+ layer->backdropLayer->setSize(layerUpdate.backdropFiltersRect.rect().size()); >+ layer->backdropLayer->setPosition(layerUpdate.backdropFiltersRect.rect().location()); >+ } >+ layer->texmapLayer.setBackdropLayer(layer->backdropLayer.get()); >+ layer->texmapLayer.setBackdropFiltersRect(layerUpdate.backdropFiltersRect); >+ } >+ if (layerUpdate.changes & WCLayerChange::PlatformLayer) { >+ if (*remoteGCGLIterator) { >+ auto platformLayer = (*remoteGCGLIterator)->platformLayer(); >+ platformLayer->setClient(layer); >+ layer->texmapLayer.setContentsLayer(platformLayer); >+ } else >+ layer->texmapLayer.setContentsLayer(nullptr); >+ } >+ remoteGCGLIterator++; >+ } >+ ASSERT(remoteGCGLIterator == remoteGCGL.end()); >+ >+ for (auto id : update.removedLayers) >+ m_layers.remove(id); >+ >+ auto rootLayer = &m_layers.get(update.rootLayer)->texmapLayer; >+ rootLayer->applyAnimationsRecursively(MonotonicTime::now()); >+ >+ WebCore::IntSize windowSize = expandedIntSize(rootLayer->size()); >+ glViewport(0, 0, windowSize.width(), windowSize.height()); >+ >+ m_textureMapper->beginPainting(); >+ rootLayer->paint(*m_textureMapper); >+ m_fpsCounter.updateFPSAndDisplay(*m_textureMapper); >+ m_textureMapper->endPainting(); >+ >+ m_context->swapBuffers(); >+} >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/WCScene.h b/Source/WebKit/GPUProcess/graphics/wc/WCScene.h >new file mode 100644 >index 000000000000..63ed03f3ee86 >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/WCScene.h >@@ -0,0 +1,66 @@ >+/* >+ * 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 <WebCore/TextureMapperFPSCounter.h> >+#include <wtf/Forward.h> >+#include <wtf/HashMap.h> >+ >+namespace WebCore { >+class TextureMapper; >+class TextureMapperLayer; >+class TextureMapperTiledBackingStore; >+} >+ >+namespace WebKit { >+ >+class RemoteGraphicsContextGL; >+class WCSceneContext; >+struct WCUpateInfo; >+ >+class WCScene { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ WCScene(); >+ ~WCScene(); >+ void initialize(WCSceneContext&); >+ void update(WCUpateInfo&&, Vector<RefPtr<RemoteGraphicsContextGL>>&&); >+ >+private: >+ struct Layer; >+ using LayerMap = HashMap<uint64_t, std::unique_ptr<Layer>>; >+ >+ WCSceneContext* m_context { nullptr }; >+ std::unique_ptr<WebCore::TextureMapper> m_textureMapper; >+ WebCore::TextureMapperFPSCounter m_fpsCounter; >+ LayerMap m_layers; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.cpp b/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.cpp >new file mode 100644 >index 000000000000..df78456c6c3b >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.cpp >@@ -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. >+ */ >+ >+#include "config.h" >+#include "WCSceneContext.h" >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+#include <WebCore/GLContext.h> >+#include <WebCore/TextureMapperGL.h> >+ >+namespace WebKit { >+ >+WCSceneContext::WCSceneContext(uint64_t nativeWindow) >+{ >+ m_glContext = WebCore::GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(nativeWindow)); >+} >+ >+WCSceneContext::~WCSceneContext() = default; >+ >+bool WCSceneContext::makeContextCurrent() >+{ >+ return m_glContext->makeContextCurrent(); >+} >+ >+std::unique_ptr<WebCore::TextureMapper> WCSceneContext::createTextureMapper() >+{ >+ return WebCore::TextureMapperGL::create(); >+} >+ >+void WCSceneContext::swapBuffers() >+{ >+ m_glContext->swapBuffers(); >+} >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.h b/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.h >new file mode 100644 >index 000000000000..5d62bfff787e >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/WCSceneContext.h >@@ -0,0 +1,55 @@ >+/* >+ * 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/FastMalloc.h> >+ >+namespace WebCore { >+class GLContext; >+class TextureMapper; >+} >+ >+namespace WebKit { >+ >+class WCSceneContext { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit WCSceneContext(uint64_t nativeWindow); >+ ~WCSceneContext(); >+ >+ bool makeContextCurrent(); >+ std::unique_ptr<WebCore::TextureMapper> createTextureMapper(); >+ void swapBuffers(); >+ >+private: >+ std::unique_ptr<WebCore::GLContext> m_glContext; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/graphics/wc/WCSharedSceneContextHolder.h b/Source/WebKit/GPUProcess/graphics/wc/WCSharedSceneContextHolder.h >new file mode 100644 >index 000000000000..9b17ffc3ca41 >--- /dev/null >+++ b/Source/WebKit/GPUProcess/graphics/wc/WCSharedSceneContextHolder.h >@@ -0,0 +1,80 @@ >+/* >+ * 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 "WCSceneContext.h" >+#include <wtf/HashMap.h> >+#include <wtf/RefPtr.h> >+ >+namespace WebKit { >+ >+// Creating a WCSceneContext for a window fails if the window already >+// has one. While navigating to a new page with a new WebProcess, the >+// provisional WebKit::WebPage in the new WebProcess has the same >+// window handle. WCSceneContext should be shared among all >+// RemoteWCLayerTreeHosts that render to the same native window. >+class WCSharedSceneContextHolder { >+ WTF_MAKE_NONCOPYABLE(WCSharedSceneContextHolder); >+public: >+ WCSharedSceneContextHolder() = default; >+ >+ struct Holder : RefCounted<Holder> { >+ WTF_MAKE_STRUCT_FAST_ALLOCATED; >+ int64_t nativeWindow; >+ // The following member is accessed in the OpenGL thread >+ std::optional<WCSceneContext> context; >+ }; >+ >+ Ref<Holder> ensureHolderForWindow(int64_t nativeWindow) >+ { >+ ASSERT(RunLoop::isMain()); >+ auto result = m_hash.add(nativeWindow, nullptr); >+ if (!result.isNewEntry) >+ return *result.iterator->value; >+ auto holder = adoptRef(*new Holder); >+ holder->nativeWindow = nativeWindow; >+ result.iterator->value = holder.ptr(); >+ return holder; >+ } >+ >+ RefPtr<Holder> removeHolder(Ref<Holder>&& holder) >+ { >+ ASSERT(RunLoop::isMain()); >+ if (!holder->hasOneRef()) >+ return nullptr; >+ m_hash.remove(holder->nativeWindow); >+ return holder; >+ } >+ >+private: >+ HashMap<int64_t, Holder*> m_hash; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/GPUProcess/win/GPUProcessMainWin.cpp b/Source/WebKit/GPUProcess/win/GPUProcessMainWin.cpp >index f01e639d9d78..27234cbfb5d6 100644 >--- a/Source/WebKit/GPUProcess/win/GPUProcessMainWin.cpp >+++ b/Source/WebKit/GPUProcess/win/GPUProcessMainWin.cpp >@@ -30,14 +30,31 @@ > > #include "AuxiliaryProcessMain.h" > #include "GPUProcess.h" >+#include <Objbase.h> >+#include <wtf/win/SoftLinking.h> >+ >+SOFT_LINK_LIBRARY(user32); >+SOFT_LINK_OPTIONAL(user32, SetProcessDpiAwarenessContext, BOOL, STDAPICALLTYPE, (DPI_AWARENESS_CONTEXT)); > > namespace WebKit { > > class GPUProcessMainWin final: public AuxiliaryProcessMainBaseNoSingleton<GPUProcess> { >+public: >+ bool platformInitialize() override >+ { >+ if (SetProcessDpiAwarenessContextPtr()) >+ SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); >+ else >+ SetProcessDPIAware(); >+ return true; >+ } > }; > > int GPUProcessMain(int argc, char** argv) > { >+ // for DirectX >+ HRESULT hr = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED); >+ RELEASE_ASSERT(SUCCEEDED(hr)); > return AuxiliaryProcessMain<GPUProcessMainWin>(argc, argv); > } > >diff --git a/Source/WebKit/PlatformWin.cmake b/Source/WebKit/PlatformWin.cmake >index 01565d550697..ab5a2df08ea4 100644 >--- a/Source/WebKit/PlatformWin.cmake >+++ b/Source/WebKit/PlatformWin.cmake >@@ -11,6 +11,10 @@ add_definitions(-DBUILDING_WEBKIT) > list(APPEND WebKit_SOURCES > GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp > >+ GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp >+ GPUProcess/graphics/wc/WCScene.cpp >+ GPUProcess/graphics/wc/WCSceneContext.cpp >+ > GPUProcess/media/win/RemoteMediaPlayerProxyWin.cpp > > GPUProcess/win/GPUProcessMainWin.cpp >@@ -69,6 +73,8 @@ list(APPEND WebKit_SOURCES > > UIProcess/WebsiteData/win/WebsiteDataStoreWin.cpp > >+ UIProcess/wc/DrawingAreaProxyWC.cpp >+ > UIProcess/win/PageClientImpl.cpp > UIProcess/win/WebContextMenuProxyWin.cpp > UIProcess/win/WebPageProxyWin.cpp >@@ -76,6 +82,8 @@ list(APPEND WebKit_SOURCES > UIProcess/win/WebProcessPoolWin.cpp > UIProcess/win/WebView.cpp > >+ WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp >+ > WebProcess/GPU/media/win/VideoLayerRemoteWin.cpp > > WebProcess/InjectedBundle/win/InjectedBundleWin.cpp >@@ -95,6 +103,10 @@ list(APPEND WebKit_SOURCES > WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp > WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp > >+ WebProcess/WebPage/wc/DrawingAreaWC.cpp >+ WebProcess/WebPage/wc/GraphicsLayerWC.cpp >+ WebProcess/WebPage/wc/WCLayerFactory.cpp >+ > WebProcess/WebPage/win/WebPageWin.cpp > > WebProcess/win/WebProcessMainWin.cpp >@@ -102,6 +114,7 @@ list(APPEND WebKit_SOURCES > ) > > list(APPEND WebKit_INCLUDE_DIRECTORIES >+ "${WEBKIT_DIR}/GPUProcess/graphics/wc" > "${WEBKIT_DIR}/Platform/classifier" > "${WEBKIT_DIR}/Platform/generic" > "${WEBKIT_DIR}/PluginProcess/win" >@@ -119,16 +132,25 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES > "${WEBKIT_DIR}/UIProcess/Inspector/socket" > "${WEBKIT_DIR}/UIProcess/Inspector/win" > "${WEBKIT_DIR}/UIProcess/Plugins/win" >+ "${WEBKIT_DIR}/UIProcess/wc" > "${WEBKIT_DIR}/UIProcess/win" >+ "${WEBKIT_DIR}/WebProcess/GPU/graphics/wc" > "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/win" > "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/win/DOM" > "${WEBKIT_DIR}/WebProcess/Inspector/win" > "${WEBKIT_DIR}/WebProcess/WebCoreSupport/win" > "${WEBKIT_DIR}/WebProcess/WebPage/CoordinatedGraphics" >+ "${WEBKIT_DIR}/WebProcess/WebPage/wc" > "${WEBKIT_DIR}/WebProcess/WebPage/win" > "${WEBKIT_DIR}/win" > ) > >+list(APPEND WebKit_MESSAGES_IN_FILES >+ GPUProcess/graphics/wc/RemoteWCLayerTreeHost >+ >+ WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy >+) >+ > set(WebKitCommonIncludeDirectories ${WebKit_INCLUDE_DIRECTORIES}) > set(WebKitCommonSystemIncludeDirectories ${WebKit_SYSTEM_INCLUDE_DIRECTORIES}) > >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index 6584d1ad7e15..3754ae44745f 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -357,6 +357,7 @@ def types_that_cannot_be_forward_declared(): > 'WebKit::TrackPrivateRemoteIdentifier', > 'WebKit::TransactionID', > 'WebKit::UserContentControllerIdentifier', >+ 'WebKit::WCLayerTreeHostIdentifier', > 'WebKit::WebPageProxyIdentifier', > 'WebKit::WebURLSchemeHandlerIdentifier', > 'WebKit::XRDeviceIdentifier', >@@ -368,6 +369,7 @@ def conditions_for_header(header): > '"InputMethodState.h"': ["PLATFORM(GTK)", "PLATFORM(WPE)"], > '"LayerHostingContext.h"': ["PLATFORM(COCOA)", ], > '"GestureTypes.h"': ["PLATFORM(IOS_FAMILY)"], >+ '"WCLayerTreeHostIdentifier.h"': ["USE(GRAPHICS_LAYER_WC)"], > '<WebCore/MediaPlaybackTargetContext.h>': ["ENABLE(WIRELESS_PLAYBACK_TARGET)"], > '<WebCore/DataDetectorType.h>': ["ENABLE(DATA_DETECTION)"], > } >diff --git a/Source/WebKit/Shared/DrawingAreaInfo.h b/Source/WebKit/Shared/DrawingAreaInfo.h >index 79f53f53dcf9..722b5f34b00d 100644 >--- a/Source/WebKit/Shared/DrawingAreaInfo.h >+++ b/Source/WebKit/Shared/DrawingAreaInfo.h >@@ -37,7 +37,10 @@ enum class DrawingAreaType : uint8_t { > #endif > RemoteLayerTree, > #elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER) >- CoordinatedGraphics >+ CoordinatedGraphics, >+#endif >+#if USE(GRAPHICS_LAYER_WC) >+ WC, > #endif > }; > >@@ -63,6 +66,9 @@ template<> struct EnumTraits<WebKit::DrawingAreaType> { > , WebKit::DrawingAreaType::RemoteLayerTree > #elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER) > , WebKit::DrawingAreaType::CoordinatedGraphics >+#endif >+#if USE(GRAPHICS_LAYER_WC) >+ , WebKit::DrawingAreaType::WC > #endif > >; > }; >diff --git a/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.cpp b/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.cpp >new file mode 100644 >index 000000000000..f6397e89d7b2 >--- /dev/null >+++ b/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.cpp >@@ -0,0 +1,98 @@ >+/* >+ * Copyright (C) 2011 Apple Inc. All rights reserved. >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * Copyright (C) 2016-2019 Igalia S.L. >+ * 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 "DrawingAreaProxyWC.h" >+ >+#include "DrawingAreaMessages.h" >+#include "UpdateInfo.h" >+#include "WebCoreArgumentCoders.h" >+#include "WebPageProxy.h" >+#include <WebCore/Region.h> >+ >+namespace WebKit { >+ >+DrawingAreaProxyWC::DrawingAreaProxyWC(WebPageProxy& webPageProxy, WebProcessProxy& process) >+ : DrawingAreaProxy(DrawingAreaType::WC, webPageProxy, process) >+{ >+} >+ >+void DrawingAreaProxyWC::paint(BackingStore::PlatformGraphicsContext context, const WebCore::IntRect& rect, WebCore::Region& unpaintedRegion) >+{ >+ unpaintedRegion = rect; >+ >+ if (!m_backingStore) >+ return; >+ m_backingStore->paint(context, rect); >+ unpaintedRegion.subtract(WebCore::IntRect({ }, m_backingStore->size())); >+} >+ >+void DrawingAreaProxyWC::sizeDidChange() >+{ >+ discardBackingStore(); >+ m_currentBackingStoreStateID++; >+ send(Messages::DrawingArea::UpdateGeometry(m_currentBackingStoreStateID, m_size)); >+} >+ >+void DrawingAreaProxyWC::update(uint64_t backingStoreStateID, const UpdateInfo& updateInfo) >+{ >+ if (backingStoreStateID == m_currentBackingStoreStateID) >+ incorporateUpdate(updateInfo); >+ send(Messages::DrawingArea::DidUpdate()); >+} >+ >+void DrawingAreaProxyWC::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) >+{ >+ discardBackingStore(); >+} >+ >+void DrawingAreaProxyWC::incorporateUpdate(const UpdateInfo& updateInfo) >+{ >+ if (updateInfo.updateRectBounds.isEmpty()) >+ return; >+ >+ if (!m_backingStore) >+ m_backingStore.emplace(updateInfo.viewSize, updateInfo.deviceScaleFactor, m_webPageProxy); >+ >+ m_backingStore->incorporateUpdate(updateInfo); >+ >+ WebCore::Region damageRegion; >+ if (updateInfo.scrollRect.isEmpty()) { >+ for (const auto& rect : updateInfo.updateRects) >+ damageRegion.unite(rect); >+ } else >+ damageRegion = WebCore::IntRect({ }, m_webPageProxy.viewSize()); >+ m_webPageProxy.setViewNeedsDisplay(damageRegion); >+} >+ >+void DrawingAreaProxyWC::discardBackingStore() >+{ >+ m_backingStore = std::nullopt; >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.h b/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.h >new file mode 100644 >index 000000000000..a147c11cf473 >--- /dev/null >+++ b/Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.h >@@ -0,0 +1,58 @@ >+/* >+ * 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 >+ >+#include "BackingStore.h" >+#include "DrawingAreaProxy.h" >+ >+namespace WebCore { >+class Region; >+} >+ >+namespace WebKit { >+ >+class DrawingAreaProxyWC final : public DrawingAreaProxy { >+public: >+ DrawingAreaProxyWC(WebPageProxy&, WebProcessProxy&); >+ >+ void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion); >+ >+private: >+ // DrawingAreaProxy >+ void deviceScaleFactorDidChange() override { } >+ void sizeDidChange() override; >+ // message handers >+ void update(uint64_t, const UpdateInfo&); >+ void enterAcceleratedCompositingMode(uint64_t, const LayerTreeContext&); >+ >+ void incorporateUpdate(const UpdateInfo&); >+ void discardBackingStore(); >+ >+ uint64_t m_currentBackingStoreStateID { 0 }; >+ std::optional<BackingStore> m_backingStore; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/win/PageClientImpl.cpp b/Source/WebKit/UIProcess/win/PageClientImpl.cpp >index 220898c122fc..c79706a124b4 100644 >--- a/Source/WebKit/UIProcess/win/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/win/PageClientImpl.cpp >@@ -28,6 +28,7 @@ > #include "PageClientImpl.h" > > #include "DrawingAreaProxyCoordinatedGraphics.h" >+#include "DrawingAreaProxyWC.h" > #include "WebContextMenuProxyWin.h" > #include "WebPageProxy.h" > #include "WebPopupMenuProxyWin.h" >@@ -47,6 +48,8 @@ PageClientImpl::PageClientImpl(WebView& view) > // PageClient's pure virtual functions > std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(WebProcessProxy& process) > { >+ if (m_view.page()->preferences().useGPUProcessForWebGLEnabled()) >+ return makeUnique<DrawingAreaProxyWC>(*m_view.page(), process); > return makeUnique<DrawingAreaProxyCoordinatedGraphics>(*m_view.page(), process); > } > >diff --git a/Source/WebKit/UIProcess/win/WebView.cpp b/Source/WebKit/UIProcess/win/WebView.cpp >index 1dff4cc683ea..0c7f40cb49ff 100644 >--- a/Source/WebKit/UIProcess/win/WebView.cpp >+++ b/Source/WebKit/UIProcess/win/WebView.cpp >@@ -29,6 +29,7 @@ > > #include "APIPageConfiguration.h" > #include "DrawingAreaProxyCoordinatedGraphics.h" >+#include "DrawingAreaProxyWC.h" > #include "Logging.h" > #include "NativeWebKeyboardEvent.h" > #include "NativeWebMouseEvent.h" >@@ -491,31 +492,43 @@ void WebView::paint(HDC hdc, const IntRect& dirtyRect) > if (dirtyRect.isEmpty()) > return; > m_page->endPrinting(); >- if (auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_page->drawingArea())) { >- // FIXME: We should port WebKit1's rect coalescing logic here. >- Region unpaintedRegion; >+ if (m_page->drawingArea()) { >+ auto painter = [&](auto drawingArea) { >+ // FIXME: We should port WebKit1's rect coalescing logic here. >+ Region unpaintedRegion; > #if USE(CAIRO) >- cairo_surface_t* surface = cairo_win32_surface_create(hdc); >- cairo_t* context = cairo_create(surface); >- >- drawingArea->paint(context, dirtyRect, unpaintedRegion); >- >- cairo_destroy(context); >- cairo_surface_destroy(surface); >-#else >- COMPtr<ID3D11Texture2D> backBuffer; >- HRESULT hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); >- if (SUCCEEDED(hr)) { >- BackingStore::DXConnections context { m_immediateContext.get(), backBuffer.get() }; >+ cairo_surface_t* surface = cairo_win32_surface_create(hdc); >+ cairo_t* context = cairo_create(surface); >+ > drawingArea->paint(context, dirtyRect, unpaintedRegion); >- } >- >- m_swapChain->Present(0, 0); >+ >+ cairo_destroy(context); >+ cairo_surface_destroy(surface); >+#else >+ COMPtr<ID3D11Texture2D> backBuffer; >+ HRESULT hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); >+ if (SUCCEEDED(hr)) { >+ BackingStore::DXConnections context { m_immediateContext.get(), backBuffer.get() }; >+ drawingArea->paint(context, dirtyRect, unpaintedRegion); >+ } >+ >+ m_swapChain->Present(0, 0); > #endif >- >- auto unpaintedRects = unpaintedRegion.rects(); >- for (auto& rect : unpaintedRects) >- drawPageBackground(hdc, m_page.get(), rect); >+ >+ auto unpaintedRects = unpaintedRegion.rects(); >+ for (auto& rect : unpaintedRects) >+ drawPageBackground(hdc, m_page.get(), rect); >+ }; >+ switch (m_page->drawingArea()->type()) { >+ case DrawingAreaType::WC: >+ painter(static_cast<DrawingAreaProxyWC*>(m_page->drawingArea())); >+ break; >+ case DrawingAreaType::CoordinatedGraphics: >+ painter(static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_page->drawingArea())); >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ } > } else > drawPageBackground(hdc, m_page.get(), dirtyRect); > } >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp >index 31d79f9f1d30..1142166d2e15 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp >@@ -40,6 +40,10 @@ > #include <WebCore/GraphicsContextGLIOSurfaceSwapChain.h> > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+#include "WCPlatformLayerGCGL.h" >+#endif >+ > namespace WebKit { > > using namespace WebCore; >@@ -62,6 +66,9 @@ RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy(GPUProcessConnection& > // TODO: We must wait until initialized, because at the moment we cannot receive IPC messages > // during wait while in synchronous stream send. Should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=217211. > waitUntilInitialized(); >+#if USE(GRAPHICS_LAYER_WC) >+ setPlatformLayer(makeUnique<WCPlatformLayerGCGL>(m_graphicsContextGLIdentifier)); >+#endif > } > > RemoteGraphicsContextGLProxy::~RemoteGraphicsContextGLProxy() >diff --git a/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp >new file mode 100644 >index 000000000000..c371dd988830 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp >@@ -0,0 +1,103 @@ >+/* >+ * 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 "RemoteWCLayerTreeHostProxy.h" >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+#include "GPUConnectionToWebProcess.h" >+#include "RemoteWCLayerTreeHostMessages.h" >+#include "RemoteWCLayerTreeHostProxyMessages.h" >+#include "WCUpateInfo.h" >+#include "WebPage.h" >+#include "WebProcess.h" >+ >+namespace WebKit { >+ >+RemoteWCLayerTreeHostProxy::RemoteWCLayerTreeHostProxy(WebPage& page, Client& client) >+ : m_page(page) >+ , m_client(client) >+{ >+} >+ >+RemoteWCLayerTreeHostProxy::~RemoteWCLayerTreeHostProxy() >+{ >+ disconnectGpuProcessIfNeeded(); >+} >+ >+IPC::Connection* RemoteWCLayerTreeHostProxy::messageSenderConnection() const >+{ >+ return &const_cast<RemoteWCLayerTreeHostProxy&>(*this).ensureGPUProcessConnection().connection(); >+} >+ >+GPUProcessConnection& RemoteWCLayerTreeHostProxy::ensureGPUProcessConnection() >+{ >+ if (!m_gpuProcessConnection) { >+ auto& gpuProcessConnection = WebProcess::singleton().ensureGPUProcessConnection(); >+ gpuProcessConnection.addClient(*this); >+ gpuProcessConnection.messageReceiverMap().addMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64(), *this); >+ gpuProcessConnection.connection().send( >+ Messages::GPUConnectionToWebProcess::CreateWCLayerTreeHost(wcLayerTreeHostIdentifier(), m_page.nativeWindowHandle()), >+ 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply); >+ m_gpuProcessConnection = gpuProcessConnection; >+ } >+ return *m_gpuProcessConnection; >+} >+ >+void RemoteWCLayerTreeHostProxy::disconnectGpuProcessIfNeeded() >+{ >+ if (auto gpuProcessConnection = std::exchange(m_gpuProcessConnection, nullptr)) { >+ gpuProcessConnection->removeClient(*this); >+ gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64()); >+ gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseWCLayerTreeHost(wcLayerTreeHostIdentifier()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply); >+ } >+} >+ >+void RemoteWCLayerTreeHostProxy::gpuProcessConnectionDidClose(GPUProcessConnection& previousConnection) >+{ >+ previousConnection.removeClient(*this); >+ m_gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64()); >+ m_gpuProcessConnection = nullptr; >+} >+ >+uint64_t RemoteWCLayerTreeHostProxy::messageSenderDestinationID() const >+{ >+ return wcLayerTreeHostIdentifier().toUInt64(); >+} >+ >+void RemoteWCLayerTreeHostProxy::update(WCUpateInfo&& updateInfo) >+{ >+ send(Messages::RemoteWCLayerTreeHost::Update(updateInfo)); >+} >+ >+void RemoteWCLayerTreeHostProxy::didUpdate() >+{ >+ m_client.didUpdate(); >+} >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.h b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.h >new file mode 100644 >index 000000000000..f9cf7ce7a9bc >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.h >@@ -0,0 +1,80 @@ >+/* >+ * 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 "GPUProcessConnection.h" >+#include "MessageReceiver.h" >+#include "MessageSender.h" >+#include "WCLayerTreeHostIdentifier.h" >+ >+namespace WebKit { >+ >+struct WCUpateInfo; >+ >+class RemoteWCLayerTreeHostProxy >+ : private IPC::MessageReceiver >+ , private IPC::MessageSender >+ , private GPUProcessConnection::Client { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ class Client { >+ public: >+ virtual void didUpdate() = 0; >+ }; >+ >+ RemoteWCLayerTreeHostProxy(WebPage&, Client&); >+ ~RemoteWCLayerTreeHostProxy(); >+ >+ void update(WCUpateInfo&&); >+ >+ void didUpdate(); >+ >+private: >+ WCLayerTreeHostIdentifier wcLayerTreeHostIdentifier() const { return m_wcLayerTreeHostIdentifier; }; >+ GPUProcessConnection& ensureGPUProcessConnection(); >+ void disconnectGpuProcessIfNeeded(); >+ >+ // GPUProcessConnection::Client >+ void gpuProcessConnectionDidClose(GPUProcessConnection&) final; >+ >+ // IPC::MessageReceiver >+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; >+ >+ // IPC::MessageSender >+ IPC::Connection* messageSenderConnection() const override; >+ uint64_t messageSenderDestinationID() const override; >+ >+ WeakPtr<GPUProcessConnection> m_gpuProcessConnection; >+ WCLayerTreeHostIdentifier m_wcLayerTreeHostIdentifier { WCLayerTreeHostIdentifier::generate() }; >+ WebPage& m_page; >+ Client& m_client; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.messages.in b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.messages.in >new file mode 100644 >index 000000000000..4f8af77a3116 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.messages.in >@@ -0,0 +1,29 @@ >+# 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. >+ >+#if USE(GRAPHICS_LAYER_WC) >+ >+messages -> RemoteWCLayerTreeHostProxy NotRefCounted { >+ DidUpdate() >+} >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/wc/WCLayerTreeHostIdentifier.h b/Source/WebKit/WebProcess/GPU/graphics/wc/WCLayerTreeHostIdentifier.h >new file mode 100644 >index 000000000000..0dba05e155f8 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/wc/WCLayerTreeHostIdentifier.h >@@ -0,0 +1,39 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * 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 WCLayerTreeHostIdentifierType { }; >+using WCLayerTreeHostIdentifier = ObjectIdentifier<WCLayerTreeHostIdentifierType>; >+ >+} // namespace WebKit >+ >+#endif // USE(GRAPHICS_LAYER_WC) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h b/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h >new file mode 100644 >index 000000000000..a87e08e82e19 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/wc/WCPlatformLayerGCGL.h >@@ -0,0 +1,45 @@ >+/* >+ * 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 >+ >+#include "GraphicsContextGLIdentifier.h" >+#include <WebCore/WCPlatformLayer.h> >+ >+namespace WebKit { >+ >+class WCPlatformLayerGCGL : public WebCore::WCPlatformLayer { >+public: >+ WCPlatformLayerGCGL(GraphicsContextGLIdentifier identifier) >+ : m_graphicsContextGLIdentifier(identifier) >+ { >+ } >+ GraphicsContextGLIdentifier& graphicsContextGLIdentifier() { return m_graphicsContextGLIdentifier; } >+ >+private: >+ GraphicsContextGLIdentifier m_graphicsContextGLIdentifier; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/DrawingArea.cpp b/Source/WebKit/WebProcess/WebPage/DrawingArea.cpp >index a534407d0366..d1d2db8c0f1d 100644 >--- a/Source/WebKit/WebProcess/WebPage/DrawingArea.cpp >+++ b/Source/WebKit/WebProcess/WebPage/DrawingArea.cpp >@@ -40,6 +40,9 @@ > #elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER) > #include "DrawingAreaCoordinatedGraphics.h" > #endif >+#if USE(GRAPHICS_LAYER_WC) >+#include "DrawingAreaWC.h" >+#endif > > namespace WebKit { > using namespace WebCore; >@@ -57,6 +60,10 @@ std::unique_ptr<DrawingArea> DrawingArea::create(WebPage& webPage, const WebPage > #elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER) > case DrawingAreaType::CoordinatedGraphics: > return makeUnique<DrawingAreaCoordinatedGraphics>(webPage, parameters); >+#endif >+#if USE(GRAPHICS_LAYER_WC) >+ case DrawingAreaType::WC: >+ return makeUnique<DrawingAreaWC>(webPage, parameters); > #endif > } > >@@ -108,6 +115,10 @@ bool DrawingArea::supportsGPUProcessRendering(DrawingAreaType type) > #elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER) > case DrawingAreaType::CoordinatedGraphics: > return false; >+#endif >+#if USE(GRAPHICS_LAYER_WC) >+ case DrawingAreaType::WC: >+ return true; > #endif > default: > return false; >diff --git a/Source/WebKit/WebProcess/WebPage/DrawingArea.h b/Source/WebKit/WebProcess/WebPage/DrawingArea.h >index 5e0b9759c6cc..29d99aaf952b 100644 >--- a/Source/WebKit/WebProcess/WebPage/DrawingArea.h >+++ b/Source/WebKit/WebProcess/WebPage/DrawingArea.h >@@ -136,6 +136,10 @@ public: > virtual void updateGeometry(const WebCore::IntSize& viewSize, bool flushSynchronously, const WTF::MachSendRight& fencePort) { } > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ virtual void updateGeometry(uint64_t, WebCore::IntSize) { }; >+#endif >+ > #if USE(COORDINATED_GRAPHICS) || USE(GRAPHICS_LAYER_TEXTURE_MAPPER) > virtual void layerHostDidFlushLayers() { } > #endif >diff --git a/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in b/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in >index 9d5f6dca6e38..b196a9f05d24 100644 >--- a/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in >@@ -40,6 +40,10 @@ messages -> DrawingArea NotRefCounted { > AddTransactionCallbackID(WebKit::CallbackID callbackID) > #endif > >+#if USE(GRAPHICS_LAYER_WC) >+ UpdateGeometry(uint64_t backingStoreStateID, WebCore::IntSize viewSize) >+#endif >+ > #if PLATFORM(COCOA) || PLATFORM(GTK) > AdjustTransientZoom(double scale, WebCore::FloatPoint origin) > CommitTransientZoom(double scale, WebCore::FloatPoint origin) >diff --git a/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp b/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp >new file mode 100644 >index 000000000000..a5b667a25638 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp >@@ -0,0 +1,360 @@ >+/* >+ * 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 "DrawingAreaWC.h" >+ >+#include "DrawingAreaProxyMessages.h" >+#include "GraphicsLayerWC.h" >+#include "PlatformImageBufferShareableBackend.h" >+#include "RemoteWCLayerTreeHostProxy.h" >+#include "UpdateInfo.h" >+#include "WebPageCreationParameters.h" >+#include "WebProcess.h" >+#include <WebCore/ConcreteImageBuffer.h> >+#include <WebCore/Frame.h> >+#include <WebCore/FrameView.h> >+ >+namespace WebKit { >+using namespace WebCore; >+ >+DrawingAreaWC::DrawingAreaWC(WebPage& webPage, const WebPageCreationParameters& parameters) >+ : DrawingArea(DrawingAreaType::WC, parameters.drawingAreaIdentifier, webPage) >+ , m_rootLayerClient(webPage) >+ , m_remoteWCLayerTreeHostProxy(makeUnique<RemoteWCLayerTreeHostProxy>(webPage, *this)) >+ , m_layerFactory(*this) >+ , m_rootLayer(GraphicsLayer::create(graphicsLayerFactory(), this->m_rootLayerClient)) >+ , m_updateRenderingTimer(*this, &DrawingAreaWC::updateRendering) >+ , m_commitQueue(WorkQueue::create("DrawingAreaWC CommitQueue"_s)) >+{ >+ m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root")); >+ m_rootLayer->setDrawsContent(true); >+ m_rootLayer->setContentsOpaque(true); >+ m_rootLayer->setSize(m_webPage.size()); >+ m_rootLayer->setNeedsDisplay(); >+} >+ >+DrawingAreaWC::~DrawingAreaWC() >+{ >+ while (auto layer = m_liveGraphicsLayers.removeHead()) >+ layer->clearObserver(); >+} >+ >+GraphicsLayerFactory* DrawingAreaWC::graphicsLayerFactory() >+{ >+ return &m_layerFactory; >+} >+ >+void DrawingAreaWC::updateRootLayers() >+{ >+ Vector<Ref<GraphicsLayer>> children; >+ if (m_contentLayer) { >+ children.append(*m_contentLayer); >+ if (m_viewOverlayRootLayer) >+ children.append(*m_viewOverlayRootLayer); >+ } >+ m_rootLayer->setChildren(WTFMove(children)); >+ triggerRenderingUpdate(); >+} >+ >+void DrawingAreaWC::setRootCompositingLayer(GraphicsLayer* rootLayer) >+{ >+ m_contentLayer = rootLayer; >+ updateRootLayers(); >+} >+ >+void DrawingAreaWC::attachViewOverlayGraphicsLayer(GraphicsLayer* layer) >+{ >+ m_viewOverlayRootLayer = layer; >+ updateRootLayers(); >+} >+ >+void DrawingAreaWC::setLayerTreeStateIsFrozen(bool isFrozen) >+{ >+ if (m_isRenderingSuspended == isFrozen) >+ return; >+ m_isRenderingSuspended = isFrozen; >+ if (!m_isRenderingSuspended && m_hasDeferredRenderingUpdate) { >+ m_hasDeferredRenderingUpdate = false; >+ triggerRenderingUpdate(); >+ } >+} >+ >+void DrawingAreaWC::updateGeometry(uint64_t backingStoreStateID, IntSize viewSize) >+{ >+ m_backingStoreStateID = backingStoreStateID; >+ m_webPage.setSize(viewSize); >+ m_rootLayer->setSize(m_webPage.size()); >+} >+ >+void DrawingAreaWC::setNeedsDisplay() >+{ >+ m_dirtyRegion = { }; >+ m_scrollRect = { }; >+ m_scrollOffset = { }; >+ setNeedsDisplayInRect(m_webPage.bounds()); >+} >+ >+void DrawingAreaWC::setNeedsDisplayInRect(const IntRect& rect) >+{ >+ if (isCompositingMode()) >+ m_rootLayer->setNeedsDisplayInRect(rect); >+ else >+ m_dirtyRegion.unite(rect); >+ triggerRenderingUpdate(); >+} >+ >+void DrawingAreaWC::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) >+{ >+ if (isCompositingMode()) >+ m_rootLayer->setNeedsDisplayInRect(scrollRect); >+ else { >+ if (scrollRect != m_scrollRect) { >+ // Just repaint the entire current scroll rect, we'll scroll the new rect instead. >+ setNeedsDisplayInRect(m_scrollRect); >+ m_scrollRect = { }; >+ m_scrollOffset = { }; >+ } >+ // Get the part of the dirty region that is in the scroll rect. >+ Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion); >+ if (!dirtyRegionInScrollRect.isEmpty()) { >+ // There are parts of the dirty region that are inside the scroll rect. >+ // We need to subtract them from the region, move them and re-add them. >+ m_dirtyRegion.subtract(scrollRect); >+ // Move the dirty parts. >+ Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect); >+ // And add them back. >+ m_dirtyRegion.unite(movedDirtyRegionInScrollRect); >+ } >+ // Compute the scroll repaint region. >+ Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); >+ m_dirtyRegion.unite(scrollRepaintRegion); >+ m_scrollRect = scrollRect; >+ m_scrollOffset += scrollDelta; >+ triggerRenderingUpdate(); >+ } >+} >+ >+void DrawingAreaWC::triggerRenderingUpdate() >+{ >+ if (m_isRenderingSuspended || m_waitDidUpdate) { >+ m_hasDeferredRenderingUpdate = true; >+ return; >+ } >+ if (m_updateRenderingTimer.isActive()) >+ return; >+ m_updateRenderingTimer.startOneShot(0_s); >+} >+ >+static void flushLayerImageBuffers(WCUpateInfo& info) >+{ >+ for (auto& layerInfo : info.changedLayers) { >+ if (layerInfo.changes & WCLayerChange::BackingStore) { >+ if (auto image = layerInfo.backingStore.imageBuffer()) { >+ if (auto flusher = image->createFlusher()) >+ flusher->flush(); >+ } >+ } >+ } >+} >+ >+bool DrawingAreaWC::isCompositingMode() >+{ >+ return m_contentLayer; >+} >+ >+void DrawingAreaWC::updateRendering() >+{ >+ if (m_isRenderingSuspended) { >+ m_hasDeferredRenderingUpdate = true; >+ return; >+ } >+ >+ // This function is not reentrant, e.g. a rAF callback may force repaint. >+ if (m_inUpdateRendering) >+ return; >+ SetForScope<bool> change(m_inUpdateRendering, true); >+ >+ ASSERT(!m_waitDidUpdate); >+ m_waitDidUpdate = true; >+ >+ m_webPage.updateRendering(); >+ m_webPage.flushPendingEditorStateUpdate(); >+ >+ OptionSet<FinalizeRenderingUpdateFlags> flags; >+ m_webPage.finalizeRenderingUpdate(flags); >+ m_webPage.didUpdateRendering(); >+ >+ if (isCompositingMode()) >+ sendUpdateAC(); >+ else >+ sendUpdateNonAC(); >+} >+ >+void DrawingAreaWC::sendUpdateAC() >+{ >+ m_rootLayer->flushCompositingStateForThisLayerOnly(); >+ >+ // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually. >+ if (m_viewOverlayRootLayer) >+ m_viewOverlayRootLayer->flushCompositingState({ }); >+ >+ m_updateInfo.rootLayer = m_rootLayer->primaryLayerID(); >+ >+ m_commitQueue->dispatch([this, weakThis = WeakPtr(*this), updateInfo = std::exchange(m_updateInfo, { })]() mutable { >+ flushLayerImageBuffers(updateInfo); >+ RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), updateInfo = WTFMove(updateInfo)]() mutable { >+ if (!weakThis) >+ return; >+ m_remoteWCLayerTreeHostProxy->update(WTFMove(updateInfo)); >+ }); >+ }); >+} >+ >+static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect, 1>& rects) >+{ >+ constexpr size_t rectThreshold = 10; >+ constexpr double wastedSpaceThreshold = 0.75; >+ >+ if (rects.size() <= 1 || rects.size() > rectThreshold) >+ return true; >+ // Attempt to guess whether or not we should use the region bounds rect or the individual rects. >+ // We do this by computing the percentage of "wasted space" in the bounds. If that wasted space >+ // is too large, then we will do individual rect painting instead. >+ unsigned boundsArea = bounds.width() * bounds.height(); >+ unsigned rectsArea = 0; >+ for (size_t i = 0; i < rects.size(); ++i) >+ rectsArea += rects[i].width() * rects[i].height(); >+ >+ double wastedSpace = 1 - (static_cast<double>(rectsArea) / boundsArea); >+ return wastedSpace <= wastedSpaceThreshold; >+} >+ >+void DrawingAreaWC::sendUpdateNonAC() >+{ >+ if (m_dirtyRegion.isEmpty()) { >+ didUpdate(); >+ return; >+ } >+ IntRect bounds = m_dirtyRegion.bounds(); >+ ASSERT(m_webPage.bounds().contains(bounds)); >+ IntSize bitmapSize = bounds.size(); >+ float deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); >+ bitmapSize.scale(deviceScaleFactor); >+ >+ auto image = createImageBuffer(bitmapSize); >+ auto rects = m_dirtyRegion.rects(); >+ if (shouldPaintBoundsRect(bounds, rects)) { >+ rects.clear(); >+ rects.append(bounds); >+ } >+ m_dirtyRegion = { }; >+ >+ UpdateInfo updateInfo; >+ updateInfo.viewSize = m_webPage.size(); >+ updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); >+ updateInfo.updateRectBounds = bounds; >+ updateInfo.updateRects = rects; >+ updateInfo.scrollRect = m_scrollRect; >+ updateInfo.scrollOffset = m_scrollOffset; >+ m_scrollRect = { }; >+ m_scrollOffset = { }; >+ >+ auto& graphicsContext = image->context(); >+ graphicsContext.applyDeviceScaleFactor(deviceScaleFactor); >+ graphicsContext.translate(-bounds.x(), -bounds.y()); >+ for (const auto& rect : rects) >+ m_webPage.drawRect(image->context(), rect); >+ image->flushDrawingContextAsync(); >+ >+ m_commitQueue->dispatch([this, weakThis = WeakPtr(*this), stateID = m_backingStoreStateID, updateInfo = WTFMove(updateInfo), image]() mutable { >+ if (auto flusher = image->createFlusher()) >+ flusher->flush(); >+ RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), stateID, updateInfo = WTFMove(updateInfo), image]() mutable { >+ if (!weakThis) >+ return; >+ if (stateID != m_backingStoreStateID) { >+ didUpdate(); >+ return; >+ } >+ auto handle = static_cast<UnacceleratedImageBufferShareableBackend&>(*image->ensureBackendCreated()).createImageBufferBackendHandle(); >+ updateInfo.bitmapHandle = std::get<ShareableBitmap::Handle>(WTFMove(handle)); >+ send(Messages::DrawingAreaProxy::Update(stateID, WTFMove(updateInfo))); >+ }); >+ }); >+} >+ >+void DrawingAreaWC::graphicsLayerAdded(GraphicsLayerWC& layer) >+{ >+ m_liveGraphicsLayers.append(&layer); >+ m_updateInfo.addedLayers.append(layer.primaryLayerID()); >+} >+ >+void DrawingAreaWC::graphicsLayerRemoved(GraphicsLayerWC& layer) >+{ >+ m_liveGraphicsLayers.remove(&layer); >+ m_updateInfo.removedLayers.append(layer.primaryLayerID()); >+} >+ >+void DrawingAreaWC::commitLayerUpateInfo(WCLayerUpateInfo&& info) >+{ >+ m_updateInfo.changedLayers.append(WTFMove(info)); >+} >+ >+RefPtr<ImageBuffer> DrawingAreaWC::createImageBuffer(FloatSize size) >+{ >+ if (WebProcess::singleton().shouldUseRemoteRenderingFor(RenderingPurpose::DOM)) >+ return m_webPage.ensureRemoteRenderingBackendProxy().createImageBuffer(size, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8); >+ return ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(size, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, nullptr); >+} >+ >+void DrawingAreaWC::didUpdate() >+{ >+ m_waitDidUpdate = false; >+ if (m_hasDeferredRenderingUpdate) { >+ m_hasDeferredRenderingUpdate = false; >+ triggerRenderingUpdate(); >+ } >+} >+ >+DrawingAreaWC::RootLayerClient::RootLayerClient(WebPage& webPage) >+ : m_webPage(webPage) >+{ >+} >+ >+void DrawingAreaWC::RootLayerClient::paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& rectToPaint, GraphicsLayerPaintBehavior) >+{ >+ context.save(); >+ context.clip(rectToPaint); >+ m_webPage.corePage()->mainFrame().view()->paint(context, enclosingIntRect(rectToPaint)); >+ context.restore(); >+} >+ >+float DrawingAreaWC::RootLayerClient::deviceScaleFactor() const >+{ >+ return m_webPage.corePage()->deviceScaleFactor(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h b/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h >new file mode 100644 >index 000000000000..872172df2b60 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h >@@ -0,0 +1,103 @@ >+/* >+ * 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 >+ >+#include "DrawingArea.h" >+#include "GraphicsLayerWC.h" >+#include "RemoteWCLayerTreeHostProxy.h" >+#include "WCLayerFactory.h" >+#include <WebCore/GraphicsLayerFactory.h> >+#include <WebCore/Timer.h> >+ >+namespace WebKit { >+ >+class DrawingAreaWC final >+ : public DrawingArea >+ , public GraphicsLayerWC::Observer >+ , public RemoteWCLayerTreeHostProxy::Client { >+public: >+ DrawingAreaWC(WebPage&, const WebPageCreationParameters&); >+ ~DrawingAreaWC() override; >+ >+private: >+ // DrawingArea >+ WebCore::GraphicsLayerFactory* graphicsLayerFactory() override; >+ void setNeedsDisplay() override; >+ void setNeedsDisplayInRect(const WebCore::IntRect&) override; >+ void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override; >+ void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override { } >+ void triggerRenderingUpdate() override; >+ void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override { } >+ void deviceOrPageScaleFactorChanged() override { } >+ void setLayerTreeStateIsFrozen(bool) override; >+ bool layerTreeStateIsFrozen() const override { return m_isRenderingSuspended; } >+ void updateGeometry(uint64_t, WebCore::IntSize) override; >+ void setRootCompositingLayer(WebCore::GraphicsLayer*) override; >+ void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override; >+ // GraphicsLayerWC::Observer >+ void graphicsLayerAdded(GraphicsLayerWC&) override; >+ void graphicsLayerRemoved(GraphicsLayerWC&) override; >+ void commitLayerUpateInfo(WCLayerUpateInfo&&) override; >+ RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize) override; >+ // RemoteWCLayerTreeHostProxy::Client >+ void didUpdate() override; >+ >+ bool isCompositingMode(); >+ void updateRendering(); >+ void sendUpdateAC(); >+ void sendUpdateNonAC(); >+ void updateRootLayers(); >+ >+ class RootLayerClient : public WebCore::GraphicsLayerClient { >+ public: >+ RootLayerClient(WebPage&); >+ private: >+ void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::FloatRect& rectToPaint, WebCore::GraphicsLayerPaintBehavior) override; >+ float deviceScaleFactor() const override; >+ WebPage& m_webPage; >+ }; >+ >+ RootLayerClient m_rootLayerClient; >+ std::unique_ptr<RemoteWCLayerTreeHostProxy> m_remoteWCLayerTreeHostProxy; >+ WCLayerFactory m_layerFactory; >+ DoublyLinkedList<GraphicsLayerWC> m_liveGraphicsLayers; >+ WebCore::Timer m_updateRenderingTimer; >+ bool m_isRenderingSuspended { false }; >+ bool m_hasDeferredRenderingUpdate { false }; >+ bool m_inUpdateRendering { false }; >+ bool m_waitDidUpdate { false }; >+ WCUpateInfo m_updateInfo; >+ Ref<WebCore::GraphicsLayer> m_rootLayer; >+ RefPtr<WebCore::GraphicsLayer> m_contentLayer; >+ RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer; >+ Ref<WorkQueue> m_commitQueue; >+ int64_t m_backingStoreStateID { 0 }; >+ WebCore::Region m_dirtyRegion; >+ WebCore::IntRect m_scrollRect; >+ WebCore::IntSize m_scrollOffset; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp b/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp >new file mode 100644 >index 000000000000..441724dc791b >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp >@@ -0,0 +1,466 @@ >+/* >+ * 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. ``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 >+ * 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 "GraphicsLayerWC.h" >+ >+#include "WCPlatformLayerGCGL.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+GraphicsLayerWC::GraphicsLayerWC(Type layerType, GraphicsLayerClient& client, Observer& observer) >+ : GraphicsLayer(layerType, client) >+ , m_observer(&observer) >+{ >+ m_observer->graphicsLayerAdded(*this); >+} >+ >+GraphicsLayerWC::~GraphicsLayerWC() >+{ >+ willBeDestroyed(); >+ if (m_observer) >+ m_observer->graphicsLayerRemoved(*this); >+} >+ >+GraphicsLayer::PlatformLayerID GraphicsLayerWC::generateLayerID() >+{ >+ // 0 and max can't be used for hash keys >+ static GraphicsLayer::PlatformLayerID id = 1; >+ return id++; >+} >+ >+GraphicsLayer::PlatformLayerID GraphicsLayerWC::primaryLayerID() const >+{ >+ return m_layerID; >+} >+ >+void GraphicsLayerWC::setNeedsDisplay() >+{ >+ if (!drawsContent()) >+ return; >+ noteLayerPropertyChanged(WCLayerChange::BackingStore); >+ addRepaintRect({ { }, m_size }); >+} >+ >+void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer) >+{ >+ if (!drawsContent()) >+ return; >+ noteLayerPropertyChanged(WCLayerChange::BackingStore); >+ addRepaintRect(rect); >+} >+ >+void GraphicsLayerWC::setContentsNeedsDisplay() >+{ >+ // For example, if WebGL canvas changed, it needs flush to display. >+ noteLayerPropertyChanged({ }); >+} >+ >+bool GraphicsLayerWC::setChildren(Vector<Ref<GraphicsLayer>>&& children) >+{ >+ bool childrenChanged = GraphicsLayer::setChildren(WTFMove(children)); >+ if (childrenChanged) >+ noteLayerPropertyChanged(WCLayerChange::Children); >+ return childrenChanged; >+} >+ >+void GraphicsLayerWC::addChild(Ref<GraphicsLayer>&& childLayer) >+{ >+ GraphicsLayer::addChild(WTFMove(childLayer)); >+ noteLayerPropertyChanged(WCLayerChange::Children); >+} >+ >+void GraphicsLayerWC::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index) >+{ >+ GraphicsLayer::addChildAtIndex(WTFMove(childLayer), index); >+ noteLayerPropertyChanged(WCLayerChange::Children); >+} >+ >+void GraphicsLayerWC::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling) >+{ >+ GraphicsLayer::addChildBelow(WTFMove(childLayer), sibling); >+ noteLayerPropertyChanged(WCLayerChange::Children); >+} >+ >+void GraphicsLayerWC::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling) >+{ >+ GraphicsLayer::addChildAbove(WTFMove(childLayer), sibling); >+ noteLayerPropertyChanged(WCLayerChange::Children); >+} >+ >+bool GraphicsLayerWC::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) >+{ >+ if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) { >+ noteLayerPropertyChanged(WCLayerChange::Children); >+ return true; >+ } >+ return false; >+} >+ >+void GraphicsLayerWC::removeFromParent() >+{ >+ if (m_parent) >+ static_cast<GraphicsLayerWC*>(m_parent)->noteLayerPropertyChanged(WCLayerChange::Children); >+ GraphicsLayer::removeFromParent(); >+} >+ >+void GraphicsLayerWC::setMaskLayer(RefPtr<GraphicsLayer>&& layer) >+{ >+ if (layer == m_maskLayer) >+ return; >+ GraphicsLayer::setMaskLayer(WTFMove(layer)); >+ noteLayerPropertyChanged(WCLayerChange::MaskLayer); >+} >+ >+void GraphicsLayerWC::setReplicatedLayer(GraphicsLayer* layer) >+{ >+ if (layer == m_replicatedLayer) >+ return; >+ GraphicsLayer::setReplicatedLayer(layer); >+ noteLayerPropertyChanged(WCLayerChange::ReplicaLayer); >+} >+ >+void GraphicsLayerWC::setReplicatedByLayer(RefPtr<GraphicsLayer>&& layer) >+{ >+ if (layer == m_replicaLayer) >+ return; >+ GraphicsLayer::setReplicatedByLayer(WTFMove(layer)); >+ noteLayerPropertyChanged(WCLayerChange::ReplicaLayer); >+} >+ >+void GraphicsLayerWC::setPosition(const FloatPoint& point) >+{ >+ if (point == m_position) >+ return; >+ GraphicsLayer::setPosition(point); >+ noteLayerPropertyChanged(WCLayerChange::Geometry); >+} >+ >+void GraphicsLayerWC::setAnchorPoint(const FloatPoint3D& point) >+{ >+ if (point == m_anchorPoint) >+ return; >+ GraphicsLayer::setAnchorPoint(point); >+ noteLayerPropertyChanged(WCLayerChange::Geometry); >+} >+ >+void GraphicsLayerWC::setSize(const FloatSize& size) >+{ >+ if (size == m_size) >+ return; >+ GraphicsLayer::setSize(size); >+ noteLayerPropertyChanged(WCLayerChange::Geometry); >+} >+ >+void GraphicsLayerWC::setBoundsOrigin(const FloatPoint& origin) >+{ >+ if (origin == m_boundsOrigin) >+ return; >+ GraphicsLayer::setBoundsOrigin(origin); >+ noteLayerPropertyChanged(WCLayerChange::Geometry); >+} >+ >+void GraphicsLayerWC::setTransform(const TransformationMatrix& t) >+{ >+ if (t == transform()) >+ return; >+ GraphicsLayer::setTransform(t); >+ noteLayerPropertyChanged(WCLayerChange::Transform); >+} >+ >+void GraphicsLayerWC::setChildrenTransform(const TransformationMatrix& t) >+{ >+ if (t == childrenTransform()) >+ return; >+ GraphicsLayer::setChildrenTransform(t); >+ noteLayerPropertyChanged(WCLayerChange::ChildrenTransform); >+} >+ >+void GraphicsLayerWC::setPreserves3D(bool value) >+{ >+ if (value == preserves3D()) >+ return; >+ GraphicsLayer::setPreserves3D(value); >+ noteLayerPropertyChanged(WCLayerChange::Preserves3D); >+} >+ >+void GraphicsLayerWC::setMasksToBounds(bool value) >+{ >+ if (value == masksToBounds()) >+ return; >+ GraphicsLayer::setMasksToBounds(value); >+ noteLayerPropertyChanged(WCLayerChange::MasksToBounds); >+} >+ >+void GraphicsLayerWC::setOpacity(float value) >+{ >+ if (value == opacity()) >+ return; >+ GraphicsLayer::setOpacity(value); >+ noteLayerPropertyChanged(WCLayerChange::Opacity); >+} >+ >+void GraphicsLayerWC::setContentsRect(const FloatRect& value) >+{ >+ if (value == contentsRect()) >+ return; >+ GraphicsLayer::setContentsRect(value); >+ noteLayerPropertyChanged(WCLayerChange::ContentsRect); >+} >+ >+void GraphicsLayerWC::setContentsClippingRect(const FloatRoundedRect& value) >+{ >+ if (value == contentsClippingRect()) >+ return; >+ GraphicsLayer::setContentsClippingRect(value); >+ noteLayerPropertyChanged(WCLayerChange::ContentsClippingRect); >+} >+ >+void GraphicsLayerWC::setDrawsContent(bool value) >+{ >+ if (value == drawsContent()) >+ return; >+ GraphicsLayer::setDrawsContent(value); >+ noteLayerPropertyChanged(WCLayerChange::BackingStore); >+} >+ >+void GraphicsLayerWC::setContentsVisible(bool value) >+{ >+ if (value == contentsAreVisible()) >+ return; >+ GraphicsLayer::setContentsVisible(value); >+ noteLayerPropertyChanged(WCLayerChange::ContentsVisible); >+} >+ >+void GraphicsLayerWC::setBackfaceVisibility(bool value) >+{ >+ if (value == backfaceVisibility()) >+ return; >+ GraphicsLayer::setBackfaceVisibility(value); >+ noteLayerPropertyChanged(WCLayerChange::BackfaceVisibility); >+} >+ >+void GraphicsLayerWC::setContentsToSolidColor(const Color& color) >+{ >+ if (color == m_solidColor) >+ return; >+ m_solidColor = color; >+ noteLayerPropertyChanged(WCLayerChange::SolidColor); >+} >+ >+void GraphicsLayerWC::setContentsToPlatformLayer(PlatformLayer* platformLayer, ContentsLayerPurpose) >+{ >+ if (m_platformLayer == platformLayer) >+ return; >+ m_platformLayer = platformLayer; >+ noteLayerPropertyChanged(WCLayerChange::PlatformLayer); >+} >+ >+bool GraphicsLayerWC::usesContentsLayer() const >+{ >+ return m_platformLayer; >+} >+ >+void GraphicsLayerWC::setShowDebugBorder(bool show) >+{ >+ if (isShowingDebugBorder() == show) >+ return; >+ GraphicsLayer::setShowDebugBorder(show); >+ updateDebugIndicators(); >+ noteLayerPropertyChanged(WCLayerChange::DebugVisuals); >+} >+ >+void GraphicsLayerWC::setDebugBorder(const Color& color, float width) >+{ >+ m_debugBorderColor = color; >+ m_debugBorderWidth = width; >+ noteLayerPropertyChanged(WCLayerChange::DebugVisuals); >+} >+ >+void GraphicsLayerWC::setShowRepaintCounter(bool show) >+{ >+ if (isShowingRepaintCounter() == show) >+ return; >+ GraphicsLayer::setShowRepaintCounter(show); >+ noteLayerPropertyChanged(WCLayerChange::RepaintCount); >+} >+ >+static bool filtersCanBeComposited(const FilterOperations& filters) >+{ >+ if (!filters.size()) >+ return false; >+ for (const auto& filterOperation : filters.operations()) { >+ if (filterOperation->type() == FilterOperation::REFERENCE) >+ return false; >+ } >+ return true; >+} >+ >+bool GraphicsLayerWC::setFilters(const FilterOperations& filters) >+{ >+ bool canCompositeFilters = filtersCanBeComposited(filters); >+ if (GraphicsLayer::filters() == filters) >+ return canCompositeFilters; >+ >+ if (canCompositeFilters) { >+ if (!GraphicsLayer::setFilters(filters)) >+ return false; >+ } else if (GraphicsLayer::filters().size()) >+ clearFilters(); >+ >+ noteLayerPropertyChanged(WCLayerChange::Filters); >+ return canCompositeFilters; >+} >+ >+bool GraphicsLayerWC::setBackdropFilters(const FilterOperations& filters) >+{ >+ bool canCompositeFilters = filtersCanBeComposited(filters); >+ if (m_backdropFilters == filters) >+ return canCompositeFilters; >+ if (canCompositeFilters) >+ GraphicsLayer::setBackdropFilters(filters); >+ else >+ clearBackdropFilters(); >+ noteLayerPropertyChanged(WCLayerChange::BackdropFilters); >+ return canCompositeFilters; >+} >+ >+void GraphicsLayerWC::setBackdropFiltersRect(const FloatRoundedRect& backdropFiltersRect) >+{ >+ if (m_backdropFiltersRect == backdropFiltersRect) >+ return; >+ GraphicsLayer::setBackdropFiltersRect(backdropFiltersRect); >+ noteLayerPropertyChanged(WCLayerChange::BackdropFilters); >+} >+ >+void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags) >+{ >+ if (beingDestroyed()) >+ return; >+ bool needsFlush = !m_uncommittedChanges; >+ m_uncommittedChanges.add(flags); >+ if (needsFlush) >+ client().notifyFlushRequired(this); >+} >+ >+void GraphicsLayerWC::flushCompositingState(const FloatRect& rect) >+{ >+ if (auto* mask = maskLayer()) >+ mask->flushCompositingStateForThisLayerOnly(); >+ if (auto* replica = replicaLayer()) >+ replica->flushCompositingStateForThisLayerOnly(); >+ flushCompositingStateForThisLayerOnly(); >+ for (auto& child : children()) >+ child->flushCompositingState(rect); >+} >+ >+void GraphicsLayerWC::flushCompositingStateForThisLayerOnly() >+{ >+ if (!m_uncommittedChanges) >+ return; >+ WCLayerUpateInfo update; >+ update.id = primaryLayerID(); >+ update.changes = std::exchange(m_uncommittedChanges, { }); >+ if (update.changes & WCLayerChange::Children) { >+ update.children = WTF::map(children(), [](auto& layer) { >+ return layer->primaryLayerID(); >+ }); >+ } >+ if (update.changes & WCLayerChange::MaskLayer) { >+ if (maskLayer()) >+ update.maskLayer = maskLayer()->primaryLayerID(); >+ else >+ update.maskLayer = std::nullopt; >+ } >+ if (update.changes & WCLayerChange::ReplicaLayer) { >+ if (replicaLayer()) >+ update.replicaLayer = replicaLayer()->primaryLayerID(); >+ else >+ update.replicaLayer = std::nullopt; >+ } >+ if (update.changes & WCLayerChange::Geometry) { >+ update.position = position(); >+ update.anchorPoint = anchorPoint(); >+ update.size = size(); >+ update.boundsOrigin = boundsOrigin(); >+ } >+ if (update.changes & WCLayerChange::Preserves3D) >+ update.preserves3D = preserves3D(); >+ if (update.changes & WCLayerChange::ContentsRect) >+ update.contentsRect = contentsRect(); >+ if (update.changes & WCLayerChange::ContentsClippingRect) >+ update.contentsClippingRect = contentsClippingRect(); >+ if (update.changes & WCLayerChange::ContentsVisible) >+ update.contentsVisible = contentsAreVisible(); >+ if (update.changes & WCLayerChange::BackfaceVisibility) >+ update.backfaceVisibility = backfaceVisibility(); >+ if (update.changes & WCLayerChange::MasksToBounds) >+ update.masksToBounds = masksToBounds(); >+ if (update.changes & WCLayerChange::BackingStore) { >+ if (drawsContent() && contentsAreVisible() && !size().isEmpty()) { >+ auto image = m_observer->createImageBuffer(size()); >+ FloatRect clipRect = { { }, size() }; >+ paintGraphicsLayerContents(image->context(), clipRect); >+ image->flushDrawingContextAsync(); >+ update.backingStore.setImageBuffer(WTFMove(image)); >+ >+ incrementRepaintCount(); >+ update.changes.add(WCLayerChange::RepaintCount); >+ } >+ } >+ if (update.changes & WCLayerChange::SolidColor) >+ update.solidColor = m_solidColor; >+ if (update.changes & WCLayerChange::DebugVisuals) { >+ update.showDebugBorder = isShowingDebugBorder(); >+ update.debugBorderColor = m_debugBorderColor; >+ update.debugBorderWidth = m_debugBorderWidth; >+ } >+ if (update.changes & WCLayerChange::RepaintCount) { >+ update.showRepaintCounter = isShowingRepaintCounter(); >+ update.repaintCount = repaintCount(); >+ } >+ if (update.changes & WCLayerChange::Opacity) >+ update.opacity = opacity(); >+ if (update.changes & WCLayerChange::Transform) >+ update.transform = transform(); >+ if (update.changes & WCLayerChange::ChildrenTransform) >+ update.childrenTransform = childrenTransform(); >+ if (update.changes & WCLayerChange::Filters) >+ update.filters = filters(); >+ if (update.changes & WCLayerChange::BackdropFilters) { >+ update.backdropFilters = backdropFilters(); >+ update.backdropFiltersRect = backdropFiltersRect(); >+ } >+ if (update.changes & WCLayerChange::PlatformLayer) { >+ if (m_platformLayer) >+ update.graphicsContextGLIdentifier = static_cast<WCPlatformLayerGCGL*>(m_platformLayer)->graphicsContextGLIdentifier().toUInt64(); >+ else >+ update.graphicsContextGLIdentifier = 0; >+ } >+ m_observer->commitLayerUpateInfo(WTFMove(update)); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h b/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h >new file mode 100644 >index 000000000000..ab5ec4709112 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h >@@ -0,0 +1,107 @@ >+/* >+ * 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. ``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 >+ * 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 >+ >+#include "WCUpateInfo.h" >+#include <wtf/DoublyLinkedList.h> >+ >+namespace WebKit { >+ >+class GraphicsLayerWC final : public WebCore::GraphicsLayer, public DoublyLinkedListNode<GraphicsLayerWC> { >+public: >+ struct Observer { >+ virtual void graphicsLayerAdded(GraphicsLayerWC&) = 0; >+ virtual void graphicsLayerRemoved(GraphicsLayerWC&) = 0; >+ virtual void commitLayerUpateInfo(WCLayerUpateInfo&&) = 0; >+ virtual RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize) = 0; >+ }; >+ >+ GraphicsLayerWC(Type layerType, WebCore::GraphicsLayerClient&, Observer&); >+ ~GraphicsLayerWC() override; >+ >+ void clearObserver() { m_observer = nullptr; } >+ >+ // GraphicsLayer >+ WebCore::GraphicsLayer::PlatformLayerID primaryLayerID() const override; >+ void setNeedsDisplay() override; >+ void setNeedsDisplayInRect(const WebCore::FloatRect&, ShouldClipToLayer) override; >+ void setContentsNeedsDisplay() override; >+ bool setChildren(Vector<Ref<GraphicsLayer>>&&) override; >+ void addChild(Ref<GraphicsLayer>&&) override; >+ void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override; >+ void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override; >+ void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override; >+ bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override; >+ void removeFromParent() override; >+ void setMaskLayer(RefPtr<GraphicsLayer>&&); >+ void setReplicatedLayer(GraphicsLayer*); >+ void setReplicatedByLayer(RefPtr<GraphicsLayer>&&); >+ void setPosition(const WebCore::FloatPoint&) override; >+ void setAnchorPoint(const WebCore::FloatPoint3D&) override; >+ void setSize(const WebCore::FloatSize&) override; >+ void setBoundsOrigin(const WebCore::FloatPoint&) override; >+ void setTransform(const WebCore::TransformationMatrix&) override; >+ void setChildrenTransform(const WebCore::TransformationMatrix&) override; >+ void setPreserves3D(bool) override; >+ void setMasksToBounds(bool) override; >+ void setOpacity(float) override; >+ void setContentsRect(const WebCore::FloatRect&) override; >+ void setContentsClippingRect(const WebCore::FloatRoundedRect&) override; >+ void setDrawsContent(bool) override; >+ void setContentsVisible(bool) override; >+ void setBackfaceVisibility(bool) override; >+ void setContentsToSolidColor(const WebCore::Color&) override; >+ void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override; >+ bool shouldDirectlyCompositeImage(WebCore::Image*) const override { return false; } >+ bool usesContentsLayer() const override; >+ void setShowDebugBorder(bool) override; >+ void setDebugBorder(const WebCore::Color&, float width) override; >+ void setShowRepaintCounter(bool) override; >+ bool setFilters(const WebCore::FilterOperations&) override; >+ bool setBackdropFilters(const WebCore::FilterOperations&) override; >+ void setBackdropFiltersRect(const WebCore::FloatRoundedRect&) override; >+ void flushCompositingState(const WebCore::FloatRect& clipRect) override; >+ void flushCompositingStateForThisLayerOnly() override; >+ >+private: >+ void noteLayerPropertyChanged(OptionSet<WCLayerChange>); >+ >+ static GraphicsLayer::PlatformLayerID generateLayerID(); >+ >+ friend class WTF::DoublyLinkedListNode<GraphicsLayerWC>; >+ >+ GraphicsLayerWC* m_prev; >+ GraphicsLayerWC* m_next; >+ WebCore::GraphicsLayer::PlatformLayerID m_layerID { generateLayerID() }; >+ Observer* m_observer; >+ PlatformLayer* m_platformLayer { nullptr }; >+ WebCore::Color m_solidColor; >+ WebCore::Color m_debugBorderColor; >+ OptionSet<WCLayerChange> m_uncommittedChanges; >+ float m_debugBorderWidth { 0 }; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/WCBackingStore.h b/Source/WebKit/WebProcess/WebPage/wc/WCBackingStore.h >new file mode 100644 >index 000000000000..34f5002f54a4 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/WCBackingStore.h >@@ -0,0 +1,72 @@ >+/* >+ * 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 >+ >+#include "ImageBufferBackendHandle.h" >+#include "PlatformRemoteImageBufferProxy.h" >+ >+namespace WebKit { >+ >+class WCBackingStore { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ WCBackingStore() { } >+ WebCore::ImageBuffer* imageBuffer() { return m_imageBuffer.get(); } >+ void setImageBuffer(RefPtr<WebCore::ImageBuffer>&& image) { m_imageBuffer = WTFMove(image); } >+ ShareableBitmap* bitmap() const { return m_bitmap.get(); } >+ >+ template<class Encoder> >+ void encode(Encoder& encoder) const >+ { >+ bool hasImageBuffer = m_imageBuffer; >+ encoder << hasImageBuffer; >+ if (hasImageBuffer) { >+ auto handle = static_cast<UnacceleratedImageBufferShareableBackend&>(*m_imageBuffer->ensureBackendCreated()).createImageBufferBackendHandle(); >+ encoder << handle; >+ } >+ } >+ >+ template <class Decoder> >+ static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCBackingStore& result) >+ { >+ bool hasImageBuffer; >+ if (!decoder.decode(hasImageBuffer)) >+ return false; >+ if (hasImageBuffer) { >+ ImageBufferBackendHandle handle; >+ if (!decoder.decode(handle)) >+ return false; >+ result.m_bitmap = ShareableBitmap::create(std::get<ShareableBitmap::Handle>(handle)); >+ } >+ return true; >+ } >+ >+private: >+ RefPtr<WebCore::ImageBuffer> m_imageBuffer; >+ RefPtr<ShareableBitmap> m_bitmap; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.cpp b/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.cpp >new file mode 100644 >index 000000000000..4b56687b2b89 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.cpp >@@ -0,0 +1,44 @@ >+/* >+ * 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 "WCLayerFactory.h" >+ >+#include "GraphicsLayerWC.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+WCLayerFactory::WCLayerFactory(GraphicsLayerWC::Observer& observer) >+ : m_observer(observer) >+{ >+} >+ >+Ref<WebCore::GraphicsLayer> WCLayerFactory::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, WebCore::GraphicsLayerClient& client) >+{ >+ return adoptRef(*new GraphicsLayerWC(layerType, client, m_observer)); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.h b/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.h >new file mode 100644 >index 000000000000..b12d2be511b9 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.h >@@ -0,0 +1,44 @@ >+/* >+ * 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 >+ >+#include "GraphicsLayerWC.h" >+#include <WebCore/GraphicsLayerFactory.h> >+ >+namespace WebKit { >+ >+class WCLayerFactory final : public WebCore::GraphicsLayerFactory { >+public: >+ WCLayerFactory(GraphicsLayerWC::Observer&); >+ >+private: >+ // WebCore::GraphicsLayerFactory >+ Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override; >+ >+ GraphicsLayerWC::Observer& m_observer; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h b/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h >new file mode 100644 >index 000000000000..494c6f058ee0 >--- /dev/null >+++ b/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h >@@ -0,0 +1,303 @@ >+/* >+ * 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 >+ >+#include "WCBackingStore.h" >+#include "WebCoreArgumentCoders.h" >+#include <WebCore/GraphicsLayer.h> >+#include <optional> >+#include <wtf/EnumTraits.h> >+#include <wtf/OptionSet.h> >+ >+namespace WebKit { >+ >+enum class WCLayerChange : uint32_t { >+ Children = 1 << 0, >+ MaskLayer = 1 << 1, >+ ReplicaLayer = 1 << 2, >+ Geometry = 1 << 3, >+ Preserves3D = 1 << 4, >+ ContentsVisible = 1 << 5, >+ BackfaceVisibility = 1 << 6, >+ MasksToBounds = 1 << 7, >+ SolidColor = 1 << 8, >+ DebugVisuals = 1 << 9, >+ RepaintCount = 1 << 10, >+ ContentsRect = 1 << 11, >+ ContentsClippingRect = 1 << 12, >+ Opacity = 1 << 13, >+ BackingStore = 1 << 14, >+ Transform = 1 << 15, >+ ChildrenTransform = 1 << 16, >+ Filters = 1 << 17, >+ BackdropFilters = 1 << 18, >+ PlatformLayer = 1 << 19, >+}; >+ >+struct WCLayerUpateInfo { >+ WebCore::GraphicsLayer::PlatformLayerID id; >+ OptionSet<WCLayerChange> changes; >+ Vector<WebCore::GraphicsLayer::PlatformLayerID> children; >+ std::optional<WebCore::GraphicsLayer::PlatformLayerID> maskLayer; >+ std::optional<WebCore::GraphicsLayer::PlatformLayerID> replicaLayer; >+ WebCore::FloatPoint position; >+ WebCore::FloatPoint3D anchorPoint; >+ WebCore::FloatSize size; >+ WebCore::FloatPoint boundsOrigin; >+ bool masksToBounds; >+ bool showDebugBorder; >+ bool showRepaintCounter; >+ bool contentsVisible; >+ bool backfaceVisibility; >+ bool preserves3D; >+ WebCore::Color solidColor; >+ WebCore::Color debugBorderColor; >+ float opacity; >+ float debugBorderWidth; >+ int repaintCount; >+ WebCore::FloatRect contentsRect; >+ WCBackingStore backingStore; >+ WebCore::TransformationMatrix transform; >+ WebCore::TransformationMatrix childrenTransform; >+ WebCore::FilterOperations filters; >+ WebCore::FilterOperations backdropFilters; >+ WebCore::FloatRoundedRect backdropFiltersRect; >+ WebCore::FloatRoundedRect contentsClippingRect; >+ uint64_t graphicsContextGLIdentifier; >+ >+ template<class Encoder> >+ void encode(Encoder& encoder) const >+ { >+ encoder << id; >+ encoder << changes; >+ if (changes & WCLayerChange::Children) >+ encoder << children; >+ if (changes & WCLayerChange::MaskLayer) >+ encoder << maskLayer; >+ if (changes & WCLayerChange::ReplicaLayer) >+ encoder << replicaLayer; >+ if (changes & WCLayerChange::Geometry) >+ encoder << position << anchorPoint << size << boundsOrigin; >+ if (changes & WCLayerChange::Preserves3D) >+ encoder << preserves3D; >+ if (changes & WCLayerChange::ContentsVisible) >+ encoder << contentsVisible; >+ if (changes & WCLayerChange::BackfaceVisibility) >+ encoder << backfaceVisibility; >+ if (changes & WCLayerChange::MasksToBounds) >+ encoder << masksToBounds; >+ if (changes & WCLayerChange::SolidColor) >+ encoder << solidColor; >+ if (changes & WCLayerChange::DebugVisuals) >+ encoder << showDebugBorder << debugBorderColor << debugBorderWidth; >+ if (changes & WCLayerChange::RepaintCount) >+ encoder << showRepaintCounter << repaintCount; >+ if (changes & WCLayerChange::ContentsRect) >+ encoder << contentsRect; >+ if (changes & WCLayerChange::ContentsClippingRect) >+ encoder << contentsClippingRect; >+ if (changes & WCLayerChange::Opacity) >+ encoder << opacity; >+ if (changes & WCLayerChange::BackingStore) >+ encoder << backingStore; >+ if (changes & WCLayerChange::Transform) >+ encoder << transform; >+ if (changes & WCLayerChange::ChildrenTransform) >+ encoder << childrenTransform; >+ if (changes & WCLayerChange::Filters) >+ encoder << filters; >+ if (changes & WCLayerChange::BackdropFilters) >+ encoder << backdropFilters << backdropFiltersRect; >+ if (changes & WCLayerChange::PlatformLayer) >+ encoder << graphicsContextGLIdentifier; >+ } >+ >+ template <class Decoder> >+ static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCLayerUpateInfo& result) >+ { >+ if (!decoder.decode(result.id)) >+ return false; >+ if (!decoder.decode(result.changes)) >+ return false; >+ if (result.changes & WCLayerChange::Children) { >+ if (!decoder.decode(result.children)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::MaskLayer) { >+ if (!decoder.decode(result.maskLayer)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::ReplicaLayer) { >+ if (!decoder.decode(result.replicaLayer)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::Geometry) { >+ if (!decoder.decode(result.position)) >+ return false; >+ if (!decoder.decode(result.anchorPoint)) >+ return false; >+ if (!decoder.decode(result.size)) >+ return false; >+ if (!decoder.decode(result.boundsOrigin)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::Preserves3D) { >+ if (!decoder.decode(result.preserves3D)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::ContentsVisible) { >+ if (!decoder.decode(result.contentsVisible)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::BackfaceVisibility) { >+ if (!decoder.decode(result.backfaceVisibility)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::MasksToBounds) { >+ if (!decoder.decode(result.masksToBounds)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::SolidColor) { >+ if (!decoder.decode(result.solidColor)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::DebugVisuals) { >+ if (!decoder.decode(result.showDebugBorder)) >+ return false; >+ if (!decoder.decode(result.debugBorderColor)) >+ return false; >+ if (!decoder.decode(result.debugBorderWidth)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::RepaintCount) { >+ if (!decoder.decode(result.showRepaintCounter)) >+ return false; >+ if (!decoder.decode(result.repaintCount)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::ContentsRect) { >+ if (!decoder.decode(result.contentsRect)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::ContentsClippingRect) { >+ if (!decoder.decode(result.contentsClippingRect)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::Opacity) { >+ if (!decoder.decode(result.opacity)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::BackingStore) { >+ if (!decoder.decode(result.backingStore)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::Transform) { >+ if (!decoder.decode(result.transform)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::ChildrenTransform) { >+ if (!decoder.decode(result.childrenTransform)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::Filters) { >+ if (!decoder.decode(result.filters)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::BackdropFilters) { >+ if (!decoder.decode(result.backdropFilters)) >+ return false; >+ if (!decoder.decode(result.backdropFiltersRect)) >+ return false; >+ } >+ if (result.changes & WCLayerChange::PlatformLayer) { >+ if (!decoder.decode(result.graphicsContextGLIdentifier)) >+ return false; >+ } >+ return true; >+ } >+}; >+ >+struct WCUpateInfo { >+ WebCore::GraphicsLayer::PlatformLayerID rootLayer; >+ Vector<WebCore::GraphicsLayer::PlatformLayerID> addedLayers; >+ Vector<WebCore::GraphicsLayer::PlatformLayerID> removedLayers; >+ Vector<WCLayerUpateInfo> changedLayers; >+ >+ template<class Encoder> >+ void encode(Encoder& encoder) const >+ { >+ encoder << rootLayer; >+ encoder << addedLayers; >+ encoder << removedLayers; >+ encoder << changedLayers; >+ } >+ >+ template <class Decoder> >+ static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCUpateInfo& result) >+ { >+ if (!decoder.decode(result.rootLayer)) >+ return false; >+ if (!decoder.decode(result.addedLayers)) >+ return false; >+ if (!decoder.decode(result.removedLayers)) >+ return false; >+ if (!decoder.decode(result.changedLayers)) >+ return false; >+ return true; >+ } >+}; >+ >+} // namespace WebKit >+ >+namespace WTF { >+ >+template<> struct EnumTraits<WebKit::WCLayerChange> { >+ using values = EnumValues< >+ WebKit::WCLayerChange, >+ WebKit::WCLayerChange::Children, >+ WebKit::WCLayerChange::MaskLayer, >+ WebKit::WCLayerChange::ReplicaLayer, >+ WebKit::WCLayerChange::Geometry, >+ WebKit::WCLayerChange::Preserves3D, >+ WebKit::WCLayerChange::ContentsVisible, >+ WebKit::WCLayerChange::BackfaceVisibility, >+ WebKit::WCLayerChange::MasksToBounds, >+ WebKit::WCLayerChange::SolidColor, >+ WebKit::WCLayerChange::DebugVisuals, >+ WebKit::WCLayerChange::RepaintCount, >+ WebKit::WCLayerChange::ContentsRect, >+ WebKit::WCLayerChange::ContentsClippingRect, >+ WebKit::WCLayerChange::Opacity, >+ WebKit::WCLayerChange::BackingStore, >+ WebKit::WCLayerChange::Transform, >+ WebKit::WCLayerChange::ChildrenTransform, >+ WebKit::WCLayerChange::Filters, >+ WebKit::WCLayerChange::BackdropFilters, >+ WebKit::WCLayerChange::PlatformLayer >+ >; >+}; >+ >+} // namespace WebKit >diff --git a/Source/cmake/OptionsWinCairo.cmake b/Source/cmake/OptionsWinCairo.cmake >index eb40b4c66dd8..49a3f41ef664 100644 >--- a/Source/cmake/OptionsWinCairo.cmake >+++ b/Source/cmake/OptionsWinCairo.cmake >@@ -44,6 +44,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_CAIRO ON) > SET_AND_EXPOSE_TO_BUILD(USE_CF ON) > SET_AND_EXPOSE_TO_BUILD(USE_CURL ON) > SET_AND_EXPOSE_TO_BUILD(USE_GRAPHICS_LAYER_TEXTURE_MAPPER ON) >+SET_AND_EXPOSE_TO_BUILD(USE_GRAPHICS_LAYER_WC ON) > SET_AND_EXPOSE_TO_BUILD(USE_EGL ON) > SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES ON) > SET_AND_EXPOSE_TO_BUILD(HAVE_OPENGL_ES_3 ON)
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
Flags:
don.olmstead
:
review+
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 228308
:
434257
|
434501
|
440578
|
441343
|
441642
|
442326
|
442526
|
442568
| 442569