From bc420f937a156050c695cca05216f62f7a46614a Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:02:34 +0530 Subject: [PATCH 01/24] Windowless backend support --- Source/WPE/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/WPE/CMakeLists.txt b/Source/WPE/CMakeLists.txt index 760227b065c97..8b1ccf589b2eb 100644 --- a/Source/WPE/CMakeLists.txt +++ b/Source/WPE/CMakeLists.txt @@ -49,6 +49,10 @@ if (USE_WPE_BACKEND_WESTEROS) add_definitions(-DWPE_BACKEND_WESTEROS=1) endif () +if (USE_WPE_BACKEND_WINDOWLESS) + add_definitions(-DWPE_BACKEND_WINDOWLESS=1) +endif () + if (USE_WPE_BUFFER_MANAGEMENT_GBM) find_package(LibGBM REQUIRED) add_definitions(-DWPE_BUFFER_MANAGEMENT_GBM=1) @@ -84,6 +88,7 @@ set(WPE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Wayland" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Wayland/Protocols" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Westeros" + "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Windowless" ${BCM_HOST_INCLUDE_DIRS} ${GDL_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} @@ -131,6 +136,7 @@ if (USE_WPE_BACKEND_BCM_NEXUS) Source/ViewBackend/BCMNexus/ViewBackendBCMNexus.cpp ) + list(APPEND WPE_LIBRARIES nxclient) endif () if (USE_WPE_BACKEND_BCM_RPI) @@ -176,6 +182,16 @@ if (USE_WPE_BACKEND_WESTEROS) ) endif () +if (USE_WPE_BACKEND_WINDOWLESS) + list(APPEND WPE_SOURCES + Source/Graphics/Westeros/RenderingBackendWesteros.cpp + + Source/ViewBackend/Westeros/ViewBackendWesteros.cpp + Source/ViewBackend/Westeros/WesterosViewbackendInput.cpp + Source/ViewBackend/Windowless/ViewBackendWindowless.cpp + ) +endif () + if (USE_WPE_BUFFER_MANAGEMENT_GBM) list(APPEND WPE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/GBM" From 1991f577049ca6bfef696e888b366752452f3c4c Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:07:33 +0530 Subject: [PATCH 02/24] Windowless backend support --- Source/WPE/Source/Graphics/RenderingBackend.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/WPE/Source/Graphics/RenderingBackend.cpp b/Source/WPE/Source/Graphics/RenderingBackend.cpp index 778aeeb860550..1e6c5b90e2c0e 100644 --- a/Source/WPE/Source/Graphics/RenderingBackend.cpp +++ b/Source/WPE/Source/Graphics/RenderingBackend.cpp @@ -26,6 +26,7 @@ #include "Config.h" +#include #include "RenderingBackendBCMNexus.h" #include "RenderingBackendBCMRPi.h" #include "RenderingBackendIntelCE.h" From b2c15efde302f6878e249c8547a1a3ba2a27a001 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:10:23 +0530 Subject: [PATCH 03/24] Windowless backend support --- Source/WPE/Source/ViewBackend/ViewBackend.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/WPE/Source/ViewBackend/ViewBackend.cpp b/Source/WPE/Source/ViewBackend/ViewBackend.cpp index df169a9b00a33..45904c93a86cf 100644 --- a/Source/WPE/Source/ViewBackend/ViewBackend.cpp +++ b/Source/WPE/Source/ViewBackend/ViewBackend.cpp @@ -31,6 +31,9 @@ #include "ViewBackendBCMRPi.h" #include "ViewBackendIntelCE.h" #include "ViewBackendWesteros.h" +#if WPE_BACKEND(WINDOWLESS) +#include "ViewBackendWindowless.h" +#endif #include #include #include @@ -80,6 +83,11 @@ std::unique_ptr ViewBackend::create() return std::unique_ptr(new ViewBackendWesteros); #endif +#if WPE_BACKEND(WINDOWLESS) + if (!backendEnv || !std::strcmp(backendEnv, "windowless")) + return std::unique_ptr(new ViewBackendWindowless); +#endif + fprintf(stderr, "ViewBackend: no usable backend found, will crash.\n"); return nullptr; } From 817f2fc449f05f09ce51ef3918bb026e531d7343 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:12:49 +0530 Subject: [PATCH 04/24] Windowless backend support --- .../Windowless/ViewBackendWindowless.h | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.h diff --git a/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.h b/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.h new file mode 100644 index 0000000000000..179b6413df1f0 --- /dev/null +++ b/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015 Igalia S.L. + * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * HOLDER 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. + */ + +#ifndef WPE_ViewBackend_ViewBackendWindowless_h +#define WPE_ViewBackend_ViewBackendWindowless_h + +#if WPE_BACKEND(WINDOWLESS) + +#include + +#include + +namespace WPE { + +namespace Input { +class Client; +} + +namespace ViewBackend { + +class Client; + +class ViewBackendWindowless final : public ViewBackend { +public: + ViewBackendWindowless(); + virtual ~ViewBackendWindowless(); + + std::pair authenticate() override { return { nullptr, 0 }; }; + uint32_t constructRenderingTarget(uint32_t, uint32_t) override; + void commitBuffer(int, const uint8_t* data, size_t size) override; + void destroyBuffer(uint32_t handle) override; +}; + +} // namespace ViewBackend + +} // namespace WPE + +#endif // WPE_BACKEND(WINDOWLESS) + +#endif // WPE_ViewBackend_ViewBackendWindowless_h From 610df6106930dc428a8bcaa6c7c0ae14914624c1 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:14:32 +0530 Subject: [PATCH 05/24] Windowless backend support --- .../Windowless/ViewBackendWindowless.cpp | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.cpp diff --git a/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.cpp b/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.cpp new file mode 100644 index 0000000000000..029d18b9587ed --- /dev/null +++ b/Source/WPE/Source/ViewBackend/Windowless/ViewBackendWindowless.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Igalia S.L. + * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * HOLDER 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 "ViewBackendWindowless.h" + +#if WPE_BACKEND(WINDOWLESS) + +#include +#include +#include + +namespace WPE { + +namespace ViewBackend { + + +ViewBackendWindowless::ViewBackendWindowless() +{ +} + +ViewBackendWindowless::~ViewBackendWindowless() +{ +} + +uint32_t ViewBackendWindowless::constructRenderingTarget(uint32_t width, uint32_t height) +{ + return 0; +} + +void ViewBackendWindowless::commitBuffer(int fd, const uint8_t* data, size_t size) +{ +} + +void ViewBackendWindowless::destroyBuffer(uint32_t handle) +{ +} + +} // namespace ViewBackend + +} // namespace WPE + +#endif // WPE_BACKEND(WINDOWLESS) From 7f644d26b05376af06a394082125b6e3d999ba04 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Fri, 8 Apr 2016 20:17:36 +0530 Subject: [PATCH 06/24] Windowless backend support --- Source/WebCore/PlatformWPE.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/PlatformWPE.cmake b/Source/WebCore/PlatformWPE.cmake index 8243f7866861c..e96b4fdda8088 100644 --- a/Source/WebCore/PlatformWPE.cmake +++ b/Source/WebCore/PlatformWPE.cmake @@ -42,6 +42,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/text/icu" ${WPE_DIR} ${WTF_DIR} + ${WAYLAND_INCLUDE_DIRS} ) list(APPEND WebCore_SOURCES @@ -111,7 +112,9 @@ list(APPEND WebCore_SOURCES platform/graphics/opentype/OpenTypeVerticalData.cpp platform/graphics/wpe/PlatformDisplayWPE.cpp - + platform/graphics/wayland/PlatformDisplayWayland.cpp + platform/graphics/wayland/WaylandEventSource.cpp + platform/graphics/wayland/WaylandSurface.cpp platform/image-encoders/JPEGImageEncoder.cpp platform/image-decoders/cairo/ImageDecoderCairo.cpp @@ -213,6 +216,7 @@ list(APPEND WebCore_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${SQLITE_LIBRARIES} + ${WAYLAND_LIBRARIES} WPE ) @@ -271,5 +275,3 @@ if (ENABLE_SUBTLE_CRYPTO) crypto/keys/CryptoKeySerializationRaw.cpp ) endif () - - From e1024bf582ee10ab10cb373913e528b5ce53f57c Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 11:47:15 +0530 Subject: [PATCH 07/24] Windowless backend support --- Source/WebCore/platform/graphics/GLContext.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/WebCore/platform/graphics/GLContext.cpp b/Source/WebCore/platform/graphics/GLContext.cpp index b2d3ab265c111..9c2f245af5763 100644 --- a/Source/WebCore/platform/graphics/GLContext.cpp +++ b/Source/WebCore/platform/graphics/GLContext.cpp @@ -34,8 +34,12 @@ #endif #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) +#include "PlatformDisplayWayland.h" +#else #include "PlatformDisplayWPE.h" #endif +#endif using WTF::ThreadSpecific; @@ -151,8 +155,13 @@ GLContext::GLContext() std::unique_ptr GLContext::createOffscreenContext(GLContext* sharingContext) { #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) + return downcast(PlatformDisplay::sharedDisplay()).createSharingGLContext(); +#else if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::WPE) return downcast(PlatformDisplay::sharedDisplay()).createOffscreenContext(sharingContext); +#endif #endif return createContextForWindow(0, sharingContext); } From d2daa447d728f1803dcaab9ff743c87642824c3f Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 11:49:15 +0530 Subject: [PATCH 08/24] Windowless backend support --- Source/WebCore/platform/graphics/PlatformDisplay.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.cpp b/Source/WebCore/platform/graphics/PlatformDisplay.cpp index e6c7954d90820..80c9896255535 100644 --- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp +++ b/Source/WebCore/platform/graphics/PlatformDisplay.cpp @@ -42,8 +42,10 @@ #endif #if PLATFORM(WPE) +#if !PLATFORM(WAYLAND) #include "PlatformDisplayWPE.h" #endif +#endif #if PLATFORM(GTK) #include @@ -94,9 +96,12 @@ std::unique_ptr PlatformDisplay::createPlatformDisplay() #endif #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + return PlatformDisplayWayland::create(); +#else return std::make_unique(); #endif - +#endif ASSERT_NOT_REACHED(); return nullptr; } From 32d43403ca73bc5e858c61d35df896c17363aff7 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 11:52:14 +0530 Subject: [PATCH 09/24] Windowless backend support --- .../graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp index 07f42f4ecca48..bf96ee1ebfc3e 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp @@ -86,7 +86,7 @@ #define WL_EGL_PLATFORM #if USE(OPENGL_ES_2) -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) #if !USE(HOLE_PUNCH_GSTREAMER) #define GST_USE_UNSTABLE_API #include @@ -650,7 +650,7 @@ void MediaPlayerPrivateGStreamerBase::updateTexture(BitmapTextureGL& texture, Gs { GstBuffer* buffer = gst_sample_get_buffer(m_sample.get()); -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 1, 2) && !USE(HOLE_PUNCH_GSTREAMER) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 1, 2) && !USE(HOLE_PUNCH_GSTREAMER) && USE(GSTREAMER_GL) GstMemory *mem; if (gst_buffer_n_memory (buffer) >= 1) { if ((mem = gst_buffer_peek_memory (buffer, 0)) && gst_is_egl_image_memory (mem)) { @@ -942,7 +942,7 @@ void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper& textur #endif #if USE(GSTREAMER_GL) -NativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime() +PassNativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime() { #if !USE(CAIRO) || !ENABLE(ACCELERATED_2D_CANVAS) return nullptr; From 3e8ee0fce73c2c2573990fcea588be142e13e615 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:08:16 +0530 Subject: [PATCH 10/24] Windowless backend support --- .../graphics/gstreamer/VideoSinkGStreamer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp index 3122b8d42a567..e6aa050ce5c30 100644 --- a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp @@ -38,7 +38,7 @@ #include #include -#if USE(EGL) +#if USE(EGL) && USE(GSTREAMER_GL) #define WL_EGL_PLATFORM #include #include @@ -70,7 +70,7 @@ using namespace WebCore; #if GST_CHECK_VERSION(1, 1, 0) #define GST_FEATURED_CAPS_GL GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, GST_CAPS_FORMAT) ";" -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) #define GST_FEATURED_CAPS GST_FEATURED_CAPS_GL GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_MEMORY_EGL_IMAGE, GST_CAPS_FORMAT) ";" #else #define GST_FEATURED_CAPS GST_FEATURED_CAPS_GL @@ -205,7 +205,7 @@ struct _WebKitVideoSinkPrivate { if (currentCaps) gst_caps_unref(currentCaps); -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 5, 1) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 5, 1) && USE(GSTREAMER_GL) if (context) { gst_gl_context_destroy(context); gst_object_unref(context); @@ -225,7 +225,7 @@ struct _WebKitVideoSinkPrivate { GstVideoInfo info; GstCaps* currentCaps; -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) GstGLDisplay *display; GstGLContext *context; GstGLContext *other_context; @@ -433,7 +433,7 @@ static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery if (!gst_video_info_from_caps(&sink->priv->info, caps)) return FALSE; -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) // Code adapted from gst-plugins-bad's glimagesink. if (!_ensure_gl_setup(sink)) @@ -492,7 +492,7 @@ static gboolean webkitVideoSinkQuery(GstBaseSink* baseSink, GstQuery* query) switch (GST_QUERY_TYPE(query)) { case GST_QUERY_DRAIN: { -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) priv->scheduler.drain(); LOG_MEDIA_MESSAGE("Drain query, emitting DRAIN signal and releasing EGL samples"); @@ -525,7 +525,7 @@ static gboolean webkitVideoSinkEvent(GstBaseSink *baseSink, GstEvent *event) switch (GST_EVENT_TYPE(event)) { case GST_EVENT_FLUSH_START: -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) priv->scheduler.drain(); LOG_MEDIA_MESSAGE("Flush-start, emitting DRAIN signal and releasing EGL samples"); @@ -541,7 +541,7 @@ static gboolean webkitVideoSinkEvent(GstBaseSink *baseSink, GstEvent *event) } } -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) static void webkitVideoSinkSetContext(GstElement* element, GstContext* context) { @@ -579,7 +579,7 @@ static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass) baseSinkClass->query = webkitVideoSinkQuery; baseSinkClass->event = webkitVideoSinkEvent; -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) elementClass->set_context = webkitVideoSinkSetContext; #endif From b0583090e06c52a6b1a89545f50b40c03facd6be Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:10:03 +0530 Subject: [PATCH 11/24] Windowless backend support --- .../wayland/PlatformDisplayWayland.cpp | 418 +++++++++++++++++- 1 file changed, 414 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp index d3305e16a2433..88756dcb51cda 100644 --- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp +++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp @@ -34,7 +34,306 @@ #include #include +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) +#include +#include +#include +#endif +//KEYBOARD SUPPORT +//MOUSE SUPPORT +#include +//MOUSE SUPPORT + namespace WebCore { + +#if !PLATFORM(GTK) + +typedef struct _GSource GSource; + +class EventSource { +public: + static GSourceFuncs sourceFuncs1; + + GSource source; + GPollFD pfd; + struct wl_display* display; +}; + +GSourceFuncs EventSource::sourceFuncs1 = { + // prepare + [](GSource* base, gint* timeout) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + *timeout = -1; + wl_display_flush(display); + wl_display_dispatch_pending(display); + + return FALSE; + }, + // check + [](GSource* base) -> gboolean + { + auto* source = reinterpret_cast(base); + return !!source->pfd.revents; + }, + // dispatch + [](GSource* base, GSourceFunc, gpointer) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + if (source->pfd.revents & G_IO_IN) + wl_display_dispatch(display); + + if (source->pfd.revents & (G_IO_ERR | G_IO_HUP)) + return FALSE; + + source->pfd.revents = 0; + return TRUE; + }, + nullptr, // finalize + nullptr, // closure_callback + nullptr, // closure_marshall +}; +//KEYBOARD SUPPORT +static void +handleKeyEvent(PlatformDisplayWayland::SeatData& seatData, uint32_t key, uint32_t state, uint32_t time) +{ + auto& xkb = seatData.xkb; + uint32_t keysym = xkb_state_key_get_one_sym(xkb.state, key); + uint32_t unicode = xkb_state_key_get_utf32(xkb.state, key); + + if (state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_compose_state_feed(xkb.composeState, keysym) == XKB_COMPOSE_FEED_ACCEPTED + && xkb_compose_state_get_status(xkb.composeState) == XKB_COMPOSE_COMPOSED) + { + keysym = xkb_compose_state_get_one_sym(xkb.composeState); + unicode = xkb_keysym_to_utf32(keysym); + } + seatData.inputHandler->handleKeyboardEvent({ time, keysym, unicode, !!state, xkb.modifiers }); +} + +static gboolean +repeatRateTimeout(void* data) +{ + auto& seatData = *static_cast(data); + handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + return G_SOURCE_CONTINUE; +} + +static gboolean +repeatDelayTimeout(void* data) +{ + auto& seatData = *static_cast(data); + handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + seatData.repeatData.eventSource = g_timeout_add(seatData.repeatInfo.rate, static_cast(repeatRateTimeout), data); + return G_SOURCE_REMOVE; +} + +static const struct wl_keyboard_listener g_keyboardListener = { + // keymap + [](void* data, struct wl_keyboard*, uint32_t format, int fd, uint32_t size) + { + if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { + close(fd); + return; + } + + void* mapping = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); + if (mapping == MAP_FAILED) { + close(fd); + return; + } + + auto& xkb = static_cast(data)->xkb; + xkb.keymap = xkb_keymap_new_from_string(xkb.context, static_cast(mapping), + XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + munmap(mapping, size); + close(fd); + + if (!xkb.keymap) + return; + + xkb.state = xkb_state_new(xkb.keymap); + if (!xkb.state) + return; + + xkb.indexes.control = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_CTRL); + xkb.indexes.alt = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_ALT); + xkb.indexes.shift = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_SHIFT); + }, + // enter + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface, struct wl_array*) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end()) + seatData.keyboard.target = *it; + }, + // leave + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end() && seatData.keyboard.target.first == it->first) + seatData.keyboard.target = { }; + }, + // key + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) + { + // IDK. + key += 8; + + auto& seatData = *static_cast(data); + seatData.serial = serial; + handleKeyEvent(seatData, key, state, time); + + if (!seatData.repeatInfo.rate) + return; + + if (state == WL_KEYBOARD_KEY_STATE_RELEASED + && seatData.repeatData.key == key) { + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + seatData.repeatData = { 0, 0, 0, 0 }; + } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_keymap_key_repeats(seatData.xkb.keymap, key)) { + + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + + seatData.repeatData = { key, time, state, g_timeout_add(seatData.repeatInfo.delay, static_cast(repeatDelayTimeout), data) }; + } + + }, + // modifiers + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t depressedMods, uint32_t latchedMods, uint32_t lockedMods, uint32_t group) + { + + static_cast(data)->serial = serial; + auto& xkb = static_cast(data)->xkb; + xkb_state_update_mask(xkb.state, depressedMods, latchedMods, lockedMods, 0, 0, group); + + auto& modifiers = xkb.modifiers; + modifiers = 0; + auto component = static_cast(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.control, component)) + modifiers |= WPE::Input::KeyboardEvent::Control; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.alt, component)) + modifiers |= WPE::Input::KeyboardEvent::Alt; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.shift, component)) + modifiers |= WPE::Input::KeyboardEvent::Shift; + + }, + // repeat_info + [](void* data, struct wl_keyboard*, int32_t rate, int32_t delay) + { + auto& repeatInfo = static_cast(data)->repeatInfo; + repeatInfo = { rate, delay }; + + // A rate of zero disables any repeating. + if (!rate) { + auto& repeatData = static_cast(data)->repeatData; + if (repeatData.eventSource) { + g_source_remove(repeatData.eventSource); + repeatData = { 0, 0, 0, 0 }; + } + } + }, +}; + + +static const struct wl_pointer_listener g_pointerListener = { + // enter + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface, wl_fixed_t, wl_fixed_t) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end()) + seatData.pointer.target = *it; + }, + // leave + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end() && seatData.pointer.target.first == it->first) + seatData.pointer.target = { }; + }, + // motion + [](void* data, struct wl_pointer*, uint32_t time, wl_fixed_t fixedX, wl_fixed_t fixedY) + { + auto x = wl_fixed_to_int(fixedX); + auto y = wl_fixed_to_int(fixedY); + auto& seatData = *static_cast(data); + seatData.pointer.coords = { x, y }; + seatData.inputHandler->handlePointerEvent({ WPE::Input::PointerEvent::Motion, time, x, y, 0, 0 }); + }, + // button + [](void* data, struct wl_pointer*, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) + { + printf("PlatformDisplayWayland::button pressed\n"); + static_cast(data)->serial = serial; + + if (button >= BTN_MOUSE) + button = button - BTN_MOUSE + 1; + else + button = 0; + + auto& seatData = *static_cast(data); + auto& coords = seatData.pointer.coords; + seatData.inputHandler->handlePointerEvent( + { WPE::Input::PointerEvent::Button, time, coords.first, coords.second, button, state }); + }, + // axis + [](void* data, struct wl_pointer*, uint32_t time, uint32_t axis, wl_fixed_t value) + { + auto& seatData = *static_cast(data); + auto& coords = seatData.pointer.coords; + seatData.inputHandler->handleAxisEvent( + { WPE::Input::AxisEvent::Motion, time, coords.first, coords.second, axis, -wl_fixed_to_int(value) }); + }, +}; + +static const struct wl_seat_listener g_seatListener = { + // capabilities + [](void* data, struct wl_seat* seat, uint32_t capabilities) + { + auto& seatData = *static_cast(data); + // WL_SEAT_CAPABILITY_POINTER + const bool hasPointerCap = capabilities & WL_SEAT_CAPABILITY_POINTER; + if (hasPointerCap && !seatData.pointer.object) { + seatData.pointer.object = wl_seat_get_pointer(seat); + wl_pointer_add_listener(seatData.pointer.object, &g_pointerListener, &seatData); + } + if (!hasPointerCap && seatData.pointer.object) { + wl_pointer_destroy(seatData.pointer.object); + seatData.pointer.object = nullptr; + } + + // WL_SEAT_CAPABILITY_KEYBOARD + const bool hasKeyboardCap = capabilities & WL_SEAT_CAPABILITY_KEYBOARD; + if (hasKeyboardCap && !seatData.keyboard.object) { + seatData.keyboard.object = wl_seat_get_keyboard(seat); + wl_keyboard_add_listener(seatData.keyboard.object, &g_keyboardListener, &seatData); + } + if (!hasKeyboardCap && seatData.keyboard.object) { + wl_keyboard_destroy(seatData.keyboard.object); + seatData.keyboard.object = nullptr; + } + }, + // name + [](void*, struct wl_seat*, const char*) { } +}; +//KEYBOARD SUPPORT +#endif const struct wl_registry_listener PlatformDisplayWayland::m_registryListener = { PlatformDisplayWayland::globalCallback, @@ -46,10 +345,46 @@ void PlatformDisplayWayland::globalCallback(void* data, struct wl_registry* regi auto display = static_cast(data); if (!std::strcmp(interface, "wl_compositor")) display->m_compositor = static_cast(wl_registry_bind(registry, name, &wl_compositor_interface, 1)); +if (!std::strcmp(interface, "wl_shell")) +display->m_shell = static_cast(wl_registry_bind(registry, name, &wl_shell_interface, 1)); +#if PLATFORM(GTK) else if (!std::strcmp(interface, "wl_webkitgtk")) display->m_webkitgtk = static_cast(wl_registry_bind(registry, name, &wl_webkitgtk_interface, 1)); +#endif +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) + else if (!std::strcmp(interface, "wl_seat")) + display->m_seat = static_cast(wl_registry_bind(registry, name, &wl_seat_interface, 4)); +#endif +//KEYBOARD SUPPORT } +//For sending pong in response to ping from server +static void +handle_ping(void *data, struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); +} + +static void +handle_configure(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ +} + +static void +handle_popup_done(void *data, struct wl_shell_surface *shell_surface) +{ +} + +static const struct wl_shell_surface_listener shell_surface_listener = { + handle_ping, + handle_configure, + handle_popup_done +}; +//For sending pong in response to ping from server + void PlatformDisplayWayland::globalRemoveCallback(void*, struct wl_registry*, uint32_t) { // FIXME: if this can happen without the UI Process getting shut down @@ -81,6 +416,29 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) wl_registry_add_listener(m_registry, &m_registryListener, this); wl_display_roundtrip(m_display); +#if !PLATFORM(GTK) + m_eventSource = g_source_new(&EventSource::sourceFuncs1, sizeof(EventSource)); + auto* source = reinterpret_cast(m_eventSource); + source->display = wlDisplay; + + source->pfd.fd = wl_display_get_fd(wlDisplay); + source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; + source->pfd.revents = 0; + g_source_add_poll(m_eventSource, &source->pfd); + + g_source_set_name(m_eventSource, "[WPE] PlatformDisplayWayland"); + g_source_set_priority(m_eventSource, G_PRIORITY_HIGH + 30); + g_source_set_can_recurse(m_eventSource, TRUE); + g_source_attach(m_eventSource, g_main_context_get_thread_default()); +//KEYBOARD SUPPORT + wl_seat_add_listener(m_seat, &g_seatListener, &m_seatData); + m_seatData.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + m_seatData.xkb.composeTable = xkb_compose_table_new_from_locale(m_seatData.xkb.context, setlocale(LC_CTYPE, nullptr), XKB_COMPOSE_COMPILE_NO_FLAGS); + if (m_seatData.xkb.composeTable) + m_seatData.xkb.composeState = xkb_compose_state_new(m_seatData.xkb.composeTable, XKB_COMPOSE_STATE_NO_FLAGS); +//KEYBOARD SUPPORT +#endif + static const EGLint configAttributes[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 1, @@ -92,9 +450,7 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) }; m_eglDisplay = eglGetDisplay(m_display); - PlatformDisplay::initializeEGLDisplay(); - if (m_eglDisplay == EGL_NO_DISPLAY) - return; + if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {return;} EGLint numberOfConfigs; if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) { @@ -107,24 +463,59 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) PlatformDisplayWayland::~PlatformDisplayWayland() { +#if PLATFORM(GTK) if (m_webkitgtk) wl_webkitgtk_destroy(m_webkitgtk); +#endif if (m_compositor) wl_compositor_destroy(m_compositor); if (m_registry) wl_registry_destroy(m_registry); if (m_display) wl_display_disconnect(m_display); +#if !PLATFORM(GTK) +//KEYBOARD SUPPORT + if (m_seat) + wl_seat_destroy(m_seat); + if (m_seatData.xkb.context) + xkb_context_unref(m_seatData.xkb.context); + if (m_seatData.xkb.keymap) + xkb_keymap_unref(m_seatData.xkb.keymap); + if (m_seatData.xkb.state) + xkb_state_unref(m_seatData.xkb.state); + if (m_seatData.xkb.composeTable) + xkb_compose_table_unref(m_seatData.xkb.composeTable); + if (m_seatData.xkb.composeState) + xkb_compose_state_unref(m_seatData.xkb.composeState); +//KEYBOARD SUPPORT +#endif } std::unique_ptr PlatformDisplayWayland::createSurface(const IntSize& size, int widgetId) { struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor); + + struct wl_shell_surface *shell_surface; + shell_surface = wl_shell_get_shell_surface(m_shell, wlSurface); + + if (shell_surface) + wl_shell_surface_add_listener(shell_surface, + &shell_surface_listener, NULL); + wl_shell_surface_set_toplevel(shell_surface); + + struct wl_region *region; + region = wl_compositor_create_region(m_compositor); + wl_region_add(region, 0, 0, + std::max(1, size.width()), + std::max(1, size.height())); + wl_surface_set_opaque_region(wlSurface, region); + // We keep the minimum size at 1x1px since Mesa returns null values in wl_egl_window_create() for zero width or height. EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, std::max(1, size.width()), std::max(1, size.height())); +#if PLATFORM(GTK) wl_webkitgtk_set_surface_for_widget(m_webkitgtk, wlSurface, widgetId); - wl_display_roundtrip(m_display); +#endif return std::make_unique(wlSurface, nativeWindow); } @@ -151,6 +542,25 @@ std::unique_ptr PlatformDisplayWayland::createSharingGLContext() return GLContextEGL::createWindowContext(nativeWindow, nullptr, WTFMove(contextData)); } +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) +void PlatformDisplayWayland::registerInputClient(struct wl_surface* surface, WPE::Input::Client* client) +{ + m_seatData.inputHandler = client; + auto result = m_seatData.inputClients.insert({ surface, client }); + assert(result.second); +} +void PlatformDisplayWayland::unregisterInputClient(struct wl_surface* surface) +{ + auto it = m_seatData.inputClients.find(surface); + assert(it != m_seatData.inputClients.end()); + + if (m_seatData.keyboard.target.first == it->first) + m_seatData.keyboard.target = { }; + m_seatData.inputClients.erase(it); +} +#endif +//KEYBOARD SUPPORT } // namespace WebCore #endif // PLATFORM(WAYLAND) From f600e6c323bfafa7c745da64e625626c277997d4 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:11:26 +0530 Subject: [PATCH 12/24] Windowless backend support --- .../graphics/wayland/PlatformDisplayWayland.h | 71 ++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h index 4cc9044380ff1..e335b3b14385f 100644 --- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h +++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h @@ -29,12 +29,25 @@ #if PLATFORM(WAYLAND) #include "PlatformDisplay.h" +#if PLATFORM(GTK) #include "WebKitGtkWaylandClientProtocol.h" +#endif #include #include #include #include +#if !PLATFORM(GTK) +#include +//KEYBOARD SUPPORT +#include +#include +#include +#include +#include +//KEYBOARD SUPPORT +#endif + namespace WebCore { class GLContextEGL; @@ -52,6 +65,55 @@ class PlatformDisplayWayland final: public PlatformDisplay { std::unique_ptr createSharingGLContext(); +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) + void registerInputClient(struct wl_surface*, WPE::Input::Client*); + void unregisterInputClient(struct wl_surface*); + struct SeatData { + std::unordered_map inputClients; + + struct { + struct wl_pointer* object; + std::pair target; + std::pair coords; + } pointer { nullptr, { }, { 0, 0 } }; + + struct { + struct wl_keyboard* object; + std::pair target; + } keyboard { nullptr, { } }; + + struct { + struct xkb_context* context; + struct xkb_keymap* keymap; + struct xkb_state* state; + struct { + xkb_mod_index_t control; + xkb_mod_index_t alt; + xkb_mod_index_t shift; + } indexes; + uint8_t modifiers; + struct xkb_compose_table* composeTable; + struct xkb_compose_state* composeState; + } xkb { nullptr, nullptr, nullptr, { 0, 0, 0 }, 0, nullptr, nullptr }; + struct { + int32_t rate; + int32_t delay; + } repeatInfo { 0, 0 }; + + struct { + uint32_t key; + uint32_t time; + uint32_t state; + uint32_t eventSource; + } repeatData { 0, 0, 0, 0 }; + + uint32_t serial; + WPE::Input::Client* inputHandler; //RISKY + }; + uint32_t serial() const { return m_seatData.serial; } +#endif +//KEYBOARD SUPPORT private: static const struct wl_registry_listener m_registryListener; static void globalCallback(void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t version); @@ -67,8 +129,15 @@ class PlatformDisplayWayland final: public PlatformDisplay { struct wl_display* m_display; struct wl_registry* m_registry; struct wl_compositor* m_compositor; + struct wl_shell *m_shell; +#if PLATFORM(GTK) struct wl_webkitgtk* m_webkitgtk; - +#endif +#if !PLATFORM(GTK) + struct wl_seat* m_seat; + GSource* m_eventSource; + SeatData m_seatData; +#endif EGLConfig m_eglConfig; bool m_eglConfigChosen; }; From d31770e1dfe0a42d7d96a15cb26bfd2748a374af Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:13:19 +0530 Subject: [PATCH 13/24] Windowless backend support --- Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp b/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp index 971ab19ed3495..6a4171431ac2c 100644 --- a/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp +++ b/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp @@ -78,6 +78,11 @@ void WaylandSurface::requestFrame() wl_callback_add_listener(frameCallback, &frameListener, this); } +#if !PLATFORM(GTK) +void WaylandSurface::releaseBuffer(uint32_t handle) +{ +} +#endif } // namespace WebCore #endif // PLATFORM(WAYLAND) From e01d79d18a310b927dd3a8a969e70d94ae15a188 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:14:10 +0530 Subject: [PATCH 14/24] Windowless backend support --- Source/WebCore/platform/graphics/wayland/WaylandSurface.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/graphics/wayland/WaylandSurface.h b/Source/WebCore/platform/graphics/wayland/WaylandSurface.h index 69f22b1cd6f3b..c20b8074e21df 100644 --- a/Source/WebCore/platform/graphics/wayland/WaylandSurface.h +++ b/Source/WebCore/platform/graphics/wayland/WaylandSurface.h @@ -51,7 +51,9 @@ class WaylandSurface { std::unique_ptr createGLContext(); void requestFrame(); - +#if !PLATFORM(GTK) + void releaseBuffer(uint32_t handle); +#endif private: struct wl_surface* m_wlSurface; EGLNativeWindowType m_nativeWindow; From 2f25e51ddc470b69177a7e1931e45a5b69555fc1 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:16:14 +0530 Subject: [PATCH 15/24] Windowless backend support --- .../threadedcompositor/ThreadedCompositor.cpp | 172 +++++++++++++++++- 1 file changed, 171 insertions(+), 1 deletion(-) diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp index 8be6198c9041d..e67812693c9f3 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp +++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp @@ -29,6 +29,11 @@ #include "ThreadedCompositor.h" #include +#if PLATFORM(WAYLAND) +#include +#include +#endif +#include #include #include #include @@ -44,9 +49,102 @@ #include #endif +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +//KEYBOARD SUPPORT +#include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" +//KEYBOARD SUPPORT +#endif + using namespace WebCore; namespace WebKit { +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +const struct wl_callback_listener g_frameCallbackListener = { + // frame + [](void* data, struct wl_callback* callback, uint32_t) + { + auto& callbackData = *static_cast(data); + callbackData.didFrameComplete(); + wl_callback_destroy(callback); + }, +}; +#endif + +class CompositingRunLoop { + WTF_MAKE_NONCOPYABLE(CompositingRunLoop); + WTF_MAKE_FAST_ALLOCATED; +public: + CompositingRunLoop(std::function updateFunction) + : m_runLoop(RunLoop::current()) + , m_updateTimer(m_runLoop, this, &CompositingRunLoop::updateTimerFired) + , m_updateFunction(WTFMove(updateFunction)) + { + m_updateState.store(UpdateState::Completed); + } + + void callOnCompositingRunLoop(std::function function) + { + if (&m_runLoop == &RunLoop::current()) { + function(); + return; + } + + m_runLoop.dispatch(WTFMove(function)); + } + + void scheduleUpdate() + { + if (m_updateState.compareExchangeStrong(UpdateState::Completed, UpdateState::InProgress)) { + m_updateTimer.startOneShot(0); + return; + } + + if (m_updateState.compareExchangeStrong(UpdateState::InProgress, UpdateState::PendingAfterCompletion)) + return; + } + + void stopUpdates() + { + m_updateTimer.stop(); + m_updateState.store(UpdateState::Completed); + } + + void updateCompleted() + { + if (m_updateState.compareExchangeStrong(UpdateState::InProgress, UpdateState::Completed)) + return; + + if (m_updateState.compareExchangeStrong(UpdateState::PendingAfterCompletion, UpdateState::InProgress)) { + m_updateTimer.startOneShot(0); + return; + } + + ASSERT_NOT_REACHED(); + } + + RunLoop& runLoop() + { + return m_runLoop; + } + +private: + enum class UpdateState { + Completed, + InProgress, + PendingAfterCompletion, + }; + + void updateTimerFired() + { + m_updateFunction(); + } + + RunLoop& m_runLoop; + RunLoop::Timer m_updateTimer; + std::function m_updateFunction; + Atomic m_updateState; +}; Ref ThreadedCompositor::create(Client* client, WebPage& webPage) { @@ -61,6 +159,11 @@ ThreadedCompositor::ThreadedCompositor(Client* client, WebPage& webPage) #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) , m_displayRefreshMonitor(adoptRef(new DisplayRefreshMonitor(*this))) #endif +//KEYBOARD SUPPORT - //THIS NEEDS TO BE TESTED WITH THIS WEBPAGE TO AVOID HAVING ONE MORE API getWebPage in threaded client +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + , webpage(webPage) +#endif +//KEYBOARD SUPPORT { m_clientRendersNextFrame.store(false); m_coordinateUpdateCompletionWithClient.store(false); @@ -188,14 +291,29 @@ GLContext* ThreadedCompositor::glContext() return m_context.get(); #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + RELEASE_ASSERT(is(PlatformDisplay::sharedDisplay())); +#else RELEASE_ASSERT(is(PlatformDisplay::sharedDisplay())); - +#endif IntSize size(viewportController()->visibleContentsRect().size()); uint32_t targetHandle = m_compositingManager->constructRenderingTarget(std::max(0, size.width()), std::max(0, size.height())); +#if PLATFORM(WAYLAND) + m_surface = downcast(PlatformDisplay::sharedDisplay()).createSurface(size, targetHandle); +#else m_surface = downcast(PlatformDisplay::sharedDisplay()).createSurface(size, targetHandle, *m_compositingManager); +#endif if (!m_surface) return nullptr; +#if PLATFORM(WAYLAND) +//KEYBOARD SUPPORT + printf("Registering input client [%x] \n",this); + fflush(stdout); + downcast(PlatformDisplay::sharedDisplay()).registerInputClient(m_surface->surface(),this); +//KEYBOARD SUPPORT +#endif + setNativeSurfaceHandleForCompositing(0); m_context = m_surface->createGLContext(); #endif @@ -237,12 +355,22 @@ void ThreadedCompositor::renderLayerTree() m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::white, false, scrollPostion); +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + requestFrame(); +#endif + glContext()->swapBuffers(); #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + using BufferExport = WPE::Graphics::RenderingBackend::BufferExport; + BufferExport bufferExport = {}; + m_compositingManager->commitBuffer(bufferExport); +#else auto bufferExport = m_surface->lockFrontBuffer(); m_compositingManager->commitBuffer(bufferExport); #endif +#endif } void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state) @@ -296,6 +424,11 @@ void ThreadedCompositor::runCompositingThread() m_viewportController = std::make_unique(this); m_initializeRunLoopCondition.notifyOne(); +#if PLATFORM(WAYLAND) +//KEYBOARD SUPPORT + downcast(PlatformDisplay::sharedDisplay()).unregisterInputClient(m_surface->surface()); +//KEYBOARD SUPPORT +#endif } m_compositingRunLoop->runLoop().run(); @@ -343,11 +476,13 @@ static void debugThreadedCompositorFPS() } } +#if PLATFORM(WPE) void ThreadedCompositor::releaseBuffer(uint32_t handle) { ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop()); m_surface->releaseBuffer(handle); } +#endif void ThreadedCompositor::frameComplete() { @@ -497,5 +632,40 @@ void ThreadedCompositor::CompositingRunLoop::updateTimerFired() m_updateFunction(); } +#if PLATFORM(WAYLAND) +void ThreadedCompositor::requestFrame() +{ + struct wl_callback* frameCallback = wl_surface_frame(m_surface->surface()); + wl_callback_add_listener(frameCallback, &(WebKit::g_frameCallbackListener), this); + wl_display_flush(downcast(PlatformDisplay::sharedDisplay()).native()); +} +void ThreadedCompositor::didFrameComplete() +{ + frameComplete(); +} +#endif +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +void ThreadedCompositor::handleKeyboardEvent(WPE::Input::KeyboardEvent&& event) +{ + fflush(stdout); + m_client->getWebPage()->keyEvent(WebKit::NativeWebKeyboardEvent(WTFMove(event))); +} +void ThreadedCompositor::handlePointerEvent(WPE::Input::PointerEvent&& event) +{ + fflush(stdout); + m_client->getWebPage()->mouseEvent(WebKit::NativeWebMouseEvent(WTFMove(event))); +} + +void ThreadedCompositor::handleAxisEvent(WPE::Input::AxisEvent&& event) +{ +} + +void ThreadedCompositor::handleTouchEvent(WPE::Input::TouchEvent&& event) +{ +} +#endif +//KEYBOARD SUPPORT + } #endif // USE(COORDINATED_GRAPHICS_THREADED) From 061f6845041d4ab0e6b482e048c9c32175de4fdd Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:17:24 +0530 Subject: [PATCH 16/24] Windowless backend support --- .../threadedcompositor/ThreadedCompositor.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h index b2673c7587abf..e72a0fe782fac 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h +++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h @@ -45,6 +45,20 @@ #include #endif +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include +//KEYBOARD SUPPORT +#include +#include "WebPage.h" +//KEYBOARD SUPPORT +#endif + + + +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include +#endif + namespace WebCore { struct CoordinatedGraphicsState; } @@ -55,7 +69,13 @@ class CoordinatedGraphicsScene; class CoordinatedGraphicsSceneClient; class WebPage; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +class ThreadedCompositor : public ThreadSafeRefCounted, public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public CompositingManager::Client, public WPE::Input::Client { +#else class ThreadedCompositor : public ThreadSafeRefCounted, public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public CompositingManager::Client { +#endif +//KEYBOARD SUPPORT WTF_MAKE_NONCOPYABLE(ThreadedCompositor); WTF_MAKE_FAST_ALLOCATED; public: @@ -65,6 +85,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ virtual void purgeBackingStores() = 0; virtual void renderNextFrame() = 0; virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + virtual WebPage* getWebPage() = 0; +#endif +//KEYBOARD SUPPORT }; static Ref create(Client*, WebPage&); @@ -84,7 +109,17 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ void scrollBy(const WebCore::IntSize&); RefPtr createDisplayRefreshMonitor(PlatformDisplayID); +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + void requestFrame(); + void didFrameComplete(); +//KEYBOARD SUPPORT + void handleKeyboardEvent(WPE::Input::KeyboardEvent&&) override; + void handlePointerEvent(WPE::Input::PointerEvent&& event) override; + void handleAxisEvent(WPE::Input::AxisEvent&& event) override; + void handleTouchEvent(WPE::Input::TouchEvent&& event) override; +//KEYBOARD SUPPORT +#endif private: ThreadedCompositor(Client*, WebPage&); @@ -117,7 +152,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ std::unique_ptr m_viewportController; #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + std::unique_ptr m_surface; +#else std::unique_ptr m_surface; +#endif #endif std::unique_ptr m_context; @@ -186,6 +225,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ Atomic m_clientRendersNextFrame; Atomic m_coordinateUpdateCompletionWithClient; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + WebPage& webpage; +#endif +//KEYBOARD SUPPORT }; } // namespace WebKit From 172a345e65f848b288847bdce897ebad8238fbb1 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:20:15 +0530 Subject: [PATCH 17/24] Windowless backend support --- .../ThreadedCoordinatedLayerTreeHost.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp index 05767d2a121a4..6ba1b59e2b9fd 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp @@ -47,6 +47,10 @@ #include #include +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include "NativeWebKeyboardEvent.h" +#endif + using namespace WebCore; namespace WebKit { @@ -285,6 +289,15 @@ void ThreadedCoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, cons m_coordinator->commitScrollOffset(layerID, offset); } +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +WebPage* ThreadedCoordinatedLayerTreeHost::getWebPage() +{ + return m_webPage; +} +#endif +//KEYBOARD SUPPORT + void ThreadedCoordinatedLayerTreeHost::notifyFlushRequired() { scheduleLayerFlush(); From 70cb81e7a4a3ca2d109425c5263c8d5de569ee4e Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:21:34 +0530 Subject: [PATCH 18/24] Windowless backend support --- .../CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h index 82298a5ddfce8..26c7e123bad3d 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h @@ -121,6 +121,12 @@ class ThreadedCoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::C void renderNextFrame() override; void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + virtual WebPage* getWebPage(); +#endif +//KEYBOARD SUPPORT + // CompositingCoordinator::Client void didFlushRootLayer(const WebCore::FloatRect&) override { } void notifyFlushRequired() override; From 612a6c5bed6b168a14d93a945c0635c2f9cf18af Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:27:20 +0530 Subject: [PATCH 19/24] Windowless backend support --- Source/WebKit2/WebProcess/WebPage/WebPage.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 65d16bf80f6d3..671d100507161 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -2148,7 +2148,12 @@ void WebPage::mouseEvent(const WebMouseEvent& mouseEvent) #endif if (!shouldHandleEvent) { +//MOUSE SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) send(Messages::WebPageProxy::DidReceiveEvent(static_cast(mouseEvent.type()), false)); +#endif +//MOUSE SUPPORT + return; } @@ -2172,8 +2177,11 @@ void WebPage::mouseEvent(const WebMouseEvent& mouseEvent) bool onlyUpdateScrollbars = !(m_page->focusController().isActive() || (mouseEvent.button() != WebMouseEvent::NoButton)); handled = handleMouseEvent(mouseEvent, this, onlyUpdateScrollbars); } - +//MOUSE SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) send(Messages::WebPageProxy::DidReceiveEvent(static_cast(mouseEvent.type()), handled)); +#endif +//MOUSE SUPPORT } static bool handleWheelEvent(const WebWheelEvent& wheelEvent, Page* page) @@ -2218,7 +2226,11 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent) if (!handled) handled = performDefaultBehaviorForKeyEvent(keyboardEvent); - send(Messages::WebPageProxy::DidReceiveEvent(static_cast(keyboardEvent.type()), handled)); +//KEYBOARD SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) + send(Messages::WebPageProxy::DidReceiveEvent(static_cast(keyboardEvent.type()), handled)); +#endif +//KEYBOARD SUPPORT } void WebPage::validateCommand(const String& commandName, uint64_t callbackID) From 99e1a542e11e7b82b34e19c2c05288ba9483d311 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:31:01 +0530 Subject: [PATCH 20/24] Windowless backend support --- Source/WebKit2/WebProcess/WebPage/WebPage.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index bede7936cb9ba..99fd7ec9c8ce2 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -939,6 +939,13 @@ class WebPage : public API::ObjectImpl, public IP void insertNewlineInQuotedContent(); +//KEYBOARD SUPPORT +#if (PLATFORM(WPE) && PLATFORM(WAYLAND)) + void keyEvent(const WebKeyboardEvent&); + void mouseEvent(const WebMouseEvent&); +#endif +//KEYBOARD SUPPORT + #if USE(OS_STATE) std::chrono::system_clock::time_point loadCommitTime() const { return m_loadCommitTime; } #endif @@ -1018,8 +1025,13 @@ class WebPage : public API::ObjectImpl, public IP void updateUserActivity(); +//KEYBOARD SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) void mouseEvent(const WebMouseEvent&); void keyEvent(const WebKeyboardEvent&); +#endif +//KEYBOARD SUPPORT + #if ENABLE(IOS_TOUCH_EVENTS) void touchEventSync(const WebTouchEvent&, bool& handled); #elif ENABLE(TOUCH_EVENTS) From a847e7bd6bee5b0f9e17835b6285c0ce12c91409 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:32:38 +0530 Subject: [PATCH 21/24] Windowless backend support --- .../WebProcess/WebPage/wpe/CompositingManager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp index ccfb50c43313a..c8bd7df673c1f 100644 --- a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp +++ b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp @@ -63,27 +63,41 @@ Vector CompositingManager::authenticate() uint32_t CompositingManager::constructRenderingTarget(uint32_t width, uint32_t height) { +#if PLATFORM(WAYLAND) + return 0; +#else uint32_t handle = 0; m_connection->sendSync(Messages::CompositingManagerProxy::ConstructRenderingTarget(width, height), Messages::CompositingManagerProxy::ConstructRenderingTarget::Reply(handle), 0); return handle; +#endif } +#if PLATFORM(WAYLAND) +void CompositingManager::commitBuffer(const WPE::Graphics::RenderingBackend::BufferExport& bufferExport) +{ +} +#else void CompositingManager::commitBuffer(const WebCore::PlatformDisplayWPE::BufferExport& bufferExport) { m_connection->send(Messages::CompositingManagerProxy::CommitBuffer( IPC::Attachment(std::get<0>(bufferExport)), IPC::DataReference(std::get<1>(bufferExport), std::get<2>(bufferExport))), 0); } +#endif void CompositingManager::destroyBuffer(uint32_t handle) { +#if !PLATFORM(WAYLAND) m_connection->send(Messages::CompositingManagerProxy::DestroyBuffer(handle), 0); +#endif } void CompositingManager::releaseBuffer(uint32_t handle) { +#if !PLATFORM(WAYLAND) m_client.releaseBuffer(handle); +#endif } void CompositingManager::frameComplete() From ecbabb6ce302add1bb1875b179022c8a8a798474 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:33:22 +0530 Subject: [PATCH 22/24] Windowless backend support --- .../WebPage/wpe/CompositingManager.h | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h index 667fdf042e408..c0f4b2aaf68f0 100644 --- a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h +++ b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h @@ -28,13 +28,20 @@ #include "Connection.h" #include "MessageReceiver.h" +#if !PLATFORM(WAYLAND) #include - +#endif +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include +#endif namespace WebKit { class WebPage; - +#if PLATFORM(WAYLAND) +class CompositingManager final : public IPC::Connection::Client { +#else class CompositingManager final : public IPC::Connection::Client, public WebCore::PlatformDisplayWPE::Surface::Client { +#endif WTF_MAKE_FAST_ALLOCATED; public: class Client { @@ -50,8 +57,11 @@ class CompositingManager final : public IPC::Connection::Client, public WebCore: Vector authenticate(); uint32_t constructRenderingTarget(uint32_t, uint32_t); +#if PLATFORM(WAYLAND) + void commitBuffer(const WPE::Graphics::RenderingBackend::BufferExport&); +#else void commitBuffer(const WebCore::PlatformDisplayWPE::BufferExport&); - +#endif CompositingManager(const CompositingManager&) = delete; CompositingManager& operator=(const CompositingManager&) = delete; CompositingManager(CompositingManager&&) = delete; @@ -67,8 +77,12 @@ class CompositingManager final : public IPC::Connection::Client, public WebCore: IPC::ProcessType localProcessType() override { return IPC::ProcessType::Web; } IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::UI; } +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + void destroyBuffer(uint32_t); +#else // PlatformDisplayWPE::Surface::Client void destroyBuffer(uint32_t) override; +#endif void releaseBuffer(uint32_t); void frameComplete(); From fe6d37e1f0f7f55b4e8e5ad0a835f0f386d2dc0e Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:34:48 +0530 Subject: [PATCH 23/24] Windowless backend support --- Source/cmake/OptionsWPE.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake index 3002a17649cbb..1916d1b3ff429 100644 --- a/Source/cmake/OptionsWPE.cmake +++ b/Source/cmake/OptionsWPE.cmake @@ -40,6 +40,7 @@ WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_DRM_TEGRA "Whether to enable support for th WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_WAYLAND "Whether to enable support for the Wayland WPE backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_WESTEROS "Whether to enable support for the Westeros WPE backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WESTEROS_SINK "Westeros-Sink to be used as video-sink for GStreamer video player" PUBLIC OFF) +WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_WINDOWLESS "Whether to enable support for the Windlowless WPE backend" PUBLIC ON) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_GBM "Whether to enable support for the GBM WPE rendering backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_BCM_RPI "Whether to enable support for the BCM RPi rendering backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_BCM_NEXUS "Whether to enable support for the BCM_NEXUS rendering backend" PUBLIC OFF) @@ -90,6 +91,7 @@ endif () find_package(OpenGLES2 REQUIRED) find_package(EGL REQUIRED) +find_package(WaylandEGL REQUIRED) if (USE_WPE_BACKEND_BCM_RPI) find_package(BCMHost REQUIRED) @@ -159,6 +161,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_EGL TRUE) SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_BCM_NEXUS ${USE_WPE_BACKEND_BCM_NEXUS}) SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_BCM_RPI ${USE_WPE_BACKEND_BCM_RPI}) SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_INTEL_CE ${USE_WPE_BACKEND_INTEL_CE}) +SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_WAYLAND ${USE_WPE_BACKEND_WINDOWLESS}) set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders) @@ -168,3 +171,4 @@ if (NOT DEVELOPER_MODE) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fvisibility=hidden") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden") endif () +set(EGL_LIBRARIES "-lwayland-egl -lwayland-client -lEGL") From ff2bdb38437bde111367b00fb6fbb22518daa566 Mon Sep 17 00:00:00 2001 From: psivasubramanian Date: Mon, 11 Apr 2016 12:36:40 +0530 Subject: [PATCH 24/24] Windowless backend support --- Source/cmake/WebKitFeatures.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmake/WebKitFeatures.cmake b/Source/cmake/WebKitFeatures.cmake index ea7c25722b2b9..2d2791abd083d 100644 --- a/Source/cmake/WebKitFeatures.cmake +++ b/Source/cmake/WebKitFeatures.cmake @@ -151,7 +151,7 @@ macro(WEBKIT_OPTION_BEGIN) WEBKIT_OPTION_DEFINE(ENABLE_METER_ELEMENT "Toggle Meter Tag support" PRIVATE ON) WEBKIT_OPTION_DEFINE(ENABLE_MHTML "Toggle MHTML support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_MINIBROWSER "Whether to enable MiniBrowser compilation." PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MOUSE_CURSOR_SCALE "Toggle Scaled mouse cursor support" PRIVATE OFF) + WEBKIT_OPTION_DEFINE(ENABLE_MOUSE_CURSOR_SCALE "Toggle Scaled mouse cursor support" PRIVATE ON) WEBKIT_OPTION_DEFINE(ENABLE_NAVIGATOR_CONTENT_UTILS "Toggle Navigator Content Utils support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_NAVIGATOR_HWCONCURRENCY "Toggle Navigator hardware concurrency support" PRIVATE ON) WEBKIT_OPTION_DEFINE(ENABLE_NOSNIFF "Toggle support for 'X-Content-Type-Options: nosniff'" PRIVATE OFF) @@ -160,7 +160,7 @@ macro(WEBKIT_OPTION_BEGIN) WEBKIT_OPTION_DEFINE(ENABLE_ORIENTATION_EVENTS "Toggle Orientation Events support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_PDFKIT_PLUGIN "Toggle PDFKit plugin support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_PERFORMANCE_TIMELINE "Toggle Performance Timeline support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_POINTER_LOCK "Toggle pointer lock support" PRIVATE OFF) + WEBKIT_OPTION_DEFINE(ENABLE_POINTER_LOCK "Toggle pointer lock support" PRIVATE ON) WEBKIT_OPTION_DEFINE(ENABLE_PROXIMITY_EVENTS "Toggle Proximity Events support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_PUBLIC_SUFFIX_LIST "Toggle public suffix list support" PRIVATE OFF) WEBKIT_OPTION_DEFINE(ENABLE_QUOTA "Toggle Quota support" PRIVATE OFF)