[GPUP][PlayStation] Enable GPU Process
https://bugs.webkit.org/show_bug.cgi?id=209865

Reviewed by Eric Carlson.

.:

Enable GPU Process for development builds as an experimental feature.

* Source/cmake/OptionsPlayStation.cmake:

Source/WebKit:

A generic LayerHostingContext is provided in this patch. It may make sense for
this to be platform specific but it may also be possible to have some shared
implementation with Cocoa ports. Once there are more implementations that
can be decided.

Add stubs for building out the GPU Process on the PlayStation port. No
implementation is provided at this time but the GPU Process will compile
and link with these changes.

* GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp: Added.
(WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
(WebKit::RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable):
(WebKit::RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged):
(WebKit::RemoteMediaPlayerProxy::enterFullscreen):
(WebKit::RemoteMediaPlayerProxy::exitFullscreen):
* GPUProcess/playstation/GPUProcessMainPlayStation.cpp: Added.
(WebKit::initializeAuxiliaryProcess<GPUProcess>):
(WebKit::GPUProcessMain):
* GPUProcess/playstation/GPUProcessPlayStation.cpp: Added.
(WebKit::GPUProcess::initializeProcess):
(WebKit::GPUProcess::initializeProcessName):
(WebKit::GPUProcess::initializeSandbox):
* Platform/generic/LayerHostingContext.h: Added.
* PlatformPlayStation.cmake:
* WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp: Added.
(WebKit::createVideoLayerRemote):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@259360 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index 583a65c..226ffee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2020-04-01  Don Olmstead  <don.olmstead@sony.com>
 
+        [GPUP][PlayStation] Enable GPU Process
+        https://bugs.webkit.org/show_bug.cgi?id=209865
+
+        Reviewed by Eric Carlson.
+
+        Enable GPU Process for development builds as an experimental feature.
+
+        * Source/cmake/OptionsPlayStation.cmake:
+
+2020-04-01  Don Olmstead  <don.olmstead@sony.com>
+
         [PlayStation] Use OBJECT libraries for WebCore and PAL
         https://bugs.webkit.org/show_bug.cgi?id=209835
 
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 40cf214..78eea7f 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,5 +1,39 @@
 2020-04-01  Don Olmstead  <don.olmstead@sony.com>
 
+        [GPUP][PlayStation] Enable GPU Process
+        https://bugs.webkit.org/show_bug.cgi?id=209865
+
+        Reviewed by Eric Carlson.
+
+        A generic LayerHostingContext is provided in this patch. It may make sense for
+        this to be platform specific but it may also be possible to have some shared
+        implementation with Cocoa ports. Once there are more implementations that
+        can be decided.
+
+        Add stubs for building out the GPU Process on the PlayStation port. No
+        implementation is provided at this time but the GPU Process will compile
+        and link with these changes.
+
+        * GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp: Added.
+        (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable):
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged):
+        (WebKit::RemoteMediaPlayerProxy::enterFullscreen):
+        (WebKit::RemoteMediaPlayerProxy::exitFullscreen):
+        * GPUProcess/playstation/GPUProcessMainPlayStation.cpp: Added.
+        (WebKit::initializeAuxiliaryProcess<GPUProcess>):
+        (WebKit::GPUProcessMain):
+        * GPUProcess/playstation/GPUProcessPlayStation.cpp: Added.
+        (WebKit::GPUProcess::initializeProcess):
+        (WebKit::GPUProcess::initializeProcessName):
+        (WebKit::GPUProcess::initializeSandbox):
+        * Platform/generic/LayerHostingContext.h: Added.
+        * PlatformPlayStation.cmake:
+        * WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp: Added.
+        (WebKit::createVideoLayerRemote):
+
+2020-04-01  Don Olmstead  <don.olmstead@sony.com>
+
         [PlayStation] Use OBJECT libraries for WebCore and PAL
         https://bugs.webkit.org/show_bug.cgi?id=209835
 
diff --git a/Source/WebKit/GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp b/Source/WebKit/GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp
new file mode 100644
index 0000000..1f21325
--- /dev/null
+++ b/Source/WebKit/GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp
@@ -0,0 +1,63 @@
+/*
+* Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+#include "RemoteMediaPlayerProxy.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "LayerHostingContext.h"
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void RemoteMediaPlayerProxy::prepareForPlayback(bool, WebCore::MediaPlayerEnums::Preload, bool, bool, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&)
+{
+    notImplemented();
+}
+
+void RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable()
+{
+    notImplemented();
+}
+
+void RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged()
+{
+    notImplemented();
+}
+
+void RemoteMediaPlayerProxy::enterFullscreen(CompletionHandler<void()>&& completionHandler)
+{
+    notImplemented();
+}
+
+void RemoteMediaPlayerProxy::exitFullscreen(CompletionHandler<void()>&& completionHandler)
+{
+    notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS)
diff --git a/Source/WebKit/GPUProcess/playstation/GPUProcessMainPlayStation.cpp b/Source/WebKit/GPUProcess/playstation/GPUProcessMainPlayStation.cpp
new file mode 100644
index 0000000..74e18ff
--- /dev/null
+++ b/Source/WebKit/GPUProcess/playstation/GPUProcessMainPlayStation.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUProcessMain.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "AuxiliaryProcessMain.h"
+#include "GPUProcess.h"
+
+namespace WebKit {
+
+static RefPtr<GPUProcess> globalGPUProcess;
+
+class GPUProcessMainPlayStation final: public AuxiliaryProcessMainBase {
+public:
+    bool platformInitialize() override
+    {
+        return true;
+    }
+};
+
+template<>
+void initializeAuxiliaryProcess<GPUProcess>(AuxiliaryProcessInitializationParameters&& parameters)
+{
+    static NeverDestroyed<GPUProcess> gpuProcess(WTFMove(parameters));
+    globalGPUProcess = &gpuProcess.get();
+}
+
+int GPUProcessMain(int argc, char** argv)
+{
+    return AuxiliaryProcessMain<GPUProcess, GPUProcessMainPlayStation>(argc, argv);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS)
diff --git a/Source/WebKit/GPUProcess/playstation/GPUProcessPlayStation.cpp b/Source/WebKit/GPUProcess/playstation/GPUProcessPlayStation.cpp
new file mode 100644
index 0000000..e7cbedf
--- /dev/null
+++ b/Source/WebKit/GPUProcess/playstation/GPUProcessPlayStation.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUProcess.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUProcessCreationParameters.h"
+
+namespace WebKit {
+
+void GPUProcess::initializeProcess(const AuxiliaryProcessInitializationParameters&)
+{
+}
+
+void GPUProcess::initializeProcessName(const AuxiliaryProcessInitializationParameters&)
+{
+}
+
+void GPUProcess::initializeSandbox(const AuxiliaryProcessInitializationParameters&, SandboxInitializationParameters&)
+{
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS)
diff --git a/Source/WebKit/Platform/generic/LayerHostingContext.h b/Source/WebKit/Platform/generic/LayerHostingContext.h
new file mode 100644
index 0000000..3e7f872
--- /dev/null
+++ b/Source/WebKit/Platform/generic/LayerHostingContext.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebKit {
+
+using LayerHostingContextID = uint32_t;
+
+class LayerHostingContext {
+    WTF_MAKE_NONCOPYABLE(LayerHostingContext); WTF_MAKE_FAST_ALLOCATED;
+public:
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit/PlatformPlayStation.cmake b/Source/WebKit/PlatformPlayStation.cmake
index b3d4262..484e413 100644
--- a/Source/WebKit/PlatformPlayStation.cmake
+++ b/Source/WebKit/PlatformPlayStation.cmake
@@ -21,6 +21,11 @@
 )
 
 list(APPEND WebKit_SOURCES
+    GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp
+
+    GPUProcess/playstation/GPUProcessMainPlayStation.cpp
+    GPUProcess/playstation/GPUProcessPlayStation.cpp
+
     NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
     NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp
 
@@ -100,6 +105,8 @@
     UIProcess/playstation/WebPageProxyPlayStation.cpp
     UIProcess/playstation/WebProcessPoolPlayStation.cpp
 
+    WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp
+
     WebProcess/InjectedBundle/playstation/InjectedBundlePlayStation.cpp
 
     WebProcess/WebCoreSupport/curl/WebFrameNetworkingContext.cpp
@@ -121,6 +128,7 @@
 list(APPEND WebKit_INCLUDE_DIRECTORIES
     "${WEBKIT_DIR}/NetworkProcess/curl"
     "${WEBKIT_DIR}/Platform/IPC/unix"
+    "${WEBKIT_DIR}/Platform/generic"
     "${WEBKIT_DIR}/Shared/CoordinatedGraphics"
     "${WEBKIT_DIR}/Shared/CoordinatedGraphics/threadedcompositor"
     "${WEBKIT_DIR}/Shared/libwpe"
diff --git a/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp b/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp
new file mode 100644
index 0000000..776ca5c
--- /dev/null
+++ b/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "VideoLayerRemote.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote* mediaPlayerPrivateRemote, LayerHostingContextID contextId)
+{
+    notImplemented();
+    return nullptr;
+}
+
+}
+
+#endif
diff --git a/Source/cmake/OptionsPlayStation.cmake b/Source/cmake/OptionsPlayStation.cmake
index 983246e..6a824f6 100644
--- a/Source/cmake/OptionsPlayStation.cmake
+++ b/Source/cmake/OptionsPlayStation.cmake
@@ -33,6 +33,7 @@
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_PAINTING_API PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TYPED_OM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS_LEVEL_2 PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GPU_PROCESS PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LAYOUT_FORMATTING_CONTEXT PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SERVICE_WORKER PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})