[Threaded Compositor] Remove platform ifdefs from threaded compositor implementation
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 12:32:44 +0000 (12:32 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 12:32:44 +0000 (12:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172265

Reviewed by Žan Doberšek.

Source/WebCore:

Remove PlatformDisplayWPE::EGLTarget.

* platform/graphics/wpe/PlatformDisplayWPE.cpp:
* platform/graphics/wpe/PlatformDisplayWPE.h:

Source/WebKit2:

Add AcceleratedSurfaceWPE implementation that is equivalent to the PlatformDisplayWPE::EGLTarget. Since WPE needs the
surface to be initialized/finalized in the compositing thread, two new virtual methods has been added to
AcceleratedSurface initialize/finalize that are only implemented by WPE. The threaded compositor no longer
receives a native surface handle as contructor parameter, it now asks the client for it from the compositing
thread, right after it's created.

* PlatformWPE.cmake:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::create): Remove ativeSurfaceHandle parameter.
(WebKit::ThreadedCompositor::ThreadedCompositor): Initialize m_nativeSurfaceHandle from the compositing thread
asking the client for it.
(WebKit::ThreadedCompositor::createGLContext): Remove the WPE implementation.
(WebKit::ThreadedCompositor::invalidate): Notify the client that the GL context has been destroyed.
(WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Remove GTK ifdefs.
(WebKit::ThreadedCompositor::setViewportSize): Remove WPE implementation.
(WebKit::ThreadedCompositor::renderLayerTree): Notify the client the frame will be rendered, and when it has
been rendered.
(WebKit::ThreadedCompositor::frameComplete): Remove WPE ifdefs.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* WebProcess/WebPage/AcceleratedSurface.cpp:
(WebKit::AcceleratedSurface::create): Add client parameter.
(WebKit::AcceleratedSurface::AcceleratedSurface): Create a AcceleratedSurfaceWPE if display is WPE.
* WebProcess/WebPage/AcceleratedSurface.h:
(WebKit::AcceleratedSurface::surfaceID):
(WebKit::AcceleratedSurface::initialize):
(WebKit::AcceleratedSurface::finalize):
(WebKit::AcceleratedSurface::willRenderFrame):
(WebKit::AcceleratedSurface::didRenderFrame):
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Pass this as client of AcceleratedSurface.
(WebKit::ThreadedCoordinatedLayerTreeHost::frameComplete): Notify the compositor.
(WebKit::ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing): Initialize the surface and return
the window handler.
(WebKit::ThreadedCoordinatedLayerTreeHost::didDestroyGLContext): Finalize the surface.
(WebKit::ThreadedCoordinatedLayerTreeHost::willRenderFrame): Notify the surface.
(WebKit::ThreadedCoordinatedLayerTreeHost::didRenderFrame): Ditto.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp:
(WebKit::AcceleratedSurfaceWayland::create): Add client parameter.
(WebKit::AcceleratedSurfaceWayland::AcceleratedSurfaceWayland): Ditto.
(WebKit::AcceleratedSurfaceWayland::didRenderFrame): Call Client::frameComplete().
* WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h:
* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp:
(WebKit::AcceleratedSurfaceX11::create): Add client parameter.
(WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11): Ditto.
(WebKit::AcceleratedSurfaceX11::didRenderFrame): Call Client::frameComplete().
* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h:
* WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp: Added.
(WebKit::AcceleratedSurfaceWPE::create):
(WebKit::AcceleratedSurfaceWPE::AcceleratedSurfaceWPE):
(WebKit::AcceleratedSurfaceWPE::~AcceleratedSurfaceWPE):
(WebKit::AcceleratedSurfaceWPE::initialize):
(WebKit::AcceleratedSurfaceWPE::finalize):
(WebKit::AcceleratedSurfaceWPE::window):
(WebKit::AcceleratedSurfaceWPE::surfaceID):
(WebKit::AcceleratedSurfaceWPE::resize):
(WebKit::AcceleratedSurfaceWPE::willRenderFrame):
(WebKit::AcceleratedSurfaceWPE::didRenderFrame):
* WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h: Copied from Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.cpp
Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.h
Source/WebKit2/ChangeLog
Source/WebKit2/PlatformWPE.cmake
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit2/WebProcess/WebPage/AcceleratedSurface.cpp
Source/WebKit2/WebProcess/WebPage/AcceleratedSurface.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp
Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h
Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp
Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h
Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h [new file with mode: 0644]

index 9865461..b491e6c 100644 (file)
@@ -1,3 +1,15 @@
+2017-05-19  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [Threaded Compositor] Remove platform ifdefs from threaded compositor implementation
+        https://bugs.webkit.org/show_bug.cgi?id=172265
+
+        Reviewed by Žan Doberšek.
+
+        Remove PlatformDisplayWPE::EGLTarget.
+
+        * platform/graphics/wpe/PlatformDisplayWPE.cpp:
+        * platform/graphics/wpe/PlatformDisplayWPE.h:
+
 2017-05-19  Jer Noble  <jer.noble@apple.com>
 
         Unreviewed build fix; add undefined functions and constants to the CoreMediaSoftLink.h, and use the
index fda8bbc..6a0970b 100644 (file)
@@ -55,64 +55,11 @@ void PlatformDisplayWPE::initialize(int hostFd)
     PlatformDisplay::initializeEGLDisplay();
 }
 
-std::unique_ptr<PlatformDisplayWPE::EGLTarget> PlatformDisplayWPE::createEGLTarget(EGLTarget::Client& client, int hostFd)
-{
-    return std::make_unique<EGLTarget>(*this, client, hostFd);
-}
-
 std::unique_ptr<PlatformDisplayWPE::EGLOffscreenTarget> PlatformDisplayWPE::createEGLOffscreenTarget()
 {
     return std::make_unique<EGLOffscreenTarget>(*this);
 }
 
-PlatformDisplayWPE::EGLTarget::EGLTarget(const PlatformDisplayWPE& display, PlatformDisplayWPE::EGLTarget::Client& client, int hostFd)
-    : m_display(display)
-    , m_client(client)
-{
-    m_backend = wpe_renderer_backend_egl_target_create(hostFd);
-
-    static struct wpe_renderer_backend_egl_target_client s_client = {
-        // frame_complete
-        [](void* data)
-        {
-            auto& surface = *reinterpret_cast<EGLTarget*>(data);
-            surface.m_client.frameComplete();
-        },
-    };
-    wpe_renderer_backend_egl_target_set_client(m_backend, &s_client, this);
-}
-
-PlatformDisplayWPE::EGLTarget::~EGLTarget()
-{
-    wpe_renderer_backend_egl_target_destroy(m_backend);
-}
-
-void PlatformDisplayWPE::EGLTarget::initialize(const IntSize& size)
-{
-    wpe_renderer_backend_egl_target_initialize(m_backend, m_display.m_backend,
-        std::max(0, size.width()), std::max(0, size.height()));
-}
-
-EGLNativeWindowType PlatformDisplayWPE::EGLTarget::nativeWindow() const
-{
-    return wpe_renderer_backend_egl_target_get_native_window(m_backend);
-}
-
-void PlatformDisplayWPE::EGLTarget::resize(const IntSize& size)
-{
-    wpe_renderer_backend_egl_target_resize(m_backend, std::max(0, size.width()), std::max(0, size.height()));
-}
-
-void PlatformDisplayWPE::EGLTarget::frameWillRender()
-{
-    wpe_renderer_backend_egl_target_frame_will_render(m_backend);
-}
-
-void PlatformDisplayWPE::EGLTarget::frameRendered()
-{
-    wpe_renderer_backend_egl_target_frame_rendered(m_backend);
-}
-
 PlatformDisplayWPE::EGLOffscreenTarget::EGLOffscreenTarget(const PlatformDisplayWPE& display)
 {
     m_target = wpe_renderer_backend_egl_offscreen_target_create();
index 59b152e..6fcb31f 100644 (file)
@@ -50,30 +50,6 @@ public:
 
     void initialize(int);
 
-    class EGLTarget {
-    public:
-        class Client {
-        public:
-            virtual void frameComplete() = 0;
-        };
-
-        EGLTarget(const PlatformDisplayWPE&, Client&, int);
-        ~EGLTarget();
-
-        void initialize(const IntSize&);
-        EGLNativeWindowType nativeWindow() const;
-
-        void resize(const IntSize&);
-
-        void frameWillRender();
-        void frameRendered();
-
-    private:
-        const PlatformDisplayWPE& m_display;
-        Client& m_client;
-        struct wpe_renderer_backend_egl_target* m_backend;
-    };
-
     class EGLOffscreenTarget {
     public:
         EGLOffscreenTarget(const PlatformDisplayWPE&);
@@ -85,9 +61,10 @@ public:
         struct wpe_renderer_backend_egl_offscreen_target* m_target;
     };
 
-    std::unique_ptr<EGLTarget> createEGLTarget(EGLTarget::Client&, int);
     std::unique_ptr<EGLOffscreenTarget> createEGLOffscreenTarget();
 
+    struct wpe_renderer_backend_egl* backend() const { return m_backend; }
+
 private:
     Type type() const override { return PlatformDisplay::Type::WPE; }
 
index 7289e44..3af2dfc 100644 (file)
@@ -1,3 +1,70 @@
+2017-05-19  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [Threaded Compositor] Remove platform ifdefs from threaded compositor implementation
+        https://bugs.webkit.org/show_bug.cgi?id=172265
+
+        Reviewed by Žan Doberšek.
+
+        Add AcceleratedSurfaceWPE implementation that is equivalent to the PlatformDisplayWPE::EGLTarget. Since WPE needs the
+        surface to be initialized/finalized in the compositing thread, two new virtual methods has been added to
+        AcceleratedSurface initialize/finalize that are only implemented by WPE. The threaded compositor no longer
+        receives a native surface handle as contructor parameter, it now asks the client for it from the compositing
+        thread, right after it's created.
+
+        * PlatformWPE.cmake:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::create): Remove ativeSurfaceHandle parameter.
+        (WebKit::ThreadedCompositor::ThreadedCompositor): Initialize m_nativeSurfaceHandle from the compositing thread
+        asking the client for it.
+        (WebKit::ThreadedCompositor::createGLContext): Remove the WPE implementation.
+        (WebKit::ThreadedCompositor::invalidate): Notify the client that the GL context has been destroyed.
+        (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Remove GTK ifdefs.
+        (WebKit::ThreadedCompositor::setViewportSize): Remove WPE implementation.
+        (WebKit::ThreadedCompositor::renderLayerTree): Notify the client the frame will be rendered, and when it has
+        been rendered.
+        (WebKit::ThreadedCompositor::frameComplete): Remove WPE ifdefs.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * WebProcess/WebPage/AcceleratedSurface.cpp:
+        (WebKit::AcceleratedSurface::create): Add client parameter.
+        (WebKit::AcceleratedSurface::AcceleratedSurface): Create a AcceleratedSurfaceWPE if display is WPE.
+        * WebProcess/WebPage/AcceleratedSurface.h:
+        (WebKit::AcceleratedSurface::surfaceID):
+        (WebKit::AcceleratedSurface::initialize):
+        (WebKit::AcceleratedSurface::finalize):
+        (WebKit::AcceleratedSurface::willRenderFrame):
+        (WebKit::AcceleratedSurface::didRenderFrame):
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Pass this as client of AcceleratedSurface.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::frameComplete): Notify the compositor.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing): Initialize the surface and return
+        the window handler.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::didDestroyGLContext): Finalize the surface.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::willRenderFrame): Notify the surface.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::didRenderFrame): Ditto.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp:
+        (WebKit::AcceleratedSurfaceWayland::create): Add client parameter.
+        (WebKit::AcceleratedSurfaceWayland::AcceleratedSurfaceWayland): Ditto.
+        (WebKit::AcceleratedSurfaceWayland::didRenderFrame): Call Client::frameComplete().
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h:
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp:
+        (WebKit::AcceleratedSurfaceX11::create): Add client parameter.
+        (WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11): Ditto.
+        (WebKit::AcceleratedSurfaceX11::didRenderFrame): Call Client::frameComplete().
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h:
+        * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp: Added.
+        (WebKit::AcceleratedSurfaceWPE::create):
+        (WebKit::AcceleratedSurfaceWPE::AcceleratedSurfaceWPE):
+        (WebKit::AcceleratedSurfaceWPE::~AcceleratedSurfaceWPE):
+        (WebKit::AcceleratedSurfaceWPE::initialize):
+        (WebKit::AcceleratedSurfaceWPE::finalize):
+        (WebKit::AcceleratedSurfaceWPE::window):
+        (WebKit::AcceleratedSurfaceWPE::surfaceID):
+        (WebKit::AcceleratedSurfaceWPE::resize):
+        (WebKit::AcceleratedSurfaceWPE::willRenderFrame):
+        (WebKit::AcceleratedSurfaceWPE::didRenderFrame):
+        * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h: Copied from Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h.
+
 2017-05-19  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC][DFG][DOMJIT] Extend CheckDOM to CheckSubClass
index 4974329..e60db1a 100644 (file)
@@ -162,6 +162,7 @@ list(APPEND WebKit2_SOURCES
 
     WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
 
+    WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp
     WebProcess/WebPage/wpe/CompositingManager.cpp
     WebProcess/WebPage/wpe/DrawingAreaWPE.cpp
     WebProcess/WebPage/wpe/WebInspectorUIWPE.cpp
index e58e193..946f636 100644 (file)
@@ -44,16 +44,15 @@ using namespace WebCore;
 
 namespace WebKit {
 
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
 {
-    return adoptRef(*new ThreadedCompositor(client, webPage, viewportSize, scaleFactor, nativeSurfaceHandle, doFrameSync, paintFlags));
+    return adoptRef(*new ThreadedCompositor(client, webPage, viewportSize, scaleFactor, doFrameSync, paintFlags));
 }
 
-ThreadedCompositor::ThreadedCompositor(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ThreadedCompositor::ThreadedCompositor(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
     : m_client(client)
     , m_viewportSize(viewportSize)
     , m_scaleFactor(scaleFactor)
-    , m_nativeSurfaceHandle(nativeSurfaceHandle)
     , m_doFrameSync(doFrameSync)
     , m_paintFlags(paintFlags)
     , m_needsResize(!viewportSize.isEmpty())
@@ -65,21 +64,14 @@ ThreadedCompositor::ThreadedCompositor(Client& client, WebPage& webPage, const I
     m_clientRendersNextFrame.store(false);
     m_coordinateUpdateCompletionWithClient.store(false);
 
-#if PLATFORM(WPE)
-    m_compositingManager.establishConnection(webPage);
-#endif
-
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
         m_scene = adoptRef(new CoordinatedGraphicsScene(this));
-#if PLATFORM(GTK)
+        m_nativeSurfaceHandle = m_client.nativeSurfaceHandleForCompositing();
         if (m_nativeSurfaceHandle) {
             createGLContext();
             m_scene->setActive(true);
         } else
             m_scene->setActive(false);
-#elif PLATFORM(WPE)
-        m_scene->setActive(true);
-#endif
     });
 }
 
@@ -91,7 +83,6 @@ void ThreadedCompositor::createGLContext()
 {
     ASSERT(!isMainThread());
 
-#if PLATFORM(GTK)
     ASSERT(m_nativeSurfaceHandle);
 
     m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
@@ -102,22 +93,6 @@ void ThreadedCompositor::createGLContext()
         if (m_context->makeContextCurrent())
             m_context->swapInterval(0);
     }
-#endif
-
-#if PLATFORM(WPE)
-    auto& platformDisplay = PlatformDisplay::sharedDisplay();
-    RELEASE_ASSERT(is<PlatformDisplayWPE>(platformDisplay));
-    m_target = downcast<PlatformDisplayWPE>(platformDisplay).createEGLTarget(*this, m_compositingManager.releaseConnectionFd());
-    ASSERT(m_target);
-    m_target->initialize(m_viewportSize);
-
-    m_context = GLContext::createContextForWindow(m_target->nativeWindow(), &platformDisplay);
-    if (!m_context)
-        return;
-
-    if (!m_context->makeContextCurrent())
-        return;
-#endif
 }
 
 void ThreadedCompositor::invalidate()
@@ -130,9 +105,7 @@ void ThreadedCompositor::invalidate()
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
         m_scene->purgeGLResources();
         m_context = nullptr;
-#if PLATFORM(WPE)
-        m_target = nullptr;
-#endif
+        m_client.didDestroyGLContext();
         m_scene = nullptr;
     });
     m_compositingRunLoop = nullptr;
@@ -140,7 +113,6 @@ void ThreadedCompositor::invalidate()
 
 void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
 {
-#if PLATFORM(GTK)
     m_compositingRunLoop->stopUpdates();
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), handle] {
         // A new native handle can't be set without destroying the previous one first if any.
@@ -154,7 +126,6 @@ void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
             m_context = nullptr;
         }
     });
-#endif
 }
 
 void ThreadedCompositor::setScaleFactor(float scale)
@@ -178,10 +149,6 @@ void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scal
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), viewportSize, scale] {
         m_viewportSize = viewportSize;
-#if PLATFORM(WPE)
-        if (m_target)
-            m_target->resize(viewportSize);
-#endif
         m_scaleFactor = scale;
         m_needsResize = true;
         m_compositingRunLoop->scheduleUpdate();
@@ -226,17 +193,10 @@ void ThreadedCompositor::renderLayerTree()
     if (!m_scene || !m_scene->isActive())
         return;
 
-#if PLATFORM(WPE)
-    if (!m_context)
-        createGLContext();
-#endif
-
     if (!m_context || !m_context->makeContextCurrent())
         return;
 
-#if PLATFORM(WPE)
-    m_target->frameWillRender();
-#endif
+    m_client.willRenderFrame();
 
     if (m_needsResize) {
         glViewport(0, 0, m_viewportSize.width(), m_viewportSize.height());
@@ -257,14 +217,8 @@ void ThreadedCompositor::renderLayerTree()
 
     m_context->swapBuffers();
 
-#if PLATFORM(WPE)
-    m_target->frameRendered();
-#endif
-
-#if PLATFORM(GTK)
     if (m_scene->isActive())
-        sceneUpdateFinished();
-#endif
+        m_client.didRenderFrame();
 }
 
 void ThreadedCompositor::sceneUpdateFinished()
@@ -334,13 +288,11 @@ void ThreadedCompositor::coordinateUpdateCompletionWithClient()
 }
 #endif
 
-#if PLATFORM(WPE)
 void ThreadedCompositor::frameComplete()
 {
     ASSERT(!isMainThread());
     sceneUpdateFinished();
 }
-#endif
 
 }
 #endif // USE(COORDINATED_GRAPHICS_THREADED)
index 9a217c6..98a38e7 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ThreadedCompositor_h
-#define ThreadedCompositor_h
+#pragma once
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
 
 #include <WebCore/DisplayRefreshMonitor.h>
 #endif
 
-#if PLATFORM(WPE)
-#include "CompositingManager.h"
-#include <WebCore/PlatformDisplayWPE.h>
-#endif
-
 namespace WebCore {
 struct CoordinatedGraphicsState;
 }
@@ -58,11 +52,7 @@ class CoordinatedGraphicsSceneClient;
 class ThreadedDisplayRefreshMonitor;
 class WebPage;
 
-class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor>
-#if PLATFORM(WPE)
-    , public WebCore::PlatformDisplayWPE::EGLTarget::Client
-#endif
-    {
+class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
     WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -70,11 +60,17 @@ public:
     public:
         virtual void renderNextFrame() = 0;
         virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
+
+        virtual uint64_t nativeSurfaceHandleForCompositing() = 0;
+        virtual void didDestroyGLContext() = 0;
+
+        virtual void willRenderFrame() = 0;
+        virtual void didRenderFrame() = 0;
     };
 
     enum class ShouldDoFrameSync { No, Yes };
 
-    static Ref<ThreadedCompositor> create(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+    static Ref<ThreadedCompositor> create(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
     virtual ~ThreadedCompositor();
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -97,19 +93,16 @@ public:
     void coordinateUpdateCompletionWithClient();
 #endif
 
+    void frameComplete();
+
 private:
-    ThreadedCompositor(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+    ThreadedCompositor(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
 
     // CoordinatedGraphicsSceneClient
     void renderNextFrame() override;
     void updateViewport() override;
     void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
 
-#if PLATFORM(WPE)
-    // WebCore::PlatformDisplayWPE::Surface::Client
-    void frameComplete() override;
-#endif
-
     void renderLayerTree();
     void sceneUpdateFinished();
 
@@ -117,12 +110,6 @@ private:
 
     Client& m_client;
     RefPtr<CoordinatedGraphicsScene> m_scene;
-
-#if PLATFORM(WPE)
-    CompositingManager m_compositingManager;
-    std::unique_ptr<WebCore::PlatformDisplayWPE::EGLTarget> m_target;
-#endif
-
     std::unique_ptr<WebCore::GLContext> m_context;
 
     WebCore::IntSize m_viewportSize;
@@ -147,6 +134,5 @@ private:
 
 } // namespace WebKit
 
-#endif
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
 
-#endif // ThreadedCompositor_h
index 6b20cd8..26faeeb 100644 (file)
 #include "AcceleratedSurfaceX11.h"
 #endif
 
+#if PLATFORM(WPE)
+#include "AcceleratedSurfaceWPE.h"
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
 
-std::unique_ptr<AcceleratedSurface> AcceleratedSurface::create(WebPage& webPage)
+std::unique_ptr<AcceleratedSurface> AcceleratedSurface::create(WebPage& webPage, Client& client)
 {
 #if PLATFORM(WAYLAND)
     if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
-        return AcceleratedSurfaceWayland::create(webPage);
+        return AcceleratedSurfaceWayland::create(webPage, client);
 #endif
 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11)
-        return AcceleratedSurfaceX11::create(webPage);
+        return AcceleratedSurfaceX11::create(webPage, client);
+#endif
+#if PLATFORM(WPE)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::WPE)
+        return AcceleratedSurfaceWPE::create(webPage, client);
 #endif
     return nullptr;
 }
 
-AcceleratedSurface::AcceleratedSurface(WebPage& webPage)
+AcceleratedSurface::AcceleratedSurface(WebPage& webPage, Client& client)
     : m_webPage(webPage)
+    , m_client(client)
     , m_size(webPage.size())
 {
     m_size.scale(m_webPage.deviceScaleFactor());
index 26b4c8a..29ee958 100644 (file)
@@ -35,18 +35,29 @@ class WebPage;
 class AcceleratedSurface {
     WTF_MAKE_NONCOPYABLE(AcceleratedSurface); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<AcceleratedSurface> create(WebPage&);
+    class Client {
+    public:
+        virtual void frameComplete() = 0;
+    };
+
+    static std::unique_ptr<AcceleratedSurface> create(WebPage&, Client&);
     virtual ~AcceleratedSurface() = default;
 
     virtual uint64_t window() const { ASSERT_NOT_REACHED(); return 0; }
-    virtual uint64_t surfaceID() const { ASSERT_NOT_REACHED(); return 0; };
+    virtual uint64_t surfaceID() const { ASSERT_NOT_REACHED(); return 0; }
     virtual bool resize(const WebCore::IntSize&);
     virtual bool shouldPaintMirrored() const { return false; }
 
+    virtual void initialize() { }
+    virtual void finalize() { }
+    virtual void willRenderFrame() { }
+    virtual void didRenderFrame() { }
+
 protected:
-    AcceleratedSurface(WebPage&);
+    AcceleratedSurface(WebPage&, Client&);
 
     WebPage& m_webPage;
+    Client& m_client;
     WebCore::IntSize m_size;
 };
 
index e2c6b5b..7bed39a 100644 (file)
@@ -52,7 +52,7 @@ ThreadedCoordinatedLayerTreeHost::~ThreadedCoordinatedLayerTreeHost()
 ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage)
     : CoordinatedLayerTreeHost(webPage)
     , m_compositorClient(*this)
-    , m_surface(AcceleratedSurface::create(webPage))
+    , m_surface(AcceleratedSurface::create(webPage, *this))
     , m_viewportController(webPage.size())
 {
     if (FrameView* frameView = m_webPage.mainFrameView()) {
@@ -71,10 +71,7 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP
         if (m_surface->shouldPaintMirrored())
             paintFlags |= TextureMapper::PaintingMirrored;
 
-        // Do not do frame sync when rendering offscreen in the web process to ensure that SwapBuffers never blocks.
-        // Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update,
-        // the compositor will take care of syncing to vblank.
-        m_compositor = ThreadedCompositor::create(m_compositorClient, webPage, scaledSize, scaleFactor, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, webPage, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
         m_layerTreeContext.contextID = m_surface->surfaceID();
     } else
         m_compositor = ThreadedCompositor::create(m_compositorClient, webPage, scaledSize, scaleFactor);
@@ -95,6 +92,38 @@ void ThreadedCoordinatedLayerTreeHost::forceRepaint()
     m_compositor->forceRepaint();
 }
 
+void ThreadedCoordinatedLayerTreeHost::frameComplete()
+{
+    m_compositor->frameComplete();
+}
+
+uint64_t ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing()
+{
+    if (!m_surface)
+        return m_layerTreeContext.contextID;
+
+    m_surface->initialize();
+    return m_surface->window();
+}
+
+void ThreadedCoordinatedLayerTreeHost::didDestroyGLContext()
+{
+    if (m_surface)
+        m_surface->finalize();
+}
+
+void ThreadedCoordinatedLayerTreeHost::willRenderFrame()
+{
+    if (m_surface)
+        m_surface->willRenderFrame();
+}
+
+void ThreadedCoordinatedLayerTreeHost::didRenderFrame()
+{
+    if (m_surface)
+        m_surface->didRenderFrame();
+}
+
 void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
 {
     FrameView* frameView = m_webPage.mainFrameView();
index eaf1c7e..f3eda89 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ThreadedCoordinatedLayerTreeHost_h
-#define ThreadedCoordinatedLayerTreeHost_h
+#pragma once
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
 
+#include "AcceleratedSurface.h"
 #include "CoordinatedLayerTreeHost.h"
 #include "SimpleViewportController.h"
 #include "ThreadedCompositor.h"
@@ -43,10 +43,9 @@ struct CoordinatedGraphicsState;
 
 namespace WebKit {
 
-class AcceleratedSurface;
 class WebPage;
 
-class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
+class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost, public AcceleratedSurface::Client {
 public:
     static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage&);
     virtual ~ThreadedCoordinatedLayerTreeHost();
@@ -92,6 +91,26 @@ private:
             m_layerTreeHost.commitScrollOffset(layerID, offset);
         }
 
+        uint64_t nativeSurfaceHandleForCompositing() override
+        {
+            return m_layerTreeHost.nativeSurfaceHandleForCompositing();
+        }
+
+        void didDestroyGLContext() override
+        {
+            m_layerTreeHost.didDestroyGLContext();
+        }
+
+        void willRenderFrame() override
+        {
+            m_layerTreeHost.willRenderFrame();
+        }
+
+        void didRenderFrame() override
+        {
+            m_layerTreeHost.didRenderFrame();
+        }
+
         ThreadedCoordinatedLayerTreeHost& m_layerTreeHost;
     };
 
@@ -106,6 +125,14 @@ private:
     RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) override;
 #endif
 
+    // AcceleratedSurface::Client
+    void frameComplete() override;
+
+    uint64_t nativeSurfaceHandleForCompositing();
+    void didDestroyGLContext();
+    void willRenderFrame();
+    void didRenderFrame();
+
     enum class DiscardableSyncActions {
         UpdateSize = 1 << 1,
         UpdateViewport = 1 << 2,
@@ -126,5 +153,3 @@ private:
 } // namespace WebKit
 
 #endif // USE(COORDINATED_GRAPHICS_THREADED)
-
-#endif // ThreadedCoordinatedLayerTreeHost_h
index b6f0b87..3cf528a 100644 (file)
@@ -85,13 +85,13 @@ static std::unique_ptr<WaylandCompositorDisplay>& waylandCompositorDisplay()
     return waylandDisplay;
 }
 
-std::unique_ptr<AcceleratedSurfaceWayland> AcceleratedSurfaceWayland::create(WebPage& webPage)
+std::unique_ptr<AcceleratedSurfaceWayland> AcceleratedSurfaceWayland::create(WebPage& webPage, Client& client)
 {
-    return waylandCompositorDisplay() ? std::unique_ptr<AcceleratedSurfaceWayland>(new AcceleratedSurfaceWayland(webPage)) : nullptr;
+    return waylandCompositorDisplay() ? std::unique_ptr<AcceleratedSurfaceWayland>(new AcceleratedSurfaceWayland(webPage, client)) : nullptr;
 }
 
-AcceleratedSurfaceWayland::AcceleratedSurfaceWayland(WebPage& webPage)
-    : AcceleratedSurface(webPage)
+AcceleratedSurfaceWayland::AcceleratedSurfaceWayland(WebPage& webPage, Client& client)
+    : AcceleratedSurface(webPage, client)
     , m_surface(waylandCompositorDisplay()->createSurface())
     , m_window(wl_egl_window_create(m_surface.get(), std::max(1, m_size.width()), std::max(1, m_size.height())))
 {
@@ -112,6 +112,12 @@ bool AcceleratedSurfaceWayland::resize(const IntSize& size)
     return true;
 }
 
+void AcceleratedSurfaceWayland::didRenderFrame()
+{
+    // FIXME: frameComplete() should be called when the frame was actually rendered in the screen.
+    m_client.frameComplete();
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(WAYLAND)
index 38a2fbc..c3c886e 100644 (file)
@@ -37,7 +37,7 @@ namespace WebKit {
 class AcceleratedSurfaceWayland final : public AcceleratedSurface {
     WTF_MAKE_NONCOPYABLE(AcceleratedSurfaceWayland); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<AcceleratedSurfaceWayland> create(WebPage&);
+    static std::unique_ptr<AcceleratedSurfaceWayland> create(WebPage&, Client&);
     ~AcceleratedSurfaceWayland();
 
     uint64_t window() const override { return reinterpret_cast<uint64_t>(m_window); }
@@ -45,8 +45,10 @@ public:
     bool resize(const WebCore::IntSize&) override;
     bool shouldPaintMirrored() const override { return true; }
 
+    void didRenderFrame() override;
+
 private:
-    AcceleratedSurfaceWayland(WebPage&);
+    AcceleratedSurfaceWayland(WebPage&, Client&);
 
     WebCore::WlUniquePtr<struct wl_surface> m_surface;
     struct wl_egl_window* m_window { nullptr };
index b42dd6c..8acd140 100644 (file)
@@ -41,11 +41,11 @@ using namespace WebCore;
 
 namespace WebKit {
 
-std::unique_ptr<AcceleratedSurfaceX11> AcceleratedSurfaceX11::create(WebPage& webPage)
+std::unique_ptr<AcceleratedSurfaceX11> AcceleratedSurfaceX11::create(WebPage& webPage, Client& client)
 {
     if (!downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).supportsXComposite())
         return nullptr;
-    return std::unique_ptr<AcceleratedSurfaceX11>(new AcceleratedSurfaceX11(webPage));
+    return std::unique_ptr<AcceleratedSurfaceX11>(new AcceleratedSurfaceX11(webPage, client));
 }
 
 static GdkVisual* defaultVisual()
@@ -55,8 +55,8 @@ static GdkVisual* defaultVisual()
     return gdk_screen_get_system_visual(gdk_screen_get_default());
 }
 
-AcceleratedSurfaceX11::AcceleratedSurfaceX11(WebPage& webPage)
-    : AcceleratedSurface(webPage)
+AcceleratedSurfaceX11::AcceleratedSurfaceX11(WebPage& webPage, Client& client)
+    : AcceleratedSurface(webPage, client)
     , m_display(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native())
 {
     Screen* screen = DefaultScreenOfDisplay(m_display);
@@ -149,6 +149,12 @@ bool AcceleratedSurfaceX11::resize(const IntSize& size)
     return true;
 }
 
-} // namespace WebCore
+void AcceleratedSurfaceX11::didRenderFrame()
+{
+    // FIXME: frameComplete() should be called when the frame was actually rendered in the screen.
+    m_client.frameComplete();
+}
+
+} // namespace WebKit
 
 #endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
index 740f589..c948fc1 100644 (file)
@@ -41,7 +41,7 @@ class WebPage;
 class AcceleratedSurfaceX11 final : public AcceleratedSurface {
     WTF_MAKE_NONCOPYABLE(AcceleratedSurfaceX11); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<AcceleratedSurfaceX11> create(WebPage&);
+    static std::unique_ptr<AcceleratedSurfaceX11> create(WebPage&, Client&);
     ~AcceleratedSurfaceX11();
 
     uint64_t window() const override { return m_window.get(); }
@@ -49,8 +49,10 @@ public:
     bool resize(const WebCore::IntSize&) override;
     bool shouldPaintMirrored() const override { return false; }
 
+    void didRenderFrame() override;
+
 private:
-    AcceleratedSurfaceX11(WebPage&);
+    AcceleratedSurfaceX11(WebPage&, Client&);
 
     void createPixmap();
 
diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp b/Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp
new file mode 100644 (file)
index 0000000..cbe88dd
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AcceleratedSurfaceWPE.h"
+
+#include "WebPage.h"
+#include <WebCore/PlatformDisplayWPE.h>
+#include <wpe/renderer-backend-egl.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr<AcceleratedSurfaceWPE> AcceleratedSurfaceWPE::create(WebPage& webPage, Client& client)
+{
+    return std::unique_ptr<AcceleratedSurfaceWPE>(new AcceleratedSurfaceWPE(webPage, client));
+}
+
+AcceleratedSurfaceWPE::AcceleratedSurfaceWPE(WebPage& webPage, Client& client)
+    : AcceleratedSurface(webPage, client)
+{
+    m_compositingManager.establishConnection(webPage);
+}
+
+AcceleratedSurfaceWPE::~AcceleratedSurfaceWPE()
+{
+    ASSERT(!m_backend);
+}
+
+void AcceleratedSurfaceWPE::initialize()
+{
+    m_backend = wpe_renderer_backend_egl_target_create(m_compositingManager.releaseConnectionFd());
+    static struct wpe_renderer_backend_egl_target_client s_client = {
+        // frame_complete
+        [](void* data)
+        {
+            auto& surface = *reinterpret_cast<AcceleratedSurfaceWPE*>(data);
+            surface.m_client.frameComplete();
+        },
+    };
+    wpe_renderer_backend_egl_target_set_client(m_backend, &s_client, this);
+    wpe_renderer_backend_egl_target_initialize(m_backend, downcast<PlatformDisplayWPE>(PlatformDisplay::sharedDisplay()).backend(),
+        std::max(0, m_size.width()), std::max(0, m_size.height()));
+}
+
+void AcceleratedSurfaceWPE::finalize()
+{
+    wpe_renderer_backend_egl_target_destroy(m_backend);
+    m_backend = nullptr;
+}
+
+uint64_t AcceleratedSurfaceWPE::window() const
+{
+    ASSERT(m_backend);
+    return reinterpret_cast<uint64_t>(wpe_renderer_backend_egl_target_get_native_window(m_backend));
+}
+
+uint64_t AcceleratedSurfaceWPE::surfaceID() const
+{
+    return m_webPage.pageID();
+}
+
+bool AcceleratedSurfaceWPE::resize(const IntSize& size)
+{
+    ASSERT(m_backend);
+    if (!AcceleratedSurface::resize(size))
+        return false;
+
+    wpe_renderer_backend_egl_target_resize(m_backend, std::max(0, m_size.width()), std::max(0, m_size.height()));
+
+    return true;
+}
+
+void AcceleratedSurfaceWPE::willRenderFrame()
+{
+    ASSERT(m_backend);
+    wpe_renderer_backend_egl_target_frame_will_render(m_backend);
+}
+
+void AcceleratedSurfaceWPE::didRenderFrame()
+{
+    ASSERT(m_backend);
+    wpe_renderer_backend_egl_target_frame_rendered(m_backend);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h b/Source/WebKit2/WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h
new file mode 100644 (file)
index 0000000..4260ff7
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(WPE)
+
+#include "AcceleratedSurface.h"
+#include "CompositingManager.h"
+
+struct wpe_renderer_backend_egl_target;
+
+namespace WebKit {
+
+class WebPage;
+
+class AcceleratedSurfaceWPE final : public AcceleratedSurface {
+    WTF_MAKE_NONCOPYABLE(AcceleratedSurfaceWPE); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr<AcceleratedSurfaceWPE> create(WebPage&, Client&);
+    ~AcceleratedSurfaceWPE();
+
+    uint64_t window() const override;
+    uint64_t surfaceID() const override;
+    bool resize(const WebCore::IntSize&) override;
+    bool shouldPaintMirrored() const override { return false; }
+
+    void initialize() override;
+    void finalize() override;
+    void willRenderFrame() override;
+    void didRenderFrame() override;
+
+private:
+    AcceleratedSurfaceWPE(WebPage&, Client&);
+
+    CompositingManager m_compositingManager;
+    struct wpe_renderer_backend_egl_target* m_backend { nullptr };
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(WPE)