Source/WebCore/PlatformWinCairo.cmake

@@list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES
1212 "${WEBKIT_LIBRARIES_DIR}/include"
1313 "${WEBCORE_DIR}/loader/archive/cf"
1414 "${WEBCORE_DIR}/platform/cf"
 15 "${WEBCORE_DIR}/platform/graphics/wc"
1516)
1617
1718list(APPEND WebCore_SOURCES

@@list(APPEND WebCore_SOURCES
2425
2526 platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp
2627
 28 platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp
 29
2730 platform/graphics/win/FontCustomPlatformDataCairo.cpp
2831 platform/graphics/win/FontPlatformDataCairoWin.cpp
2932 platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp

@@list(APPEND WebCore_SOURCES
4447 platform/win/PEImage.cpp
4548)
4649
 50list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
 51 platform/graphics/wc/WCPlatformLayer.h
 52 platform/graphics/wc/WCPlatformLayerGCGL.h
 53)
 54
4755list(APPEND WebCore_LIBRARIES
4856 comctl32
4957 crypt32

Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.cpp

2929#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
3030#include "NotImplemented.h"
3131
 32#if USE(GRAPHICS_LAYER_WC)
 33#include "TextureMapperPlatformLayer.h" // ~RemoteGraphicsContextGLProxyBase needs it
 34#endif
 35
3236namespace WebCore {
3337
3438RemoteGraphicsContextGLProxyBase::RemoteGraphicsContextGLProxyBase(const GraphicsContextGLAttributes& attrs)

@@void RemoteGraphicsContextGLProxyBase::initialize(const String& availableExtensi
126130 m_requestableExtensions.add(extension);
127131}
128132
129 #if !PLATFORM(COCOA)
 133#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC)
130134void RemoteGraphicsContextGLProxyBase::platformInitialize()
131135{
132136}

Source/WebCore/platform/graphics/RemoteGraphicsContextGLProxyBase.h

@@private:
9999 void platformInitialize();
100100#if PLATFORM(COCOA)
101101 RetainPtr<WebGLLayer> m_webGLLayer;
 102#elif USE(GRAPHICS_LAYER_WC)
 103 PlatformLayerContainer m_platformLayer;
102104#endif
103105
104106 // Guarded by waitUntilInitialized().

Source/WebCore/platform/graphics/wc/RemoteGraphicsContextGLProxyBaseWC.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "RemoteGraphicsContextGLProxyBase.h"
 28
 29#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GRAPHICS_LAYER_WC)
 30
 31#include "WCPlatformLayerGCGL.h"
 32
 33namespace WebCore {
 34
 35void RemoteGraphicsContextGLProxyBase::platformInitialize()
 36{
 37 m_platformLayer = makeUnique<WCPlatformLayerGCGL>();
 38}
 39
 40PlatformLayer* RemoteGraphicsContextGLProxyBase::platformLayer() const
 41{
 42 return m_platformLayer.get();
 43}
 44
 45} // namespace WebCore
 46#endif

Source/WebCore/platform/graphics/wc/WCPlatformLayer.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "TextureMapperPlatformLayer.h"
 29
 30namespace WebCore {
 31
 32class WCPlatformLayer : public TextureMapperPlatformLayer {
 33 WTF_MAKE_FAST_ALLOCATED;
 34
 35private:
 36 // TextureMapperPlatformLayer
 37 void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix&, float) final { }
 38};
 39
 40} // namespace WebKit

Source/WebCore/platform/graphics/wc/WCPlatformLayerGCGL.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "WCPlatformLayer.h"
 29
 30namespace WebCore {
 31
 32class WCPlatformLayerGCGL : public WCPlatformLayer {
 33public:
 34 uint64_t graphicsContextGLIdentifier() { return m_graphicsContextGLIdentifier; }
 35 void setGraphicsContextGLIdentifier(uint64_t id) { m_graphicsContextGLIdentifier = id; }
 36
 37private:
 38 uint64_t m_graphicsContextGLIdentifier;
 39};
 40
 41} // namespace WebKit

Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp

@@static void fillWithClearColor(HBITMAP bitmap)
5353
5454HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend)
5555{
 56 if (!hasPlatformContext())
 57 return 0;
5658 HDC hdc = nullptr;
5759#if !USE(CAIRO)
5860 hdc = deprecatedPrivateContext()->m_hdc;

Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp

@@void MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame(Web
28522852 ASSERT(cairoFormat != CAIRO_FORMAT_INVALID);
28532853
28542854 cairo_surface_t* image = nullptr;
2855  if (cairoFormat != CAIRO_FORMAT_INVALID)
2856  image = cairo_image_surface_create_for_data(static_cast<unsigned char*>(data), cairoFormat, width, height, pitch);
2857 
2858  FloatRect srcRect(0, 0, width, height);
2859  if (image) {
2860  ASSERT(context.hasPlatformContext());
2861  auto& state = context.state();
2862  Cairo::drawSurface(*context.platformContext(), image, destRect, srcRect, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state));
2863  cairo_surface_destroy(image);
 2855 if (cairoFormat != CAIRO_FORMAT_INVALID) {
 2856 auto surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data), cairoFormat, width, height, pitch));
 2857 auto image = NativeImage::create(WTFMove(surface));
 2858 FloatRect srcRect(0, 0, width, height);
 2859 context.drawNativeImage(*image, srcRect.size(), destRect, srcRect);
28642860 }
28652861#else
28662862#error "Platform needs to implement drawing of Direct3D surface to graphics context!"

Source/WebCore/rendering/RenderLayer.cpp

@@Ref<ClipRects> RenderLayer::updateClipRects(const ClipRectsContext& clipRectsCon
44154415 ASSERT(clipRectsType < NumCachedClipRectsTypes);
44164416 if (m_clipRectsCache) {
44174417 if (auto* clipRects = m_clipRectsCache->getClipRects(clipRectsType, clipRectsContext.respectOverflowClip)) {
4418  ASSERT(clipRectsContext.rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]);
 4418 //ASSERT(clipRectsContext.rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]);
44194419 ASSERT(m_clipRectsCache->m_scrollbarRelevancy[clipRectsType] == clipRectsContext.overlayScrollbarSizeRelevancy);
44204420
44214421#ifdef CHECK_CACHED_CLIP_RECTS

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp

143143#include <WebCore/SecurityOrigin.h>
144144#endif
145145
 146#if USE(GRAPHICS_LAYER_WC)
 147#include "RemoteWCLayerTreeHost.h"
 148#endif
 149
146150namespace WebKit {
147151using namespace WebCore;
148152

@@void GPUConnectionToWebProcess::configureLoggingChannel(const String& channelNam
323327#endif
324328}
325329
 330#if USE(GRAPHICS_LAYER_WC)
 331void GPUConnectionToWebProcess::createWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow)
 332{
 333 auto addResult = m_remoteWCLayerTreeHostMap.ensure(identifier, [&]() {
 334 return RemoteWCLayerTreeHost::create(*this, WTFMove(identifier), nativeWindow);
 335 });
 336 ASSERT_UNUSED(addResult, addResult.isNewEntry);
 337}
 338
 339void GPUConnectionToWebProcess::releaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier)
 340{
 341 m_remoteWCLayerTreeHostMap.remove(identifier);
 342}
 343
 344RefPtr<RemoteGraphicsContextGL> GPUConnectionToWebProcess::findRemoteGraphicsContextGL(GraphicsContextGLIdentifier identifier)
 345{
 346 ASSERT(RunLoop::isMain());
 347 auto iter = m_remoteGraphicsContextGLMap.find(identifier);
 348 if (iter == m_remoteGraphicsContextGLMap.end())
 349 return nullptr;
 350 return iter->value.get();
 351}
 352#endif
 353
326354bool GPUConnectionToWebProcess::allowsExitUnderMemoryPressure() const
327355{
328356 for (auto& remoteRenderingBackend : m_remoteRenderingBackendMap.values()) {

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h

5353#include <CoreGraphics/CGDisplayConfiguration.h>
5454#endif
5555
 56#if USE(GRAPHICS_LAYER_WC)
 57#include "WCLayerTreeHostIdentifier.h"
 58#endif
 59
5660namespace WebCore {
5761class SecurityOrigin;
5862struct SecurityOriginData;

@@struct MediaOverridesForTesting;
8791struct RemoteAudioSessionConfiguration;
8892struct RemoteRenderingBackendCreationParameters;
8993
 94#if USE(GRAPHICS_LAYER_WC)
 95class RemoteWCLayerTreeHost;
 96#endif
 97
9098class GPUConnectionToWebProcess
9199 : public ThreadSafeRefCounted<GPUConnectionToWebProcess, WTF::DestructionThread::Main>
92100 , public WebCore::NowPlayingManager::Client

@@public:
152160 RemoteImageDecoderAVFProxy& imageDecoderAVFProxy();
153161#endif
154162
 163#if USE(GRAPHICS_LAYER_WC)
 164 RefPtr<RemoteGraphicsContextGL> findRemoteGraphicsContextGL(GraphicsContextGLIdentifier);
 165#endif
 166
155167 void updateSupportedRemoteCommands();
156168
157169 bool allowsExitUnderMemoryPressure() const;

@@private:
217229 void setUserPreferredLanguages(const Vector<String>&);
218230 void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel);
219231
 232#if USE(GRAPHICS_LAYER_WC)
 233 void createWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow);
 234 void releaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier);
 235#endif
 236
220237 // IPC::Connection::Client
221238 void didClose(IPC::Connection&) final;
222239 void didReceiveInvalidMessage(IPC::Connection&, IPC::MessageName) final;

@@private:
296313 using RemoteAudioHardwareListenerMap = HashMap<RemoteAudioHardwareListenerIdentifier, std::unique_ptr<RemoteAudioHardwareListenerProxy>>;
297314 RemoteAudioHardwareListenerMap m_remoteAudioHardwareListenerMap;
298315
 316#if USE(GRAPHICS_LAYER_WC)
 317 using RemoteWCLayerTreeHostMap = HashMap<WCLayerTreeHostIdentifier, std::unique_ptr<RemoteWCLayerTreeHost>>;
 318 RemoteWCLayerTreeHostMap m_remoteWCLayerTreeHostMap;
 319#endif
 320
299321 RefPtr<RemoteRemoteCommandListenerProxy> m_remoteRemoteCommandListener;
300322 bool m_isActiveNowPlayingProcess { false };
301323

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in

@@messages -> GPUConnectionToWebProcess WantsDispatchMessage {
5151 ReleaseRemoteCommandListener(WebKit::RemoteRemoteCommandListenerIdentifier identifier)
5252 SetUserPreferredLanguages(Vector<String> languages)
5353 ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level)
 54#if USE(GRAPHICS_LAYER_WC)
 55 CreateWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow)
 56 ReleaseWCLayerTreeHost(WebKit::WCLayerTreeHostIdentifier identifier)
 57#endif
5458}
5559
5660#endif // ENABLE(GPU_PROCESS)

Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h

@@public:
7272 void displayWasReconfigured();
7373#endif
7474
 75#if USE(GRAPHICS_LAYER_WC)
 76 RefPtr<WebCore::GraphicsContextGLOpenGL> context() const { return m_context; }
 77#endif
 78
7579protected:
7680 RemoteGraphicsContextGL(GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&);
7781 void initialize(WebCore::GraphicsContextGLAttributes&&);

Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp

@@static bool didScheduleFreeWebGLRenderingResources;
4242
4343void ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources()
4444{
 45#if !USE(GRAPHICS_LAYER_WC)
4546 if (didScheduleFreeWebGLRenderingResources)
4647 return;
4748 RunLoop::main().dispatchAfter(freeWebGLRenderingResourcesTimeout, freeWebGLRenderingResources);
4849 didScheduleFreeWebGLRenderingResources = true;
 50#endif
4951}
5052
5153void ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources()

Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "RemoteWCLayerTreeHost.h"
 28
 29#if USE(GRAPHICS_LAYER_WC)
 30
 31#include "GPUConnectionToWebProcess.h"
 32#include "RemoteGraphicsContextGL.h"
 33#include "RemoteWCLayerTreeHostMessages.h"
 34#include "RemoteWCLayerTreeHostProxyMessages.h"
 35#include "StreamConnectionWorkQueue.h"
 36#include "WCScene.h"
 37#include "WCUpateInfo.h"
 38
 39namespace WebKit {
 40using namespace WebCore;
 41
 42IPC::StreamConnectionWorkQueue& remoteGraphicsContextGLStreamWorkQueue();
 43
 44std::unique_ptr<RemoteWCLayerTreeHost> RemoteWCLayerTreeHost::create(GPUConnectionToWebProcess& connectionToWebProcess, WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow)
 45{
 46 return makeUnique<RemoteWCLayerTreeHost>(connectionToWebProcess, identifier, nativeWindow);
 47}
 48
 49RemoteWCLayerTreeHost::RemoteWCLayerTreeHost(GPUConnectionToWebProcess& connectionToWebProcess, WebKit::WCLayerTreeHostIdentifier identifier, uint64_t nativeWindow)
 50 : m_connectionToWebProcess(connectionToWebProcess)
 51 , m_identifier(identifier)
 52{
 53 m_connectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteWCLayerTreeHost::messageReceiverName(), m_identifier.toUInt64(), *this);
 54 m_scene = makeUnique<WCScene>();
 55 remoteGraphicsContextGLStreamWorkQueue().dispatch([scene = m_scene.get(), nativeWindow] {
 56 scene->initialize(nativeWindow);
 57 });
 58}
 59
 60RemoteWCLayerTreeHost::~RemoteWCLayerTreeHost()
 61{
 62 ASSERT(m_connectionToWebProcess);
 63 m_connectionToWebProcess->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHost::messageReceiverName(), m_identifier.toUInt64());
 64 remoteGraphicsContextGLStreamWorkQueue().dispatch([scene = WTFMove(m_scene)] {
 65 // Destroy scene on the StreamWorkQueue thread
 66 });
 67}
 68
 69IPC::Connection* RemoteWCLayerTreeHost::messageSenderConnection() const
 70{
 71 return &m_connectionToWebProcess->connection();
 72}
 73
 74uint64_t RemoteWCLayerTreeHost::messageSenderDestinationID() const
 75{
 76 return m_identifier.toUInt64();
 77}
 78
 79void RemoteWCLayerTreeHost::update(WCUpateInfo&& update)
 80{
 81 auto remoteGCGL = WTF::map(update.changedLayers, [this](auto& layerUpdate) -> RefPtr<RemoteGraphicsContextGL> {
 82 if (layerUpdate.changes & WCLayerChange::PlatformLayer) {
 83 if (layerUpdate.graphicsContextGLIdentifier)
 84 return m_connectionToWebProcess->findRemoteGraphicsContextGL(makeObjectIdentifier<GraphicsContextGLIdentifierType>(layerUpdate.graphicsContextGLIdentifier));
 85 }
 86 return nullptr;
 87 });
 88
 89 remoteGraphicsContextGLStreamWorkQueue().dispatch([this, weakThis = WeakPtr(*this), scene = m_scene.get(), update = WTFMove(update), remoteGCGL = WTFMove(remoteGCGL)]() mutable {
 90 scene->update(WTFMove(update), WTFMove(remoteGCGL));
 91 RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis)] {
 92 if (!weakThis)
 93 return;
 94 send(Messages::RemoteWCLayerTreeHostProxy::DidUpdate());
 95 });
 96 });
 97}
 98
 99} // namespace WebKit
 100
 101#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if USE(GRAPHICS_LAYER_WC)
 29
 30#include "Connection.h"
 31#include "MessageReceiver.h"
 32#include "MessageSender.h"
 33#include "WCLayerTreeHostIdentifier.h"
 34
 35namespace WebCore {
 36class GLContext;
 37class TextureMapper;
 38class TextureMapperLayer;
 39class TextureMapperTiledBackingStore;
 40}
 41
 42namespace WebKit {
 43class GPUConnectionToWebProcess;
 44class WCScene;
 45struct WCUpateInfo;
 46
 47class RemoteWCLayerTreeHost : public IPC::MessageReceiver, private IPC::MessageSender {
 48 WTF_MAKE_FAST_ALLOCATED;
 49 WTF_MAKE_NONCOPYABLE(RemoteWCLayerTreeHost);
 50public:
 51 static std::unique_ptr<RemoteWCLayerTreeHost> create(GPUConnectionToWebProcess&, WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow);
 52 RemoteWCLayerTreeHost(GPUConnectionToWebProcess&, WebKit::WCLayerTreeHostIdentifier, uint64_t nativeWindow);
 53 ~RemoteWCLayerTreeHost();
 54 // message handlers
 55 void update(WCUpateInfo&&);
 56
 57private:
 58 // IPC::MessageReceiver
 59 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 60 // IPC::MessageSender
 61 IPC::Connection* messageSenderConnection() const override;
 62 uint64_t messageSenderDestinationID() const override;
 63
 64 WeakPtr<GPUConnectionToWebProcess> m_connectionToWebProcess;
 65 WCLayerTreeHostIdentifier m_identifier;
 66 std::unique_ptr<WCScene> m_scene;
 67};
 68
 69} // namespace WebKit
 70
 71#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/GPUProcess/graphics/wc/RemoteWCLayerTreeHost.messages.in

 1# Copyright (C) 2021 Sony Interactive Entertainment Inc.
 2#
 3# Redistribution and use in source and binary forms, with or without
 4# modification, are permitted provided that the following conditions
 5# are met:
 6# 1. Redistributions of source code must retain the above copyright
 7# notice, this list of conditions and the following disclaimer.
 8# 2. Redistributions in binary form must reproduce the above copyright
 9# notice, this list of conditions and the following disclaimer in the
 10# documentation and/or other materials provided with the distribution.
 11#
 12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 13# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 14# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 15# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
 16# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 17# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 18# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 19# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 20# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 21# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 22
 23#if USE(GRAPHICS_LAYER_WC)
 24
 25messages -> RemoteWCLayerTreeHost NotRefCounted {
 26 Update(struct WebKit::WCUpateInfo updateInfo)
 27}
 28
 29#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WCScene.h"
 28
 29#if USE(GRAPHICS_LAYER_WC)
 30
 31#include "RemoteGraphicsContextGL.h"
 32#include "WCUpateInfo.h"
 33#include <WebCore/GLContext.h>
 34#include <WebCore/GraphicsContextGLOpenGL.h>
 35#include <WebCore/TextureMapperGL.h>
 36#include <WebCore/TextureMapperLayer.h>
 37#include <WebCore/TextureMapperTiledBackingStore.h>
 38
 39namespace WebKit {
 40using namespace WebCore;
 41
 42struct WCScene::Layer {
 43 WTF_MAKE_FAST_ALLOCATED;
 44 WTF_MAKE_NONCOPYABLE(Layer);
 45public:
 46 Layer() = default;
 47
 48 WebCore::TextureMapperLayer texmapLayer;
 49 RefPtr<TextureMapperTiledBackingStore> backingStore;
 50 std::unique_ptr<TextureMapperLayer> backdropLayer;
 51 RefPtr<RemoteGraphicsContextGL> remoteGraphicsContextGL;
 52 RefPtr<GraphicsContextGLOpenGL> gcglOpenGL;
 53};
 54
 55void WCScene::initialize(uint64_t nativeWindow)
 56{
 57 // The creation of the TextureMapper needs an active OpenGL context.
 58 m_context = GLContext::createContextForWindow(reinterpret_cast<HWND>(nativeWindow));
 59 m_context->makeContextCurrent();
 60 m_textureMapper = TextureMapperGL::create();
 61}
 62
 63WCScene::WCScene() = default;
 64
 65WCScene::~WCScene()
 66{
 67 m_context->makeContextCurrent();
 68 m_textureMapper = nullptr;
 69}
 70
 71void WCScene::update(WCUpateInfo&& update, Vector<RefPtr<RemoteGraphicsContextGL>>&& remoteGCGL)
 72{
 73 if (!m_context->makeContextCurrent())
 74 return;
 75
 76 for (auto id : update.addedLayers) {
 77 auto layer = makeUnique<Layer>();
 78 m_layers.add(id, WTFMove(layer));
 79 }
 80
 81 auto remoteGCGLIterator = remoteGCGL.begin();
 82
 83 for (auto& layerUpdate : update.changedLayers) {
 84 auto layer = m_layers.get(layerUpdate.id);
 85 if (layerUpdate.changes & WCLayerChange::Children) {
 86 layer->texmapLayer.setChildren(WTF::map(layerUpdate.children, [&](auto id) {
 87 return &m_layers.get(id)->texmapLayer;
 88 }));
 89 }
 90 if (layerUpdate.changes & WCLayerChange::MaskLayer) {
 91 TextureMapperLayer* maskLayer = nullptr;
 92 if (layerUpdate.maskLayer)
 93 maskLayer = &m_layers.get(*layerUpdate.maskLayer)->texmapLayer;
 94 layer->texmapLayer.setMaskLayer(maskLayer);
 95 }
 96 if (layerUpdate.changes & WCLayerChange::ReplicaLayer) {
 97 TextureMapperLayer* replicaLayer = nullptr;
 98 if (layerUpdate.replicaLayer)
 99 replicaLayer = &m_layers.get(*layerUpdate.replicaLayer)->texmapLayer;
 100 layer->texmapLayer.setReplicaLayer(replicaLayer);
 101 }
 102 if (layerUpdate.changes & WCLayerChange::Geometry) {
 103 layer->texmapLayer.setPosition(layerUpdate.position);
 104 layer->texmapLayer.setAnchorPoint(layerUpdate.anchorPoint);
 105 layer->texmapLayer.setSize(layerUpdate.size);
 106 layer->texmapLayer.setBoundsOrigin(layerUpdate.boundsOrigin);
 107 }
 108 if (layerUpdate.changes & WCLayerChange::Preserves3D)
 109 layer->texmapLayer.setPreserves3D(layerUpdate.preserves3D);
 110 if (layerUpdate.changes & WCLayerChange::ContentsRect)
 111 layer->texmapLayer.setContentsRect(layerUpdate.contentsRect);
 112 if (layerUpdate.changes & WCLayerChange::ContentsClippingRect)
 113 layer->texmapLayer.setContentsClippingRect(layerUpdate.contentsClippingRect);
 114 if (layerUpdate.changes & WCLayerChange::ContentsVisible)
 115 layer->texmapLayer.setContentsVisible(layerUpdate.contentsVisible);
 116 if (layerUpdate.changes & WCLayerChange::BackfaceVisibility)
 117 layer->texmapLayer.setBackfaceVisibility(layerUpdate.backfaceVisibility);
 118 if (layerUpdate.changes & WCLayerChange::MasksToBounds)
 119 layer->texmapLayer.setMasksToBounds(layerUpdate.masksToBounds);
 120 if (layerUpdate.changes & WCLayerChange::BackingStore) {
 121 auto bitmap = layerUpdate.backingStore.bitmap();
 122 if (bitmap) {
 123 layer->backingStore = TextureMapperTiledBackingStore::create();
 124 auto image = bitmap->createImage();
 125 layer->backingStore->updateContents(*m_textureMapper, image.get(), bitmap->size(), { { }, bitmap->size() });
 126 layer->texmapLayer.setBackingStore(layer->backingStore.get());
 127 } else {
 128 layer->texmapLayer.setBackingStore(nullptr);
 129 layer->backingStore = nullptr;
 130 }
 131 }
 132 if (layerUpdate.changes & WCLayerChange::SolidColor)
 133 layer->texmapLayer.setSolidColor(layerUpdate.solidColor);
 134 if (layerUpdate.changes & WCLayerChange::DebugVisuals)
 135 layer->texmapLayer.setDebugVisuals(layerUpdate.showDebugBorder, layerUpdate.debugBorderColor, layerUpdate.debugBorderWidth);
 136 if (layerUpdate.changes & WCLayerChange::RepaintCount)
 137 layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount);
 138 if (layerUpdate.changes & WCLayerChange::Opacity)
 139 layer->texmapLayer.setOpacity(layerUpdate.opacity);
 140 if (layerUpdate.changes & WCLayerChange::Transform)
 141 layer->texmapLayer.setTransform(layerUpdate.transform);
 142 if (layerUpdate.changes & WCLayerChange::ChildrenTransform)
 143 layer->texmapLayer.setChildrenTransform(layerUpdate.childrenTransform);
 144 if (layerUpdate.changes & WCLayerChange::Filters)
 145 layer->texmapLayer.setFilters(layerUpdate.filters);
 146 if (layerUpdate.changes & WCLayerChange::BackdropFilters) {
 147 if (layerUpdate.backdropFilters.isEmpty())
 148 layer->backdropLayer.reset();
 149 else {
 150 if (!layer->backdropLayer) {
 151 layer->backdropLayer = makeUnique<TextureMapperLayer>();
 152 layer->backdropLayer->setAnchorPoint(FloatPoint3D());
 153 layer->backdropLayer->setContentsVisible(true);
 154 layer->backdropLayer->setMasksToBounds(true);
 155 }
 156 layer->backdropLayer->setFilters(layerUpdate.backdropFilters);
 157 layer->backdropLayer->setSize(layerUpdate.backdropFiltersRect.rect().size());
 158 layer->backdropLayer->setPosition(layerUpdate.backdropFiltersRect.rect().location());
 159 }
 160 layer->texmapLayer.setBackdropLayer(layer->backdropLayer.get());
 161 layer->texmapLayer.setBackdropFiltersRect(layerUpdate.backdropFiltersRect);
 162 }
 163 if (layerUpdate.changes & WCLayerChange::PlatformLayer) {
 164 if (*remoteGCGLIterator) {
 165 layer->remoteGraphicsContextGL = *remoteGCGLIterator;
 166 layer->gcglOpenGL = layer->remoteGraphicsContextGL->context();
 167 layer->texmapLayer.setContentsLayer(layer->gcglOpenGL->platformLayer());
 168 } else {
 169 layer->remoteGraphicsContextGL = nullptr;
 170 layer->gcglOpenGL = nullptr;
 171 layer->texmapLayer.setContentsLayer(nullptr);
 172 }
 173 }
 174 remoteGCGLIterator++;
 175 }
 176 ASSERT(remoteGCGLIterator == remoteGCGL.end());
 177
 178 for (auto id : update.removedLayers)
 179 m_layers.remove(id);
 180
 181 auto rootLayer = &m_layers.get(update.rootLayer)->texmapLayer;
 182 rootLayer->applyAnimationsRecursively(MonotonicTime::now());
 183
 184 IntSize windowSize = expandedIntSize(rootLayer->size());
 185 glViewport(0, 0, windowSize.width(), windowSize.height());
 186
 187 m_textureMapper->beginPainting();
 188 rootLayer->paint(*m_textureMapper);
 189 m_fpsCounter.updateFPSAndDisplay(*m_textureMapper);
 190 m_textureMapper->endPainting();
 191
 192 m_context->swapBuffers();
 193}
 194
 195} // namespace WebKit
 196
 197#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/GPUProcess/graphics/wc/WCScene.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if USE(GRAPHICS_LAYER_WC)
 29
 30#include <WebCore/TextureMapperFPSCounter.h>
 31#include <wtf/HashMap.h>
 32#include <wtf/RefPtr.h>
 33#include <wtf/Vector.h>
 34
 35namespace WebCore {
 36class GLContext;
 37class TextureMapper;
 38class TextureMapperLayer;
 39class TextureMapperTiledBackingStore;
 40}
 41
 42namespace WebKit {
 43
 44class RemoteGraphicsContextGL;
 45struct WCUpateInfo;
 46
 47class WCScene {
 48 WTF_MAKE_FAST_ALLOCATED;
 49 WTF_MAKE_NONCOPYABLE(WCScene);
 50public:
 51 WCScene();
 52 ~WCScene();
 53 void initialize(uint64_t nativeWindow);
 54 void update(WCUpateInfo&&, Vector<RefPtr<RemoteGraphicsContextGL>>&&);
 55
 56private:
 57 struct Layer;
 58 typedef HashMap<uint64_t, std::unique_ptr<Layer>> LayerMap;
 59
 60 std::unique_ptr<WebCore::GLContext> m_context;
 61 std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
 62 WebCore::TextureMapperFPSCounter m_fpsCounter;
 63 LayerMap m_layers;
 64};
 65
 66} // namespace WebKit
 67
 68#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/GPUProcess/win/GPUProcessMainWin.cpp

3030
3131#include "AuxiliaryProcessMain.h"
3232#include "GPUProcess.h"
 33#include <Objbase.h>
 34#include <wtf/win/SoftLinking.h>
 35
 36SOFT_LINK_LIBRARY(user32);
 37SOFT_LINK_OPTIONAL(user32, SetProcessDpiAwarenessContext, BOOL, STDAPICALLTYPE, (DPI_AWARENESS_CONTEXT));
3338
3439namespace WebKit {
3540
3641class GPUProcessMainWin final: public AuxiliaryProcessMainBaseNoSingleton<GPUProcess> {
 42public:
 43 bool platformInitialize() override
 44 {
 45 if (SetProcessDpiAwarenessContextPtr())
 46 SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
 47 else
 48 SetProcessDPIAware();
 49 return true;
 50 }
3751};
3852
3953int GPUProcessMain(int argc, char** argv)
4054{
 55 // for DirectX
 56 HRESULT hr = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
 57 RELEASE_ASSERT(SUCCEEDED(hr));
4158 return AuxiliaryProcessMain<GPUProcessMainWin>(argc, argv);
4259}
4360

Source/WebKit/PlatformWin.cmake

@@add_definitions(-DBUILDING_WEBKIT)
1111list(APPEND WebKit_SOURCES
1212 GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp
1313
 14 GPUProcess/graphics/wc/RemoteWCLayerTreeHost.cpp
 15 GPUProcess/graphics/wc/WCScene.cpp
 16
1417 GPUProcess/media/win/RemoteMediaPlayerProxyWin.cpp
1518
1619 GPUProcess/win/GPUProcessMainWin.cpp

@@list(APPEND WebKit_SOURCES
6972
7073 UIProcess/WebsiteData/win/WebsiteDataStoreWin.cpp
7174
 75 UIProcess/wc/DrawingAreaProxyWC.cpp
 76
7277 UIProcess/win/PageClientImpl.cpp
7378 UIProcess/win/WebContextMenuProxyWin.cpp
7479 UIProcess/win/WebPageProxyWin.cpp

@@list(APPEND WebKit_SOURCES
7681 UIProcess/win/WebProcessPoolWin.cpp
7782 UIProcess/win/WebView.cpp
7883
 84 WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp
 85
7986 WebProcess/GPU/media/win/VideoLayerRemoteWin.cpp
8087
8188 WebProcess/InjectedBundle/win/InjectedBundleWin.cpp

@@list(APPEND WebKit_SOURCES
95102 WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
96103 WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp
97104
 105 WebProcess/WebPage/wc/DrawingAreaWC.cpp
 106 WebProcess/WebPage/wc/GraphicsLayerWC.cpp
 107 WebProcess/WebPage/wc/WCLayerFactory.cpp
 108
98109 WebProcess/WebPage/win/WebPageWin.cpp
99110
100111 WebProcess/win/WebProcessMainWin.cpp

@@list(APPEND WebKit_SOURCES
102113)
103114
104115list(APPEND WebKit_INCLUDE_DIRECTORIES
 116 "${WEBKIT_DIR}/GPUProcess/graphics/wc"
105117 "${WEBKIT_DIR}/Platform/classifier"
106118 "${WEBKIT_DIR}/Platform/generic"
107119 "${WEBKIT_DIR}/PluginProcess/win"

@@list(APPEND WebKit_INCLUDE_DIRECTORIES
119131 "${WEBKIT_DIR}/UIProcess/Inspector/socket"
120132 "${WEBKIT_DIR}/UIProcess/Inspector/win"
121133 "${WEBKIT_DIR}/UIProcess/Plugins/win"
 134 "${WEBKIT_DIR}/UIProcess/wc"
122135 "${WEBKIT_DIR}/UIProcess/win"
 136 "${WEBKIT_DIR}/WebProcess/GPU/graphics/wc"
123137 "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/win"
124138 "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/win/DOM"
125139 "${WEBKIT_DIR}/WebProcess/Inspector/win"
126140 "${WEBKIT_DIR}/WebProcess/WebCoreSupport/win"
127141 "${WEBKIT_DIR}/WebProcess/WebPage/CoordinatedGraphics"
 142 "${WEBKIT_DIR}/WebProcess/WebPage/wc"
128143 "${WEBKIT_DIR}/WebProcess/WebPage/win"
129144 "${WEBKIT_DIR}/win"
130145)
131146
 147list(APPEND WebKit_MESSAGES_IN_FILES
 148 GPUProcess/graphics/wc/RemoteWCLayerTreeHost
 149
 150 WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy
 151)
 152
132153set(WebKitCommonIncludeDirectories ${WebKit_INCLUDE_DIRECTORIES})
133154set(WebKitCommonSystemIncludeDirectories ${WebKit_SYSTEM_INCLUDE_DIRECTORIES})
134155

Source/WebKit/Scripts/webkit/messages.py

@@def types_that_cannot_be_forward_declared():
357357 'WebKit::TrackPrivateRemoteIdentifier',
358358 'WebKit::TransactionID',
359359 'WebKit::UserContentControllerIdentifier',
 360 'WebKit::WCLayerTreeHostIdentifier',
360361 'WebKit::WebPageProxyIdentifier',
361362 'WebKit::WebURLSchemeHandlerIdentifier',
362363 'WebKit::XRDeviceIdentifier',

Source/WebKit/Shared/DrawingAreaInfo.h

@@enum class DrawingAreaType : uint8_t {
3737#endif
3838 RemoteLayerTree,
3939#elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
40  CoordinatedGraphics
 40 CoordinatedGraphics,
 41#endif
 42#if USE(GRAPHICS_LAYER_WC)
 43 WC,
4144#endif
4245};
4346

@@template<> struct EnumTraits<WebKit::DrawingAreaType> {
6366 , WebKit::DrawingAreaType::RemoteLayerTree
6467#elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
6568 , WebKit::DrawingAreaType::CoordinatedGraphics
 69#endif
 70#if USE(GRAPHICS_LAYER_WC)
 71 , WebKit::DrawingAreaType::WC
6672#endif
6773 >;
6874};

Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.cpp

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
 4 * Copyright (C) 2016-2019 Igalia S.L.
 5 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 6 *
 7 * Redistribution and use in source and binary forms, with or without
 8 * modification, are permitted provided that the following conditions
 9 * are met:
 10 * 1. Redistributions of source code must retain the above copyright
 11 * notice, this list of conditions and the following disclaimer.
 12 * 2. Redistributions in binary form must reproduce the above copyright
 13 * notice, this list of conditions and the following disclaimer in the
 14 * documentation and/or other materials provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 26 * THE POSSIBILITY OF SUCH DAMAGE.
 27 */
 28
 29#include "config.h"
 30#include "DrawingAreaProxyWC.h"
 31
 32#include "DrawingAreaMessages.h"
 33#include "UpdateInfo.h"
 34#include "WebCoreArgumentCoders.h"
 35#include "WebPageProxy.h"
 36#include <WebCore/Region.h>
 37
 38namespace WebKit {
 39using namespace WebCore;
 40
 41DrawingAreaProxyWC::DrawingAreaProxyWC(WebPageProxy& webPageProxy, WebProcessProxy& process)
 42 : DrawingAreaProxy(DrawingAreaType::WC, webPageProxy, process)
 43{
 44}
 45
 46void DrawingAreaProxyWC::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion)
 47{
 48 unpaintedRegion = rect;
 49
 50 if (!m_backingStore)
 51 return;
 52 m_backingStore->paint(context, rect);
 53 unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));
 54}
 55
 56void DrawingAreaProxyWC::sizeDidChange()
 57{
 58 discardBackingStore();
 59 m_currentBackingStoreStateID++;
 60 send(Messages::DrawingArea::UpdateGeometry(m_currentBackingStoreStateID, m_size));
 61}
 62
 63void DrawingAreaProxyWC::update(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
 64{
 65 if (backingStoreStateID == m_currentBackingStoreStateID)
 66 incorporateUpdate(updateInfo);
 67 send(Messages::DrawingArea::DidUpdate());
 68}
 69
 70void DrawingAreaProxyWC::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&)
 71{
 72 discardBackingStore();
 73}
 74
 75void DrawingAreaProxyWC::incorporateUpdate(const UpdateInfo& updateInfo)
 76{
 77 if (updateInfo.updateRectBounds.isEmpty())
 78 return;
 79
 80 if (!m_backingStore)
 81 m_backingStore.emplace(updateInfo.viewSize, updateInfo.deviceScaleFactor, m_webPageProxy);
 82
 83 m_backingStore->incorporateUpdate(updateInfo);
 84
 85 Region damageRegion;
 86 if (updateInfo.scrollRect.isEmpty()) {
 87 for (const auto& rect : updateInfo.updateRects)
 88 damageRegion.unite(rect);
 89 } else
 90 damageRegion = IntRect(IntPoint(), m_webPageProxy.viewSize());
 91 m_webPageProxy.setViewNeedsDisplay(damageRegion);
 92}
 93
 94void DrawingAreaProxyWC::discardBackingStore()
 95{
 96 m_backingStore = std::nullopt;
 97}
 98
 99} // namespace WebKit

Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "BackingStore.h"
 29#include "DrawingAreaProxy.h"
 30
 31namespace WebCore {
 32class Region;
 33}
 34
 35namespace WebKit {
 36
 37class DrawingAreaProxyWC final : public DrawingAreaProxy {
 38public:
 39 DrawingAreaProxyWC(WebPageProxy&, WebProcessProxy&);
 40
 41 void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
 42
 43private:
 44 // DrawingAreaProxy
 45 void deviceScaleFactorDidChange() override { }
 46 void sizeDidChange() override;
 47 // message handers
 48 void update(uint64_t, const UpdateInfo&);
 49 void enterAcceleratedCompositingMode(uint64_t, const LayerTreeContext&);
 50
 51 void incorporateUpdate(const UpdateInfo&);
 52 void discardBackingStore();
 53
 54 uint64_t m_currentBackingStoreStateID { 0 };
 55 std::optional<BackingStore> m_backingStore;
 56};
 57
 58} // namespace WebKit

Source/WebKit/UIProcess/win/PageClientImpl.cpp

2828#include "PageClientImpl.h"
2929
3030#include "DrawingAreaProxyCoordinatedGraphics.h"
 31#include "DrawingAreaProxyWC.h"
3132#include "WebContextMenuProxyWin.h"
3233#include "WebPageProxy.h"
3334#include "WebPopupMenuProxyWin.h"

@@PageClientImpl::PageClientImpl(WebView& view)
4748// PageClient's pure virtual functions
4849std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(WebProcessProxy& process)
4950{
 51 if (m_view.page()->preferences().useGPUProcessForWebGLEnabled())
 52 return makeUnique<DrawingAreaProxyWC>(*m_view.page(), process);
5053 return makeUnique<DrawingAreaProxyCoordinatedGraphics>(*m_view.page(), process);
5154}
5255

Source/WebKit/UIProcess/win/WebView.cpp

2929
3030#include "APIPageConfiguration.h"
3131#include "DrawingAreaProxyCoordinatedGraphics.h"
 32#include "DrawingAreaProxyWC.h"
3233#include "Logging.h"
3334#include "NativeWebKeyboardEvent.h"
3435#include "NativeWebMouseEvent.h"

@@void WebView::paint(HDC hdc, const IntRect& dirtyRect)
491492 if (dirtyRect.isEmpty())
492493 return;
493494 m_page->endPrinting();
494  if (auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_page->drawingArea())) {
495  // FIXME: We should port WebKit1's rect coalescing logic here.
496  Region unpaintedRegion;
 495 if (m_page->drawingArea()) {
 496 auto painter = [&](auto drawingArea) {
 497 // FIXME: We should port WebKit1's rect coalescing logic here.
 498 Region unpaintedRegion;
497499#if USE(CAIRO)
498  cairo_surface_t* surface = cairo_win32_surface_create(hdc);
499  cairo_t* context = cairo_create(surface);
500 
501  drawingArea->paint(context, dirtyRect, unpaintedRegion);
502 
503  cairo_destroy(context);
504  cairo_surface_destroy(surface);
505 #else
506  COMPtr<ID3D11Texture2D> backBuffer;
507  HRESULT hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer));
508  if (SUCCEEDED(hr)) {
509  BackingStore::DXConnections context { m_immediateContext.get(), backBuffer.get() };
 500 cairo_surface_t* surface = cairo_win32_surface_create(hdc);
 501 cairo_t* context = cairo_create(surface);
 502
510503 drawingArea->paint(context, dirtyRect, unpaintedRegion);
511  }
512 
513  m_swapChain->Present(0, 0);
 504
 505 cairo_destroy(context);
 506 cairo_surface_destroy(surface);
 507#else
 508 COMPtr<ID3D11Texture2D> backBuffer;
 509 HRESULT hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer));
 510 if (SUCCEEDED(hr)) {
 511 BackingStore::DXConnections context { m_immediateContext.get(), backBuffer.get() };
 512 drawingArea->paint(context, dirtyRect, unpaintedRegion);
 513 }
 514
 515 m_swapChain->Present(0, 0);
514516#endif
515 
516  auto unpaintedRects = unpaintedRegion.rects();
517  for (auto& rect : unpaintedRects)
518  drawPageBackground(hdc, m_page.get(), rect);
 517
 518 auto unpaintedRects = unpaintedRegion.rects();
 519 for (auto& rect : unpaintedRects)
 520 drawPageBackground(hdc, m_page.get(), rect);
 521 };
 522 switch (m_page->drawingArea()->type()) {
 523 case DrawingAreaType::WC:
 524 painter(static_cast<DrawingAreaProxyWC*>(m_page->drawingArea()));
 525 break;
 526 case DrawingAreaType::CoordinatedGraphics:
 527 painter(static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_page->drawingArea()));
 528 break;
 529 default:
 530 ASSERT_NOT_REACHED();
 531 }
519532 } else
520533 drawPageBackground(hdc, m_page.get(), dirtyRect);
521534}

Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp

4040#include <WebCore/GraphicsContextGLIOSurfaceSwapChain.h>
4141#endif
4242
 43#if USE(GRAPHICS_LAYER_WC)
 44#include <WebCore/WCPlatformLayerGCGL.h>
 45#endif
 46
4347namespace WebKit {
4448
4549using namespace WebCore;

@@RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy(GPUProcessConnection&
6266 // TODO: We must wait until initialized, because at the moment we cannot receive IPC messages
6367 // during wait while in synchronous stream send. Should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=217211.
6468 waitUntilInitialized();
 69#if USE(GRAPHICS_LAYER_WC)
 70 static_cast<WCPlatformLayerGCGL*>(platformLayer())->setGraphicsContextGLIdentifier(m_graphicsContextGLIdentifier.toUInt64());
 71#endif
6572}
6673
6774RemoteGraphicsContextGLProxy::~RemoteGraphicsContextGLProxy()

Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "RemoteWCLayerTreeHostProxy.h"
 28
 29#if USE(GRAPHICS_LAYER_WC)
 30
 31#include "GPUConnectionToWebProcess.h"
 32#include "RemoteWCLayerTreeHostMessages.h"
 33#include "RemoteWCLayerTreeHostProxyMessages.h"
 34#include "WCUpateInfo.h"
 35#include "WebPage.h"
 36#include "WebProcess.h"
 37
 38namespace WebKit {
 39
 40RemoteWCLayerTreeHostProxy::RemoteWCLayerTreeHostProxy(WebPage& page, Client& client)
 41 : m_page(page)
 42 , m_client(client)
 43{
 44}
 45
 46RemoteWCLayerTreeHostProxy::~RemoteWCLayerTreeHostProxy()
 47{
 48 disconnectGpuProcessIfNeeded();
 49}
 50
 51IPC::Connection* RemoteWCLayerTreeHostProxy::messageSenderConnection() const
 52{
 53 return &const_cast<RemoteWCLayerTreeHostProxy&>(*this).ensureGPUProcessConnection().connection();
 54}
 55
 56GPUProcessConnection& RemoteWCLayerTreeHostProxy::ensureGPUProcessConnection()
 57{
 58 if (!m_gpuProcessConnection) {
 59 auto& gpuProcessConnection = WebProcess::singleton().ensureGPUProcessConnection();
 60 gpuProcessConnection.addClient(*this);
 61 gpuProcessConnection.messageReceiverMap().addMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64(), *this);
 62 gpuProcessConnection.connection().send(
 63 Messages::GPUConnectionToWebProcess::CreateWCLayerTreeHost(wcLayerTreeHostIdentifier(), m_page.nativeWindowHandle()),
 64 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
 65 m_gpuProcessConnection = gpuProcessConnection;
 66 }
 67 return *m_gpuProcessConnection;
 68}
 69
 70void RemoteWCLayerTreeHostProxy::disconnectGpuProcessIfNeeded()
 71{
 72 if (auto gpuProcessConnection = std::exchange(m_gpuProcessConnection, nullptr)) {
 73 gpuProcessConnection->removeClient(*this);
 74 gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64());
 75 gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseWCLayerTreeHost(wcLayerTreeHostIdentifier()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
 76 }
 77}
 78
 79void RemoteWCLayerTreeHostProxy::gpuProcessConnectionDidClose(GPUProcessConnection& previousConnection)
 80{
 81 previousConnection.removeClient(*this);
 82 m_gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteWCLayerTreeHostProxy::messageReceiverName(), wcLayerTreeHostIdentifier().toUInt64());
 83 m_gpuProcessConnection = nullptr;
 84}
 85
 86uint64_t RemoteWCLayerTreeHostProxy::messageSenderDestinationID() const
 87{
 88 return wcLayerTreeHostIdentifier().toUInt64();
 89}
 90
 91void RemoteWCLayerTreeHostProxy::update(WCUpateInfo&& updateInfo)
 92{
 93 send(Messages::RemoteWCLayerTreeHost::Update(updateInfo));
 94}
 95
 96void RemoteWCLayerTreeHostProxy::didUpdate()
 97{
 98 m_client.didUpdate();
 99}
 100
 101} // namespace WebKit
 102
 103#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if USE(GRAPHICS_LAYER_WC)
 29
 30#include "GPUProcessConnection.h"
 31#include "MessageReceiver.h"
 32#include "MessageSender.h"
 33#include "WCLayerTreeHostIdentifier.h"
 34
 35namespace WebKit {
 36
 37struct WCUpateInfo;
 38
 39class RemoteWCLayerTreeHostProxy
 40 : private IPC::MessageReceiver
 41 , private IPC::MessageSender
 42 , private GPUProcessConnection::Client {
 43 WTF_MAKE_FAST_ALLOCATED;
 44 WTF_MAKE_NONCOPYABLE(RemoteWCLayerTreeHostProxy);
 45public:
 46 class Client {
 47 public:
 48 virtual void didUpdate() = 0;
 49 };
 50
 51 RemoteWCLayerTreeHostProxy(WebPage&, Client&);
 52 ~RemoteWCLayerTreeHostProxy();
 53
 54 void update(WCUpateInfo&&);
 55
 56 void didUpdate();
 57
 58private:
 59 WCLayerTreeHostIdentifier wcLayerTreeHostIdentifier() const { return m_wcLayerTreeHostIdentifier; };
 60 GPUProcessConnection& ensureGPUProcessConnection();
 61 void disconnectGpuProcessIfNeeded();
 62
 63 // GPUProcessConnection::Client
 64 void gpuProcessConnectionDidClose(GPUProcessConnection&) final;
 65
 66 // IPC::MessageReceiver
 67 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 68
 69 // IPC::MessageSender
 70 IPC::Connection* messageSenderConnection() const override;
 71 uint64_t messageSenderDestinationID() const override;
 72
 73 WeakPtr<GPUProcessConnection> m_gpuProcessConnection;
 74 WCLayerTreeHostIdentifier m_wcLayerTreeHostIdentifier { WCLayerTreeHostIdentifier::generate() };
 75 WebPage& m_page;
 76 Client& m_client;
 77};
 78
 79} // namespace WebKit
 80
 81#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/WebProcess/GPU/graphics/wc/RemoteWCLayerTreeHostProxy.messages.in

 1# Copyright (C) 2021 Sony Interactive Entertainment Inc.
 2#
 3# Redistribution and use in source and binary forms, with or without
 4# modification, are permitted provided that the following conditions
 5# are met:
 6# 1. Redistributions of source code must retain the above copyright
 7# notice, this list of conditions and the following disclaimer.
 8# 2. Redistributions in binary form must reproduce the above copyright
 9# notice, this list of conditions and the following disclaimer in the
 10# documentation and/or other materials provided with the distribution.
 11#
 12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 13# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 14# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 15# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
 16# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 17# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 18# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 19# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 20# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 21# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 22
 23#if USE(GRAPHICS_LAYER_WC)
 24
 25messages -> RemoteWCLayerTreeHostProxy NotRefCounted {
 26 DidUpdate()
 27}
 28
 29#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/WebProcess/GPU/graphics/wc/WCLayerTreeHostIdentifier.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if USE(GRAPHICS_LAYER_WC)
 29
 30#include <wtf/ObjectIdentifier.h>
 31
 32namespace WebKit {
 33
 34enum WCLayerTreeHostIdentifierType { };
 35using WCLayerTreeHostIdentifier = ObjectIdentifier<WCLayerTreeHostIdentifierType>;
 36
 37} // namespace WebKit
 38
 39#endif // USE(GRAPHICS_LAYER_WC)

Source/WebKit/WebProcess/WebPage/DrawingArea.cpp

3939#include "TiledCoreAnimationDrawingArea.h"
4040#elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
4141#include "DrawingAreaCoordinatedGraphics.h"
 42#include "DrawingAreaWC.h"
4243#endif
4344
4445namespace WebKit {

@@std::unique_ptr<DrawingArea> DrawingArea::create(WebPage& webPage, const WebPage
5758#elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
5859 case DrawingAreaType::CoordinatedGraphics:
5960 return makeUnique<DrawingAreaCoordinatedGraphics>(webPage, parameters);
 61#endif
 62#if USE(GRAPHICS_LAYER_WC)
 63 case DrawingAreaType::WC:
 64 return makeUnique<DrawingAreaWC>(webPage, parameters);
6065#endif
6166 }
6267

@@bool DrawingArea::supportsGPUProcessRendering(DrawingAreaType type)
108113#elif USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
109114 case DrawingAreaType::CoordinatedGraphics:
110115 return false;
 116#endif
 117#if USE(GRAPHICS_LAYER_WC)
 118 case DrawingAreaType::WC:
 119 return true;
111120#endif
112121 default:
113122 return false;

Source/WebKit/WebProcess/WebPage/DrawingArea.h

@@public:
136136 virtual void updateGeometry(const WebCore::IntSize& viewSize, bool flushSynchronously, const WTF::MachSendRight& fencePort) { }
137137#endif
138138
 139#if USE(GRAPHICS_LAYER_WC)
 140 virtual void updateGeometry(uint64_t, WebCore::IntSize) { };
 141#endif
 142
139143#if USE(COORDINATED_GRAPHICS) || USE(GRAPHICS_LAYER_TEXTURE_MAPPER)
140144 virtual void layerHostDidFlushLayers() { }
141145#endif

Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in

@@messages -> DrawingArea NotRefCounted {
4040 AddTransactionCallbackID(WebKit::CallbackID callbackID)
4141#endif
4242
 43#if USE(GRAPHICS_LAYER_WC)
 44 UpdateGeometry(uint64_t backingStoreStateID, WebCore::IntSize viewSize)
 45#endif
 46
4347#if PLATFORM(COCOA) || PLATFORM(GTK)
4448 AdjustTransientZoom(double scale, WebCore::FloatPoint origin)
4549 CommitTransientZoom(double scale, WebCore::FloatPoint origin)

Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DrawingAreaWC.h"
 28
 29#include "DrawingAreaProxyMessages.h"
 30#include "GraphicsLayerWC.h"
 31#include "PlatformImageBufferShareableBackend.h"
 32#include "RemoteWCLayerTreeHostProxy.h"
 33#include "UpdateInfo.h"
 34#include "WebPageCreationParameters.h"
 35#include "WebProcess.h"
 36#include <WebCore/ConcreteImageBuffer.h>
 37#include <WebCore/Frame.h>
 38#include <WebCore/FrameView.h>
 39
 40namespace WebKit {
 41using namespace WebCore;
 42
 43DrawingAreaWC::DrawingAreaWC(WebPage& webPage, const WebPageCreationParameters& parameters)
 44 : DrawingArea(DrawingAreaType::WC, parameters.drawingAreaIdentifier, webPage)
 45 , m_rootLayerClient(webPage)
 46 , m_remoteWCLayerTreeHostProxy(makeUnique<RemoteWCLayerTreeHostProxy>(webPage, *this))
 47 , m_layerFactory(*this)
 48 , m_rootLayer(GraphicsLayer::create(graphicsLayerFactory(), this->m_rootLayerClient))
 49 , m_updateRenderingTimer(*this, &DrawingAreaWC::updateRendering)
 50 , m_commitQueue(WorkQueue::create("DrawingAreaWC CommitQueue"_s))
 51{
 52 m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root"));
 53 m_rootLayer->setDrawsContent(true);
 54 m_rootLayer->setContentsOpaque(true);
 55 m_rootLayer->setSize(m_webPage.size());
 56 m_rootLayer->setNeedsDisplay();
 57}
 58
 59DrawingAreaWC::~DrawingAreaWC()
 60{
 61 while (auto layer = m_liveGraphicsLayers.removeHead())
 62 layer->clearObserver();
 63}
 64
 65GraphicsLayerFactory* DrawingAreaWC::graphicsLayerFactory()
 66{
 67 return &m_layerFactory;
 68}
 69
 70void DrawingAreaWC::updateRootLayers()
 71{
 72 Vector<Ref<GraphicsLayer>> children;
 73 if (m_contentLayer) {
 74 children.append(*m_contentLayer);
 75 if (m_viewOverlayRootLayer)
 76 children.append(*m_viewOverlayRootLayer);
 77 }
 78 m_rootLayer->setChildren(WTFMove(children));
 79 triggerRenderingUpdate();
 80}
 81
 82void DrawingAreaWC::setRootCompositingLayer(GraphicsLayer* rootLayer)
 83{
 84 m_contentLayer = rootLayer;
 85 updateRootLayers();
 86}
 87
 88void DrawingAreaWC::attachViewOverlayGraphicsLayer(GraphicsLayer* layer)
 89{
 90 m_viewOverlayRootLayer = layer;
 91 updateRootLayers();
 92}
 93
 94void DrawingAreaWC::setLayerTreeStateIsFrozen(bool isFrozen)
 95{
 96 if (m_isRenderingSuspended == isFrozen)
 97 return;
 98 m_isRenderingSuspended = isFrozen;
 99 if (!m_isRenderingSuspended && m_hasDeferredRenderingUpdate) {
 100 m_hasDeferredRenderingUpdate = false;
 101 triggerRenderingUpdate();
 102 }
 103}
 104
 105void DrawingAreaWC::updateGeometry(uint64_t backingStoreStateID, IntSize viewSize)
 106{
 107 m_backingStoreStateID = backingStoreStateID;
 108 m_webPage.setSize(viewSize);
 109 m_rootLayer->setSize(m_webPage.size());
 110}
 111
 112void DrawingAreaWC::setNeedsDisplay()
 113{
 114 m_dirtyRegion = { };
 115 m_scrollRect = { };
 116 m_scrollOffset = { };
 117 setNeedsDisplayInRect(m_webPage.bounds());
 118}
 119
 120void DrawingAreaWC::setNeedsDisplayInRect(const IntRect& rect)
 121{
 122 if (isCompositingMode())
 123 m_rootLayer->setNeedsDisplayInRect(rect);
 124 else
 125 m_dirtyRegion.unite(rect);
 126 triggerRenderingUpdate();
 127}
 128
 129void DrawingAreaWC::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
 130{
 131 if (isCompositingMode())
 132 m_rootLayer->setNeedsDisplayInRect(scrollRect);
 133 else {
 134 if (scrollRect != m_scrollRect) {
 135 // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
 136 setNeedsDisplayInRect(m_scrollRect);
 137 m_scrollRect = { };
 138 m_scrollOffset = { };
 139 }
 140 // Get the part of the dirty region that is in the scroll rect.
 141 Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
 142 if (!dirtyRegionInScrollRect.isEmpty()) {
 143 // There are parts of the dirty region that are inside the scroll rect.
 144 // We need to subtract them from the region, move them and re-add them.
 145 m_dirtyRegion.subtract(scrollRect);
 146 // Move the dirty parts.
 147 Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
 148 // And add them back.
 149 m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
 150 }
 151 // Compute the scroll repaint region.
 152 Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
 153 m_dirtyRegion.unite(scrollRepaintRegion);
 154 m_scrollRect = scrollRect;
 155 m_scrollOffset += scrollDelta;
 156 triggerRenderingUpdate();
 157 }
 158}
 159
 160void DrawingAreaWC::triggerRenderingUpdate()
 161{
 162 if (m_isRenderingSuspended || m_waitDidUpdate) {
 163 m_hasDeferredRenderingUpdate = true;
 164 return;
 165 }
 166 if (m_updateRenderingTimer.isActive())
 167 return;
 168 m_updateRenderingTimer.startOneShot(0_s);
 169}
 170
 171static void flushLayerImageBuffers(WCUpateInfo& info)
 172{
 173 for (auto& layerInfo : info.changedLayers) {
 174 if (layerInfo.changes & WCLayerChange::BackingStore) {
 175 if (auto image = layerInfo.backingStore.imageBuffer()) {
 176 if (auto flusher = image->createFlusher())
 177 flusher->flush();
 178 }
 179 }
 180 }
 181}
 182
 183bool DrawingAreaWC::isCompositingMode()
 184{
 185 return m_contentLayer;
 186}
 187
 188void DrawingAreaWC::updateRendering()
 189{
 190 if (m_isRenderingSuspended) {
 191 m_hasDeferredRenderingUpdate = true;
 192 return;
 193 }
 194
 195 // This function is not reentrant, e.g. a rAF callback may force repaint.
 196 if (m_inUpdateRendering)
 197 return;
 198 SetForScope<bool> change(m_inUpdateRendering, true);
 199
 200 ASSERT(!m_waitDidUpdate);
 201 m_waitDidUpdate = true;
 202
 203 m_webPage.updateRendering();
 204 m_webPage.flushPendingEditorStateUpdate();
 205
 206 OptionSet<FinalizeRenderingUpdateFlags> flags;
 207 m_webPage.finalizeRenderingUpdate(flags);
 208 m_webPage.didUpdateRendering();
 209
 210 if (isCompositingMode())
 211 sendUpdateAC();
 212 else
 213 sendUpdateNonAC();
 214}
 215
 216void DrawingAreaWC::sendUpdateAC()
 217{
 218 m_rootLayer->flushCompositingStateForThisLayerOnly();
 219
 220 // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.
 221 if (m_viewOverlayRootLayer)
 222 m_viewOverlayRootLayer->flushCompositingState({ });
 223
 224 m_updateInfo.rootLayer = m_rootLayer->primaryLayerID();
 225
 226 m_commitQueue->dispatch([this, weakThis = WeakPtr(*this), updateInfo = std::exchange(m_updateInfo, { })]() mutable {
 227 flushLayerImageBuffers(updateInfo);
 228 RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), updateInfo = WTFMove(updateInfo)]() mutable {
 229 if (!weakThis)
 230 return;
 231 m_remoteWCLayerTreeHostProxy->update(WTFMove(updateInfo));
 232 });
 233 });
 234}
 235
 236static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect, 1>& rects)
 237{
 238 const size_t rectThreshold = 10;
 239 const double wastedSpaceThreshold = 0.75;
 240
 241 if (rects.size() <= 1 || rects.size() > rectThreshold)
 242 return true;
 243 // Attempt to guess whether or not we should use the region bounds rect or the individual rects.
 244 // We do this by computing the percentage of "wasted space" in the bounds. If that wasted space
 245 // is too large, then we will do individual rect painting instead.
 246 unsigned boundsArea = bounds.width() * bounds.height();
 247 unsigned rectsArea = 0;
 248 for (size_t i = 0; i < rects.size(); ++i)
 249 rectsArea += rects[i].width() * rects[i].height();
 250
 251 double wastedSpace = 1 - (static_cast<double>(rectsArea) / boundsArea);
 252 return wastedSpace <= wastedSpaceThreshold;
 253}
 254
 255void DrawingAreaWC::sendUpdateNonAC()
 256{
 257 if (m_dirtyRegion.isEmpty()) {
 258 didUpdate();
 259 return;
 260 }
 261 IntRect bounds = m_dirtyRegion.bounds();
 262 ASSERT(m_webPage.bounds().contains(bounds));
 263 IntSize bitmapSize = bounds.size();
 264 float deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
 265 bitmapSize.scale(deviceScaleFactor);
 266
 267 auto image = createImageBuffer(bitmapSize);
 268 auto rects = m_dirtyRegion.rects();
 269 if (shouldPaintBoundsRect(bounds, rects)) {
 270 rects.clear();
 271 rects.append(bounds);
 272 }
 273 m_dirtyRegion = { };
 274
 275 UpdateInfo updateInfo;
 276 updateInfo.viewSize = m_webPage.size();
 277 updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
 278 updateInfo.updateRectBounds = bounds;
 279 updateInfo.updateRects = rects;
 280 updateInfo.scrollRect = m_scrollRect;
 281 updateInfo.scrollOffset = m_scrollOffset;
 282 m_scrollRect = { };
 283 m_scrollOffset = { };
 284
 285 auto& graphicsContext = image->context();
 286 graphicsContext.applyDeviceScaleFactor(deviceScaleFactor);
 287 graphicsContext.translate(-bounds.x(), -bounds.y());
 288 for (const auto& rect : rects)
 289 m_webPage.drawRect(image->context(), rect);
 290 image->flushDrawingContextAsync();
 291
 292 m_commitQueue->dispatch([this, weakThis = WeakPtr(*this), stateID = m_backingStoreStateID, updateInfo = WTFMove(updateInfo), image]() mutable {
 293 if (auto flusher = image->createFlusher())
 294 flusher->flush();
 295 RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), stateID, updateInfo = WTFMove(updateInfo), image]() mutable {
 296 if (!weakThis)
 297 return;
 298 if (stateID != m_backingStoreStateID) {
 299 didUpdate();
 300 return;
 301 }
 302 auto handle = static_cast<UnacceleratedImageBufferShareableBackend&>(*image->ensureBackendCreated()).createImageBufferBackendHandle();
 303 updateInfo.bitmapHandle = std::get<ShareableBitmap::Handle>(WTFMove(handle));
 304 send(Messages::DrawingAreaProxy::Update(stateID, WTFMove(updateInfo)));
 305 });
 306 });
 307}
 308
 309void DrawingAreaWC::graphicsLayerAdded(GraphicsLayerWC& layer)
 310{
 311 m_liveGraphicsLayers.append(&layer);
 312 m_updateInfo.addedLayers.append(layer.primaryLayerID());
 313}
 314
 315void DrawingAreaWC::graphicsLayerRemoved(GraphicsLayerWC& layer)
 316{
 317 m_liveGraphicsLayers.remove(&layer);
 318 m_updateInfo.removedLayers.append(layer.primaryLayerID());
 319}
 320
 321void DrawingAreaWC::commitLayerUpateInfo(WCLayerUpateInfo&& info)
 322{
 323 m_updateInfo.changedLayers.append(WTFMove(info));
 324}
 325
 326RefPtr<ImageBuffer> DrawingAreaWC::createImageBuffer(FloatSize size)
 327{
 328 if (WebProcess::singleton().shouldUseRemoteRenderingFor(RenderingPurpose::DOM))
 329 return m_webPage.ensureRemoteRenderingBackendProxy().createImageBuffer(size, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
 330 return ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(size, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, nullptr);
 331}
 332
 333void DrawingAreaWC::didUpdate()
 334{
 335 m_waitDidUpdate = false;
 336 if (m_hasDeferredRenderingUpdate) {
 337 m_hasDeferredRenderingUpdate = false;
 338 triggerRenderingUpdate();
 339 }
 340}
 341
 342DrawingAreaWC::RootLayerClient::RootLayerClient(WebPage& webPage)
 343 : m_webPage(webPage)
 344{
 345}
 346
 347void DrawingAreaWC::RootLayerClient::paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& rectToPaint, GraphicsLayerPaintBehavior)
 348{
 349 context.save();
 350 context.clip(rectToPaint);
 351 m_webPage.corePage()->mainFrame().view()->paint(context, enclosingIntRect(rectToPaint));
 352 context.restore();
 353}
 354
 355float DrawingAreaWC::RootLayerClient::deviceScaleFactor() const
 356{
 357 return m_webPage.corePage()->deviceScaleFactor();
 358}
 359
 360} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "DrawingArea.h"
 29#include "GraphicsLayerWC.h"
 30#include "RemoteWCLayerTreeHostProxy.h"
 31#include "WCLayerFactory.h"
 32#include <WebCore/GraphicsLayerFactory.h>
 33#include <WebCore/Timer.h>
 34
 35namespace WebKit {
 36
 37class DrawingAreaWC final
 38 : public DrawingArea
 39 , public GraphicsLayerWC::Observer
 40 , public RemoteWCLayerTreeHostProxy::Client {
 41public:
 42 DrawingAreaWC(WebPage&, const WebPageCreationParameters&);
 43 ~DrawingAreaWC() override;
 44
 45private:
 46 // DrawingArea
 47 WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
 48 void setNeedsDisplay() override;
 49 void setNeedsDisplayInRect(const WebCore::IntRect&) override;
 50 void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
 51 void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override { }
 52 void triggerRenderingUpdate() override;
 53 void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override { }
 54 void deviceOrPageScaleFactorChanged() override { }
 55 void setLayerTreeStateIsFrozen(bool) override;
 56 bool layerTreeStateIsFrozen() const override { return m_isRenderingSuspended; }
 57 void updateGeometry(uint64_t, WebCore::IntSize) override;
 58 void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
 59 void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
 60 // GraphicsLayerWC::Observer
 61 void graphicsLayerAdded(GraphicsLayerWC&) override;
 62 void graphicsLayerRemoved(GraphicsLayerWC&) override;
 63 void commitLayerUpateInfo(WCLayerUpateInfo&&) override;
 64 RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize) override;
 65 // RemoteWCLayerTreeHostProxy::Client
 66 void didUpdate() override;
 67
 68 bool isCompositingMode();
 69 void updateRendering();
 70 void sendUpdateAC();
 71 void sendUpdateNonAC();
 72 void updateRootLayers();
 73
 74 class RootLayerClient : public WebCore::GraphicsLayerClient {
 75 public:
 76 RootLayerClient(WebPage&);
 77 private:
 78 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::FloatRect& rectToPaint, WebCore::GraphicsLayerPaintBehavior) override;
 79 float deviceScaleFactor() const override;
 80 WebPage& m_webPage;
 81 };
 82
 83 RootLayerClient m_rootLayerClient;
 84 std::unique_ptr<RemoteWCLayerTreeHostProxy> m_remoteWCLayerTreeHostProxy;
 85 WCLayerFactory m_layerFactory;
 86 DoublyLinkedList<GraphicsLayerWC> m_liveGraphicsLayers;
 87 WebCore::Timer m_updateRenderingTimer;
 88 bool m_isRenderingSuspended { false };
 89 bool m_hasDeferredRenderingUpdate { false };
 90 bool m_inUpdateRendering { false };
 91 bool m_waitDidUpdate { false };
 92 WCUpateInfo m_updateInfo;
 93 Ref<WebCore::GraphicsLayer> m_rootLayer;
 94 RefPtr<WebCore::GraphicsLayer> m_contentLayer;
 95 RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer;
 96 Ref<WorkQueue> m_commitQueue;
 97 int64_t m_backingStoreStateID { 0 };
 98 WebCore::Region m_dirtyRegion;
 99 WebCore::IntRect m_scrollRect;
 100 WebCore::IntSize m_scrollOffset;
 101};
 102
 103} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "GraphicsLayerWC.h"
 28
 29#include <WebCore/WCPlatformLayerGCGL.h>
 30
 31namespace WebKit {
 32using namespace WebCore;
 33
 34GraphicsLayerWC::GraphicsLayerWC(Type layerType, GraphicsLayerClient& client, Observer& observer)
 35 : GraphicsLayer(layerType, client)
 36 , m_observer(&observer)
 37{
 38 m_observer->graphicsLayerAdded(*this);
 39}
 40
 41GraphicsLayerWC::~GraphicsLayerWC()
 42{
 43 willBeDestroyed();
 44 if (m_observer)
 45 m_observer->graphicsLayerRemoved(*this);
 46}
 47
 48GraphicsLayer::PlatformLayerID GraphicsLayerWC::generateLayerID()
 49{
 50 // 0 and max can't be used for hash keys
 51 static GraphicsLayer::PlatformLayerID id = 1;
 52 return id++;
 53}
 54
 55GraphicsLayer::PlatformLayerID GraphicsLayerWC::primaryLayerID() const
 56{
 57 return m_layerID;
 58}
 59
 60void GraphicsLayerWC::setNeedsDisplay()
 61{
 62 if (!drawsContent())
 63 return;
 64 noteLayerPropertyChanged(WCLayerChange::BackingStore);
 65 addRepaintRect({ { }, m_size });
 66}
 67
 68void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer)
 69{
 70 if (!drawsContent())
 71 return;
 72 noteLayerPropertyChanged(WCLayerChange::BackingStore);
 73 addRepaintRect(rect);
 74}
 75
 76void GraphicsLayerWC::setContentsNeedsDisplay()
 77{
 78 // For example, if WebGL canvas changed, it needs flush to display.
 79 noteLayerPropertyChanged({ });
 80}
 81
 82bool GraphicsLayerWC::setChildren(Vector<Ref<GraphicsLayer>>&& children)
 83{
 84 bool childrenChanged = GraphicsLayer::setChildren(WTFMove(children));
 85 if (childrenChanged)
 86 noteLayerPropertyChanged(WCLayerChange::Children);
 87 return childrenChanged;
 88}
 89
 90void GraphicsLayerWC::addChild(Ref<GraphicsLayer>&& childLayer)
 91{
 92 GraphicsLayer::addChild(WTFMove(childLayer));
 93 noteLayerPropertyChanged(WCLayerChange::Children);
 94}
 95
 96void GraphicsLayerWC::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index)
 97{
 98 GraphicsLayer::addChildAtIndex(WTFMove(childLayer), index);
 99 noteLayerPropertyChanged(WCLayerChange::Children);
 100}
 101
 102void GraphicsLayerWC::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
 103{
 104 GraphicsLayer::addChildBelow(WTFMove(childLayer), sibling);
 105 noteLayerPropertyChanged(WCLayerChange::Children);
 106}
 107
 108void GraphicsLayerWC::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
 109{
 110 GraphicsLayer::addChildAbove(WTFMove(childLayer), sibling);
 111 noteLayerPropertyChanged(WCLayerChange::Children);
 112}
 113
 114bool GraphicsLayerWC::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
 115{
 116 if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) {
 117 noteLayerPropertyChanged(WCLayerChange::Children);
 118 return true;
 119 }
 120 return false;
 121}
 122
 123void GraphicsLayerWC::removeFromParent()
 124{
 125 if (m_parent)
 126 static_cast<GraphicsLayerWC*>(m_parent)->noteLayerPropertyChanged(WCLayerChange::Children);
 127 GraphicsLayer::removeFromParent();
 128}
 129
 130void GraphicsLayerWC::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
 131{
 132 if (layer == m_maskLayer)
 133 return;
 134 GraphicsLayer::setMaskLayer(WTFMove(layer));
 135 noteLayerPropertyChanged(WCLayerChange::MaskLayer);
 136}
 137
 138void GraphicsLayerWC::setReplicatedLayer(GraphicsLayer* layer)
 139{
 140 if (layer == m_replicatedLayer)
 141 return;
 142 GraphicsLayer::setReplicatedLayer(layer);
 143 noteLayerPropertyChanged(WCLayerChange::ReplicaLayer);
 144}
 145
 146void GraphicsLayerWC::setReplicatedByLayer(RefPtr<GraphicsLayer>&& layer)
 147{
 148 if (layer == m_replicaLayer)
 149 return;
 150 GraphicsLayer::setReplicatedByLayer(WTFMove(layer));
 151 noteLayerPropertyChanged(WCLayerChange::ReplicaLayer);
 152}
 153
 154void GraphicsLayerWC::setPosition(const FloatPoint& point)
 155{
 156 if (point == m_position)
 157 return;
 158 GraphicsLayer::setPosition(point);
 159 noteLayerPropertyChanged(WCLayerChange::Geometry);
 160}
 161
 162void GraphicsLayerWC::setAnchorPoint(const FloatPoint3D& point)
 163{
 164 if (point == m_anchorPoint)
 165 return;
 166 GraphicsLayer::setAnchorPoint(point);
 167 noteLayerPropertyChanged(WCLayerChange::Geometry);
 168}
 169
 170void GraphicsLayerWC::setSize(const FloatSize& size)
 171{
 172 if (size == m_size)
 173 return;
 174 GraphicsLayer::setSize(size);
 175 noteLayerPropertyChanged(WCLayerChange::Geometry);
 176}
 177
 178void GraphicsLayerWC::setBoundsOrigin(const FloatPoint& origin)
 179{
 180 if (origin == m_boundsOrigin)
 181 return;
 182 GraphicsLayer::setBoundsOrigin(origin);
 183 noteLayerPropertyChanged(WCLayerChange::Geometry);
 184}
 185
 186void GraphicsLayerWC::setTransform(const TransformationMatrix& t)
 187{
 188 if (t == transform())
 189 return;
 190 GraphicsLayer::setTransform(t);
 191 noteLayerPropertyChanged(WCLayerChange::Transform);
 192}
 193
 194void GraphicsLayerWC::setChildrenTransform(const TransformationMatrix& t)
 195{
 196 if (t == childrenTransform())
 197 return;
 198 GraphicsLayer::setChildrenTransform(t);
 199 noteLayerPropertyChanged(WCLayerChange::ChildrenTransform);
 200}
 201
 202void GraphicsLayerWC::setPreserves3D(bool value)
 203{
 204 if (value == preserves3D())
 205 return;
 206 GraphicsLayer::setPreserves3D(value);
 207 noteLayerPropertyChanged(WCLayerChange::Preserves3D);
 208}
 209
 210void GraphicsLayerWC::setMasksToBounds(bool value)
 211{
 212 if (value == masksToBounds())
 213 return;
 214 GraphicsLayer::setMasksToBounds(value);
 215 noteLayerPropertyChanged(WCLayerChange::MasksToBounds);
 216}
 217
 218void GraphicsLayerWC::setOpacity(float value)
 219{
 220 if (value == opacity())
 221 return;
 222 GraphicsLayer::setOpacity(value);
 223 noteLayerPropertyChanged(WCLayerChange::Opacity);
 224}
 225
 226void GraphicsLayerWC::setContentsRect(const FloatRect& value)
 227{
 228 if (value == contentsRect())
 229 return;
 230 GraphicsLayer::setContentsRect(value);
 231 noteLayerPropertyChanged(WCLayerChange::ContentsRect);
 232}
 233
 234void GraphicsLayerWC::setContentsClippingRect(const FloatRoundedRect& value)
 235{
 236 if (value == contentsClippingRect())
 237 return;
 238 GraphicsLayer::setContentsClippingRect(value);
 239 noteLayerPropertyChanged(WCLayerChange::ContentsClippingRect);
 240}
 241
 242void GraphicsLayerWC::setDrawsContent(bool value)
 243{
 244 if (value == drawsContent())
 245 return;
 246 GraphicsLayer::setDrawsContent(value);
 247 noteLayerPropertyChanged(WCLayerChange::BackingStore);
 248}
 249
 250void GraphicsLayerWC::setContentsVisible(bool value)
 251{
 252 if (value == contentsAreVisible())
 253 return;
 254 GraphicsLayer::setContentsVisible(value);
 255 noteLayerPropertyChanged(WCLayerChange::ContentsVisible);
 256}
 257
 258void GraphicsLayerWC::setBackfaceVisibility(bool value)
 259{
 260 if (value == backfaceVisibility())
 261 return;
 262 GraphicsLayer::setBackfaceVisibility(value);
 263 noteLayerPropertyChanged(WCLayerChange::BackfaceVisibility);
 264}
 265
 266void GraphicsLayerWC::setContentsToSolidColor(const Color& color)
 267{
 268 if (color == m_solidColor)
 269 return;
 270 m_solidColor = color;
 271 noteLayerPropertyChanged(WCLayerChange::SolidColor);
 272}
 273
 274void GraphicsLayerWC::setContentsToPlatformLayer(PlatformLayer* platformLayer, ContentsLayerPurpose)
 275{
 276 if (m_platformLayer == platformLayer)
 277 return;
 278 m_platformLayer = platformLayer;
 279 noteLayerPropertyChanged(WCLayerChange::PlatformLayer);
 280}
 281
 282bool GraphicsLayerWC::usesContentsLayer() const
 283{
 284 return m_platformLayer;
 285}
 286
 287void GraphicsLayerWC::setShowDebugBorder(bool show)
 288{
 289 if (isShowingDebugBorder() == show)
 290 return;
 291 GraphicsLayer::setShowDebugBorder(show);
 292 updateDebugIndicators();
 293 noteLayerPropertyChanged(WCLayerChange::DebugVisuals);
 294}
 295
 296void GraphicsLayerWC::setDebugBorder(const Color& color, float width)
 297{
 298 m_debugBorderColor = color;
 299 m_debugBorderWidth = width;
 300 noteLayerPropertyChanged(WCLayerChange::DebugVisuals);
 301}
 302
 303void GraphicsLayerWC::setShowRepaintCounter(bool show)
 304{
 305 if (isShowingRepaintCounter() == show)
 306 return;
 307 GraphicsLayer::setShowRepaintCounter(show);
 308 noteLayerPropertyChanged(WCLayerChange::RepaintCount);
 309}
 310
 311static bool filtersCanBeComposited(const FilterOperations& filters)
 312{
 313 if (!filters.size())
 314 return false;
 315 for (const auto& filterOperation : filters.operations()) {
 316 if (filterOperation->type() == FilterOperation::REFERENCE)
 317 return false;
 318 }
 319 return true;
 320}
 321
 322bool GraphicsLayerWC::setFilters(const FilterOperations& filters)
 323{
 324 bool canCompositeFilters = filtersCanBeComposited(filters);
 325 if (GraphicsLayer::filters() == filters)
 326 return canCompositeFilters;
 327
 328 if (canCompositeFilters) {
 329 if (!GraphicsLayer::setFilters(filters))
 330 return false;
 331 } else if (GraphicsLayer::filters().size())
 332 clearFilters();
 333
 334 noteLayerPropertyChanged(WCLayerChange::Filters);
 335 return canCompositeFilters;
 336}
 337
 338bool GraphicsLayerWC::setBackdropFilters(const FilterOperations& filters)
 339{
 340 bool canCompositeFilters = filtersCanBeComposited(filters);
 341 if (m_backdropFilters == filters)
 342 return canCompositeFilters;
 343 if (canCompositeFilters)
 344 GraphicsLayer::setBackdropFilters(filters);
 345 else
 346 clearBackdropFilters();
 347 noteLayerPropertyChanged(WCLayerChange::BackdropFilters);
 348 return canCompositeFilters;
 349}
 350
 351void GraphicsLayerWC::setBackdropFiltersRect(const FloatRoundedRect& backdropFiltersRect)
 352{
 353 if (m_backdropFiltersRect == backdropFiltersRect)
 354 return;
 355 GraphicsLayer::setBackdropFiltersRect(backdropFiltersRect);
 356 noteLayerPropertyChanged(WCLayerChange::BackdropFilters);
 357}
 358
 359void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags)
 360{
 361 if (beingDestroyed())
 362 return;
 363 bool needsFlush = !m_uncommittedChanges;
 364 m_uncommittedChanges.add(flags);
 365 if (needsFlush)
 366 client().notifyFlushRequired(this);
 367}
 368
 369void GraphicsLayerWC::flushCompositingState(const FloatRect& rect)
 370{
 371 if (auto* mask = maskLayer())
 372 mask->flushCompositingStateForThisLayerOnly();
 373 if (auto* replica = replicaLayer())
 374 replica->flushCompositingStateForThisLayerOnly();
 375 flushCompositingStateForThisLayerOnly();
 376 for (auto& child : children())
 377 child->flushCompositingState(rect);
 378}
 379
 380void GraphicsLayerWC::flushCompositingStateForThisLayerOnly()
 381{
 382 if (!m_uncommittedChanges)
 383 return;
 384 WCLayerUpateInfo update;
 385 update.id = primaryLayerID();
 386 update.changes = std::exchange(m_uncommittedChanges, { });
 387 if (update.changes & WCLayerChange::Children) {
 388 update.children = WTF::map(children(), [](auto& layer) {
 389 return layer->primaryLayerID();
 390 });
 391 }
 392 if (update.changes & WCLayerChange::MaskLayer) {
 393 if (maskLayer())
 394 update.maskLayer = maskLayer()->primaryLayerID();
 395 else
 396 update.maskLayer = std::nullopt;
 397 }
 398 if (update.changes & WCLayerChange::ReplicaLayer) {
 399 if (replicaLayer())
 400 update.replicaLayer = replicaLayer()->primaryLayerID();
 401 else
 402 update.replicaLayer = std::nullopt;
 403 }
 404 if (update.changes & WCLayerChange::Geometry) {
 405 update.position = position();
 406 update.anchorPoint = anchorPoint();
 407 update.size = size();
 408 update.boundsOrigin = boundsOrigin();
 409 }
 410 if (update.changes & WCLayerChange::Preserves3D)
 411 update.preserves3D = preserves3D();
 412 if (update.changes & WCLayerChange::ContentsRect)
 413 update.contentsRect = contentsRect();
 414 if (update.changes & WCLayerChange::ContentsClippingRect)
 415 update.contentsClippingRect = contentsClippingRect();
 416 if (update.changes & WCLayerChange::ContentsVisible)
 417 update.contentsVisible = contentsAreVisible();
 418 if (update.changes & WCLayerChange::BackfaceVisibility)
 419 update.backfaceVisibility = backfaceVisibility();
 420 if (update.changes & WCLayerChange::MasksToBounds)
 421 update.masksToBounds = masksToBounds();
 422 if (update.changes & WCLayerChange::BackingStore) {
 423 if (drawsContent() && contentsAreVisible() && !size().isEmpty()) {
 424 auto image = m_observer->createImageBuffer(size());
 425 FloatRect clipRect = { { }, size() };
 426 paintGraphicsLayerContents(image->context(), clipRect);
 427 image->flushDrawingContextAsync();
 428 update.backingStore.setImageBuffer(WTFMove(image));
 429
 430 incrementRepaintCount();
 431 update.changes.add(WCLayerChange::RepaintCount);
 432 }
 433 }
 434 if (update.changes & WCLayerChange::SolidColor)
 435 update.solidColor = m_solidColor;
 436 if (update.changes & WCLayerChange::DebugVisuals) {
 437 update.showDebugBorder = isShowingDebugBorder();
 438 update.debugBorderColor = m_debugBorderColor;
 439 update.debugBorderWidth = m_debugBorderWidth;
 440 }
 441 if (update.changes & WCLayerChange::RepaintCount) {
 442 update.showRepaintCounter = isShowingRepaintCounter();
 443 update.repaintCount = repaintCount();
 444 }
 445 if (update.changes & WCLayerChange::Opacity)
 446 update.opacity = opacity();
 447 if (update.changes & WCLayerChange::Transform)
 448 update.transform = transform();
 449 if (update.changes & WCLayerChange::ChildrenTransform)
 450 update.childrenTransform = childrenTransform();
 451 if (update.changes & WCLayerChange::Filters)
 452 update.filters = filters();
 453 if (update.changes & WCLayerChange::BackdropFilters) {
 454 update.backdropFilters = backdropFilters();
 455 update.backdropFiltersRect = backdropFiltersRect();
 456 }
 457 if (update.changes & WCLayerChange::PlatformLayer) {
 458 if (m_platformLayer)
 459 update.graphicsContextGLIdentifier = static_cast<WCPlatformLayerGCGL*>(m_platformLayer)->graphicsContextGLIdentifier();
 460 else
 461 update.graphicsContextGLIdentifier = 0;
 462 }
 463 m_observer->commitLayerUpateInfo(WTFMove(update));
 464}
 465
 466} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "WCUpateInfo.h"
 29#include <wtf/DoublyLinkedList.h>
 30
 31namespace WebKit {
 32
 33class GraphicsLayerWC final : public WebCore::GraphicsLayer, public DoublyLinkedListNode<GraphicsLayerWC> {
 34public:
 35 struct Observer {
 36 virtual void graphicsLayerAdded(GraphicsLayerWC&) = 0;
 37 virtual void graphicsLayerRemoved(GraphicsLayerWC&) = 0;
 38 virtual void commitLayerUpateInfo(WCLayerUpateInfo&&) = 0;
 39 virtual RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize) = 0;
 40 };
 41
 42 GraphicsLayerWC(Type layerType, WebCore::GraphicsLayerClient&, Observer&);
 43 ~GraphicsLayerWC() override;
 44
 45 void clearObserver() { m_observer = nullptr; }
 46
 47 // GraphicsLayer
 48 WebCore::GraphicsLayer::PlatformLayerID primaryLayerID() const override;
 49 void setNeedsDisplay() override;
 50 void setNeedsDisplayInRect(const WebCore::FloatRect&, ShouldClipToLayer) override;
 51 void setContentsNeedsDisplay() override;
 52 bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
 53 void addChild(Ref<GraphicsLayer>&&) override;
 54 void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override;
 55 void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
 56 void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
 57 bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override;
 58 void removeFromParent() override;
 59 void setMaskLayer(RefPtr<GraphicsLayer>&&);
 60 void setReplicatedLayer(GraphicsLayer*);
 61 void setReplicatedByLayer(RefPtr<GraphicsLayer>&&);
 62 void setPosition(const WebCore::FloatPoint&) override;
 63 void setAnchorPoint(const WebCore::FloatPoint3D&) override;
 64 void setSize(const WebCore::FloatSize&) override;
 65 void setBoundsOrigin(const WebCore::FloatPoint&) override;
 66 void setTransform(const WebCore::TransformationMatrix&) override;
 67 void setChildrenTransform(const WebCore::TransformationMatrix&) override;
 68 void setPreserves3D(bool) override;
 69 void setMasksToBounds(bool) override;
 70 void setOpacity(float) override;
 71 void setContentsRect(const WebCore::FloatRect&) override;
 72 void setContentsClippingRect(const WebCore::FloatRoundedRect&) override;
 73 void setDrawsContent(bool) override;
 74 void setContentsVisible(bool) override;
 75 void setBackfaceVisibility(bool) override;
 76 void setContentsToSolidColor(const WebCore::Color&) override;
 77 void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
 78 bool shouldDirectlyCompositeImage(WebCore::Image*) const override { return false; }
 79 bool usesContentsLayer() const override;
 80 void setShowDebugBorder(bool) override;
 81 void setDebugBorder(const WebCore::Color&, float width) override;
 82 void setShowRepaintCounter(bool) override;
 83 bool setFilters(const WebCore::FilterOperations&) override;
 84 bool setBackdropFilters(const WebCore::FilterOperations&) override;
 85 void setBackdropFiltersRect(const WebCore::FloatRoundedRect&) override;
 86 void flushCompositingState(const WebCore::FloatRect& clipRect) override;
 87 void flushCompositingStateForThisLayerOnly() override;
 88
 89private:
 90 void noteLayerPropertyChanged(OptionSet<WCLayerChange>);
 91
 92 static GraphicsLayer::PlatformLayerID generateLayerID();
 93
 94 friend class WTF::DoublyLinkedListNode<GraphicsLayerWC>;
 95
 96 GraphicsLayerWC* m_prev;
 97 GraphicsLayerWC* m_next;
 98 WebCore::GraphicsLayer::PlatformLayerID m_layerID { generateLayerID() };
 99 Observer* m_observer;
 100 PlatformLayer* m_platformLayer { nullptr };
 101 WebCore::Color m_solidColor;
 102 WebCore::Color m_debugBorderColor;
 103 OptionSet<WCLayerChange> m_uncommittedChanges;
 104 float m_debugBorderWidth { 0 };
 105};
 106
 107} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/WCBackingStore.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "ImageBufferBackendHandle.h"
 29#include "PlatformRemoteImageBufferProxy.h"
 30
 31namespace WebKit {
 32
 33class WCBackingStore {
 34 WTF_MAKE_FAST_ALLOCATED;
 35public:
 36 WCBackingStore() { }
 37 WebCore::ImageBuffer* imageBuffer() { return m_imageBuffer.get(); }
 38 void setImageBuffer(RefPtr<WebCore::ImageBuffer>&& image) { m_imageBuffer = WTFMove(image); }
 39 ShareableBitmap* bitmap() const { return m_bitmap.get(); }
 40
 41 template<class Encoder>
 42 void encode(Encoder& encoder) const
 43 {
 44 bool hasImageBuffer = m_imageBuffer;
 45 encoder << hasImageBuffer;
 46 if (hasImageBuffer) {
 47 auto handle = static_cast<UnacceleratedImageBufferShareableBackend&>(*m_imageBuffer->ensureBackendCreated()).createImageBufferBackendHandle();
 48 encoder << handle;
 49 }
 50 }
 51
 52 template <class Decoder>
 53 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCBackingStore& result)
 54 {
 55 bool hasImageBuffer;
 56 if (!decoder.decode(hasImageBuffer))
 57 return false;
 58 if (hasImageBuffer) {
 59 ImageBufferBackendHandle handle;
 60 if (!decoder.decode(handle))
 61 return false;
 62 result.m_bitmap = ShareableBitmap::create(std::get<ShareableBitmap::Handle>(handle));
 63 }
 64 return true;
 65 }
 66
 67private:
 68 RefPtr<WebCore::ImageBuffer> m_imageBuffer;
 69 RefPtr<ShareableBitmap> m_bitmap;
 70};
 71
 72} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.cpp

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WCLayerFactory.h"
 28
 29#include "GraphicsLayerWC.h"
 30
 31namespace WebKit {
 32using namespace WebCore;
 33
 34WCLayerFactory::WCLayerFactory(GraphicsLayerWC::Observer& observer)
 35 : m_observer(observer)
 36{
 37}
 38
 39Ref<WebCore::GraphicsLayer> WCLayerFactory::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, WebCore::GraphicsLayerClient& client)
 40{
 41 return adoptRef(*new GraphicsLayerWC(layerType, client, m_observer));
 42}
 43
 44} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/WCLayerFactory.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "GraphicsLayerWC.h"
 29#include <WebCore/GraphicsLayerFactory.h>
 30
 31namespace WebKit {
 32
 33class WCLayerFactory final : public WebCore::GraphicsLayerFactory {
 34public:
 35 WCLayerFactory(GraphicsLayerWC::Observer&);
 36
 37private:
 38 // WebCore::GraphicsLayerFactory
 39 Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
 40
 41 GraphicsLayerWC::Observer& m_observer;
 42};
 43
 44} // namespace WebKit

Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h

 1/*
 2 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "WCBackingStore.h"
 29#include "WebCoreArgumentCoders.h"
 30#include <WebCore/GraphicsLayer.h>
 31#include <optional>
 32#include <wtf/EnumTraits.h>
 33#include <wtf/OptionSet.h>
 34
 35namespace WebKit {
 36
 37enum class WCLayerChange : uint32_t {
 38 Children = 1 << 0,
 39 MaskLayer = 1 << 1,
 40 ReplicaLayer = 1 << 2,
 41 Geometry = 1 << 3,
 42 Preserves3D = 1 << 4,
 43 ContentsVisible = 1 << 5,
 44 BackfaceVisibility = 1 << 6,
 45 MasksToBounds = 1 << 7,
 46 SolidColor = 1 << 8,
 47 DebugVisuals = 1 << 9,
 48 RepaintCount = 1 << 10,
 49 ContentsRect = 1 << 11,
 50 ContentsClippingRect = 1 << 12,
 51 Opacity = 1 << 13,
 52 BackingStore = 1 << 14,
 53 Transform = 1 << 15,
 54 ChildrenTransform = 1 << 16,
 55 Filters = 1 << 17,
 56 BackdropFilters = 1 << 18,
 57 PlatformLayer = 1 << 19,
 58};
 59
 60struct WCLayerUpateInfo {
 61 WebCore::GraphicsLayer::PlatformLayerID id;
 62 OptionSet<WCLayerChange> changes;
 63 Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
 64 std::optional<WebCore::GraphicsLayer::PlatformLayerID> maskLayer;
 65 std::optional<WebCore::GraphicsLayer::PlatformLayerID> replicaLayer;
 66 WebCore::FloatPoint position;
 67 WebCore::FloatPoint3D anchorPoint;
 68 WebCore::FloatSize size;
 69 WebCore::FloatPoint boundsOrigin;
 70 bool masksToBounds;
 71 bool showDebugBorder;
 72 bool showRepaintCounter;
 73 bool contentsVisible;
 74 bool backfaceVisibility;
 75 bool preserves3D;
 76 WebCore::Color solidColor;
 77 WebCore::Color debugBorderColor;
 78 float opacity;
 79 float debugBorderWidth;
 80 int repaintCount;
 81 WebCore::FloatRect contentsRect;
 82 WCBackingStore backingStore;
 83 WebCore::TransformationMatrix transform;
 84 WebCore::TransformationMatrix childrenTransform;
 85 WebCore::FilterOperations filters;
 86 WebCore::FilterOperations backdropFilters;
 87 WebCore::FloatRoundedRect backdropFiltersRect;
 88 WebCore::FloatRoundedRect contentsClippingRect;
 89 uint64_t graphicsContextGLIdentifier;
 90
 91 template<class Encoder>
 92 void encode(Encoder& encoder) const
 93 {
 94 encoder << id;
 95 encoder << changes;
 96 if (changes & WCLayerChange::Children)
 97 encoder << children;
 98 if (changes & WCLayerChange::MaskLayer)
 99 encoder << maskLayer;
 100 if (changes & WCLayerChange::ReplicaLayer)
 101 encoder << replicaLayer;
 102 if (changes & WCLayerChange::Geometry)
 103 encoder << position << anchorPoint << size << boundsOrigin;
 104 if (changes & WCLayerChange::Preserves3D)
 105 encoder << preserves3D;
 106 if (changes & WCLayerChange::ContentsVisible)
 107 encoder << contentsVisible;
 108 if (changes & WCLayerChange::BackfaceVisibility)
 109 encoder << backfaceVisibility;
 110 if (changes & WCLayerChange::MasksToBounds)
 111 encoder << masksToBounds;
 112 if (changes & WCLayerChange::SolidColor)
 113 encoder << solidColor;
 114 if (changes & WCLayerChange::DebugVisuals)
 115 encoder << showDebugBorder << debugBorderColor << debugBorderWidth;
 116 if (changes & WCLayerChange::RepaintCount)
 117 encoder << showRepaintCounter << repaintCount;
 118 if (changes & WCLayerChange::ContentsRect)
 119 encoder << contentsRect;
 120 if (changes & WCLayerChange::ContentsClippingRect)
 121 encoder << contentsClippingRect;
 122 if (changes & WCLayerChange::Opacity)
 123 encoder << opacity;
 124 if (changes & WCLayerChange::BackingStore)
 125 encoder << backingStore;
 126 if (changes & WCLayerChange::Transform)
 127 encoder << transform;
 128 if (changes & WCLayerChange::ChildrenTransform)
 129 encoder << childrenTransform;
 130 if (changes & WCLayerChange::Filters)
 131 encoder << filters;
 132 if (changes & WCLayerChange::BackdropFilters)
 133 encoder << backdropFilters << backdropFiltersRect;
 134 if (changes & WCLayerChange::PlatformLayer)
 135 encoder << graphicsContextGLIdentifier;
 136 }
 137
 138 template <class Decoder>
 139 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCLayerUpateInfo& result)
 140 {
 141 if (!decoder.decode(result.id))
 142 return false;
 143 if (!decoder.decode(result.changes))
 144 return false;
 145 if (result.changes & WCLayerChange::Children) {
 146 if (!decoder.decode(result.children))
 147 return false;
 148 }
 149 if (result.changes & WCLayerChange::MaskLayer) {
 150 if (!decoder.decode(result.maskLayer))
 151 return false;
 152 }
 153 if (result.changes & WCLayerChange::ReplicaLayer) {
 154 if (!decoder.decode(result.replicaLayer))
 155 return false;
 156 }
 157 if (result.changes & WCLayerChange::Geometry) {
 158 if (!decoder.decode(result.position))
 159 return false;
 160 if (!decoder.decode(result.anchorPoint))
 161 return false;
 162 if (!decoder.decode(result.size))
 163 return false;
 164 if (!decoder.decode(result.boundsOrigin))
 165 return false;
 166 }
 167 if (result.changes & WCLayerChange::Preserves3D) {
 168 if (!decoder.decode(result.preserves3D))
 169 return false;
 170 }
 171 if (result.changes & WCLayerChange::ContentsVisible) {
 172 if (!decoder.decode(result.contentsVisible))
 173 return false;
 174 }
 175 if (result.changes & WCLayerChange::BackfaceVisibility) {
 176 if (!decoder.decode(result.backfaceVisibility))
 177 return false;
 178 }
 179 if (result.changes & WCLayerChange::MasksToBounds) {
 180 if (!decoder.decode(result.masksToBounds))
 181 return false;
 182 }
 183 if (result.changes & WCLayerChange::SolidColor) {
 184 if (!decoder.decode(result.solidColor))
 185 return false;
 186 }
 187 if (result.changes & WCLayerChange::DebugVisuals) {
 188 if (!decoder.decode(result.showDebugBorder))
 189 return false;
 190 if (!decoder.decode(result.debugBorderColor))
 191 return false;
 192 if (!decoder.decode(result.debugBorderWidth))
 193 return false;
 194 }
 195 if (result.changes & WCLayerChange::RepaintCount) {
 196 if (!decoder.decode(result.showRepaintCounter))
 197 return false;
 198 if (!decoder.decode(result.repaintCount))
 199 return false;
 200 }
 201 if (result.changes & WCLayerChange::ContentsRect) {
 202 if (!decoder.decode(result.contentsRect))
 203 return false;
 204 }
 205 if (result.changes & WCLayerChange::ContentsClippingRect) {
 206 if (!decoder.decode(result.contentsClippingRect))
 207 return false;
 208 }
 209 if (result.changes & WCLayerChange::Opacity) {
 210 if (!decoder.decode(result.opacity))
 211 return false;
 212 }
 213 if (result.changes & WCLayerChange::BackingStore) {
 214 if (!decoder.decode(result.backingStore))
 215 return false;
 216 }
 217 if (result.changes & WCLayerChange::Transform) {
 218 if (!decoder.decode(result.transform))
 219 return false;
 220 }
 221 if (result.changes & WCLayerChange::ChildrenTransform) {
 222 if (!decoder.decode(result.childrenTransform))
 223 return false;
 224 }
 225 if (result.changes & WCLayerChange::Filters) {
 226 if (!decoder.decode(result.filters))
 227 return false;
 228 }
 229 if (result.changes & WCLayerChange::BackdropFilters) {
 230 if (!decoder.decode(result.backdropFilters))
 231 return false;
 232 if (!decoder.decode(result.backdropFiltersRect))
 233 return false;
 234 }
 235 if (result.changes & WCLayerChange::PlatformLayer) {
 236 if (!decoder.decode(result.graphicsContextGLIdentifier))
 237 return false;
 238 }
 239 return true;
 240 }
 241};
 242
 243struct WCUpateInfo {
 244 WebCore::GraphicsLayer::PlatformLayerID rootLayer;
 245 Vector<WebCore::GraphicsLayer::PlatformLayerID> addedLayers;
 246 Vector<WebCore::GraphicsLayer::PlatformLayerID> removedLayers;
 247 Vector<WCLayerUpateInfo> changedLayers;
 248
 249 template<class Encoder>
 250 void encode(Encoder& encoder) const
 251 {
 252 encoder << rootLayer;
 253 encoder << addedLayers;
 254 encoder << removedLayers;
 255 encoder << changedLayers;
 256 }
 257
 258 template <class Decoder>
 259 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WCUpateInfo& result)
 260 {
 261 if (!decoder.decode(result.rootLayer))
 262 return false;
 263 if (!decoder.decode(result.addedLayers))
 264 return false;
 265 if (!decoder.decode(result.removedLayers))
 266 return false;
 267 if (!decoder.decode(result.changedLayers))
 268 return false;
 269 return true;
 270 }
 271};
 272
 273} // namespace WebKit
 274
 275namespace WTF {
 276
 277template<> struct EnumTraits<WebKit::WCLayerChange> {
 278 using values = EnumValues<
 279 WebKit::WCLayerChange,
 280 WebKit::WCLayerChange::Children,
 281 WebKit::WCLayerChange::MaskLayer,
 282 WebKit::WCLayerChange::ReplicaLayer,
 283 WebKit::WCLayerChange::Geometry,
 284 WebKit::WCLayerChange::Preserves3D,
 285 WebKit::WCLayerChange::ContentsVisible,
 286 WebKit::WCLayerChange::BackfaceVisibility,
 287 WebKit::WCLayerChange::MasksToBounds,
 288 WebKit::WCLayerChange::SolidColor,
 289 WebKit::WCLayerChange::DebugVisuals,
 290 WebKit::WCLayerChange::RepaintCount,
 291 WebKit::WCLayerChange::ContentsRect,
 292 WebKit::WCLayerChange::ContentsClippingRect,
 293 WebKit::WCLayerChange::Opacity,
 294 WebKit::WCLayerChange::BackingStore,
 295 WebKit::WCLayerChange::Transform,
 296 WebKit::WCLayerChange::ChildrenTransform,
 297 WebKit::WCLayerChange::Filters,
 298 WebKit::WCLayerChange::BackdropFilters,
 299 WebKit::WCLayerChange::PlatformLayer
 300 >;
 301};
 302
 303} // namespace WebKit

Source/cmake/OptionsWinCairo.cmake

@@SET_AND_EXPOSE_TO_BUILD(USE_CAIRO ON)
4444SET_AND_EXPOSE_TO_BUILD(USE_CF ON)
4545SET_AND_EXPOSE_TO_BUILD(USE_CURL ON)
4646SET_AND_EXPOSE_TO_BUILD(USE_GRAPHICS_LAYER_TEXTURE_MAPPER ON)
 47SET_AND_EXPOSE_TO_BUILD(USE_GRAPHICS_LAYER_WC ON)
4748SET_AND_EXPOSE_TO_BUILD(USE_EGL ON)
4849SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES ON)
4950SET_AND_EXPOSE_TO_BUILD(HAVE_OPENGL_ES_3 ON)