Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 113 additions & 50 deletions Source/WebKit/PlatformWPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -552,56 +552,119 @@ target_include_directories(WPEInjectedBundle SYSTEM PRIVATE
)

if (ENABLE_WPE_QT_API)
set(qtwpe_SOURCES
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQtViewBackend.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQmlExtensionPlugin.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQtView.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQtViewLoadRequest.cpp
)

set(qtwpe_LIBRARIES
Epoxy::Epoxy
Qt5::Core Qt5::Quick
WPE::FDO
WebKit
${GLIB_GOBJECT_LIBRARIES}
${GLIB_LIBRARIES}
)

set(qtwpe_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:WebKit,INCLUDE_DIRECTORIES>
${JavaScriptCoreGLib_FRAMEWORK_HEADERS_DIR}
${CMAKE_BINARY_DIR}
${GLIB_INCLUDE_DIRS}
${Qt5_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
${WPE_INCLUDE_DIRS}
)

list(APPEND WPE_QT_API_INSTALLED_HEADERS
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQtView.h
${WEBKIT_DIR}/UIProcess/API/wpe/qt/WPEQtViewLoadRequest.h
)

add_library(qtwpe SHARED ${qtwpe_SOURCES})
set_target_properties(qtwpe PROPERTIES
OUTPUT_NAME qtwpe
AUTOMOC ON
)
target_compile_definitions(qtwpe PUBLIC QT_NO_KEYWORDS=1)
target_link_libraries(qtwpe ${qtwpe_LIBRARIES})
target_include_directories(qtwpe PRIVATE ${qtwpe_INCLUDE_DIRECTORIES})
install(TARGETS qtwpe DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt5/qml/org/wpewebkit/qtwpe/")
install(FILES ${WEBKIT_DIR}/UIProcess/API/wpe/qt/qmldir DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt5/qml/org/wpewebkit/qtwpe/")

file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libqtwpe.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${WEBKIT_DIR}/UIProcess/API/wpe/qt/qmldir
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
if (USE_QT6)
list(APPEND WPE_QT_API_INSTALLED_HEADERS
${WEBKIT_DIR}/UIProcess/API/wpe/qt6/WPEQtView.h
${WEBKIT_DIR}/UIProcess/API/wpe/qt6/WPEQtViewLoadRequest.h
)

# FIXME: This should be MODULE, but tests link directly against it. Abusing
# SHARED here works on Linux and probably some other systems, but
# not on MacOS or Windows.
add_library(qtwpe SHARED
UIProcess/API/wpe/qt6/WPEViewQtQuick.cpp
UIProcess/API/wpe/qt6/WPEDisplayQtQuick.cpp
UIProcess/API/wpe/qt6/WPEQmlExtensionPlugin.cpp
UIProcess/API/wpe/qt6/WPEQtView.cpp
UIProcess/API/wpe/qt6/WPEQtViewLoadRequest.cpp
)
set_target_properties(qtwpe PROPERTIES
OUTPUT_NAME qtwpe
AUTOMOC ON
)
target_compile_definitions(qtwpe PUBLIC
QT_NO_KEYWORDS=1
)
target_link_libraries(qtwpe
PUBLIC
Qt::Quick
PRIVATE
Epoxy::Epoxy
WebKit
${GLIB_GOBJECT_LIBRARIES}
${GLIB_LIBRARIES}
WPEPlatform-${WPE_API_VERSION}
)
target_include_directories(qtwpe PRIVATE
$<TARGET_PROPERTY:WebKit,INCLUDE_DIRECTORIES>
${JavaScriptCoreGLib_FRAMEWORK_HEADERS_DIR}
${CMAKE_BINARY_DIR}
${GLIB_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
${WPE_INCLUDE_DIRS}
${WEBKIT_DIR}/UIProcess/API/wpe/qt6
)

target_link_libraries(qtwpe PRIVATE Qt::QuickPrivate)

install(TARGETS qtwpe
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt6/qml/org/wpewebkit/qtwpe/"
)
install(FILES ${WEBKIT_DIR}/UIProcess/API/wpe/qt6/qmldir
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt6/qml/org/wpewebkit/qtwpe/"
)

file(MAKE_DIRECTORY
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt6/qml/org/wpewebkit/qtwpe
)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libqtwpe.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt6/qml/org/wpewebkit/qtwpe)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${WEBKIT_DIR}/UIProcess/API/wpe/qt6/qmldir
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt6/qml/org/wpewebkit/qtwpe)
else ()
set(qtwpe_SOURCES
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQtViewBackend.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQmlExtensionPlugin.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQtView.cpp
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQtViewLoadRequest.cpp
)

set(qtwpe_LIBRARIES
Epoxy::Epoxy
Qt5::Core Qt5::Quick
WPE::FDO
WebKit
${GLIB_GOBJECT_LIBRARIES}
${GLIB_LIBRARIES}
)

set(qtwpe_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:WebKit,INCLUDE_DIRECTORIES>
${JavaScriptCoreGLib_FRAMEWORK_HEADERS_DIR}
${CMAKE_BINARY_DIR}
${GLIB_INCLUDE_DIRS}
${Qt5_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
${WPE_INCLUDE_DIRS}
)

list(APPEND WPE_QT_API_INSTALLED_HEADERS
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQtView.h
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/WPEQtViewLoadRequest.h
)

add_library(qtwpe SHARED ${qtwpe_SOURCES})
set_target_properties(qtwpe PROPERTIES
OUTPUT_NAME qtwpe
AUTOMOC ON
)
target_compile_definitions(qtwpe PUBLIC QT_NO_KEYWORDS=1)
target_link_libraries(qtwpe ${qtwpe_LIBRARIES})
target_include_directories(qtwpe PRIVATE ${qtwpe_INCLUDE_DIRECTORIES})
install(TARGETS qtwpe DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt5/qml/org/wpewebkit/qtwpe/")
install(FILES ${WEBKIT_DIR}/UIProcess/API/wpe/qt5/qmldir DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/qt5/qml/org/wpewebkit/qtwpe/")

file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libqtwpe.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
add_custom_command(TARGET qtwpe POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${WEBKIT_DIR}/UIProcess/API/wpe/qt5/qmldir
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qt5/qml/org/wpewebkit/qtwpe)
endif ()
endif ()

install(TARGETS WPEInjectedBundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "WPEQmlExtensionPlugin.h"

#include "WPEQtView.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "WPEQtView.h"

#include "WPEQtViewBackend.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "WPEQtViewBackend.h"

#include "WPEQtView.h"
Expand Down Expand Up @@ -177,10 +178,10 @@ GLuint WPEQtViewBackend::texture(QOpenGLContext* context)
glFunctions->glUniform1i(m_textureUniform, 0);

static const GLfloat vertices[4][2] = {
{ -1.0, 1.0 },
{ 1.0, 1.0 },
{ -1.0, 1.0 },
{ 1.0, 1.0 },
{ -1.0, -1.0 },
{ 1.0, -1.0 },
{ 1.0, -1.0 },
};

static const GLfloat texturePos[4][2] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "WPEQtViewLoadRequest.h"

#include "WPEQtView.h"
Expand Down
131 changes: 131 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/qt6/WPEDisplayQtQuick.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright (C) 2024 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 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 "WPEDisplayQtQuick.h"

#include "WPEViewQtQuick.h"

#include <epoxy/egl.h>

#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#include <wtf/glib/GRefPtr.h>
#include <wtf/glib/WTFGType.h>
#include <wtf/text/CString.h>

#ifndef EGL_DRM_RENDER_NODE_FILE_EXT
#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377
#endif

/**
* WPEDisplayQtQuick:
*
*/
struct _WPEDisplayQtQuickPrivate {
EGLDisplay eglDisplay;
CString drmDevice;
CString drmRenderNode;
};
WEBKIT_DEFINE_FINAL_TYPE(WPEDisplayQtQuick, wpe_display_qtquick, WPE_TYPE_DISPLAY, WPEDisplay)

static gboolean wpeDisplayQtQuickConnect(WPEDisplay* display, GError** error)
{
auto* priv = WPE_DISPLAY_QTQUICK(display)->priv;

auto eglDisplay = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("eglDisplay"));
if (!eglDisplay) {
g_set_error_literal(error, WPE_VIEW_ERROR, WPE_VIEW_ERROR_RENDER_FAILED, "Failed to initialize rendering: Cannot access EGL display via Qt");
return FALSE;
}

priv->eglDisplay = eglDisplay;

if (!epoxy_has_egl_extension(eglDisplay, "EGL_EXT_device_query")) {
g_set_error_literal(error, WPE_VIEW_ERROR, WPE_VIEW_ERROR_RENDER_FAILED, "Failed to initialize rendering: 'EGL_EXT_device_query' not available");
return FALSE;
}

EGLDeviceEXT eglDevice;
if (!eglQueryDisplayAttribEXT(eglDisplay, EGL_DEVICE_EXT, reinterpret_cast<EGLAttrib*>(&eglDevice))) {
g_set_error_literal(error, WPE_VIEW_ERROR, WPE_VIEW_ERROR_RENDER_FAILED, "Failed to initialize rendering: 'EGLDeviceEXT' not available");
return FALSE;
}

const char* extensions = eglQueryDeviceStringEXT(eglDevice, EGL_EXTENSIONS);
if (epoxy_extension_in_string(extensions, "EGL_EXT_device_drm"))
priv->drmDevice = eglQueryDeviceStringEXT(eglDevice, EGL_DRM_DEVICE_FILE_EXT);
else {
g_set_error_literal(error, WPE_VIEW_ERROR, WPE_VIEW_ERROR_RENDER_FAILED, "Failed to initialize rendering: 'EGL_EXT_device_drm' not available");
return FALSE;
}

if (epoxy_extension_in_string(extensions, "EGL_EXT_device_drm_render_node"))
priv->drmRenderNode = eglQueryDeviceStringEXT(eglDevice, EGL_DRM_RENDER_NODE_FILE_EXT);
else {
g_set_error_literal(error, WPE_VIEW_ERROR, WPE_VIEW_ERROR_RENDER_FAILED, "Failed to initialize rendering: 'EGL_EXT_device_drm_render_node' not available");
return FALSE;
}

return TRUE;
}

static WPEView* wpeDisplayQtQuickCreateView(WPEDisplay* display)
{
return wpe_view_qtquick_new(WPE_DISPLAY_QTQUICK(display));
}

static gpointer wpeDisplayQtQuickGetEGLDisplay(WPEDisplay* display, GError**)
{
return WPE_DISPLAY_QTQUICK(display)->priv->eglDisplay;
}

static const char* wpeDisplayQtQuickGetDRMDevice(WPEDisplay* display)
{
return WPE_DISPLAY_QTQUICK(display)->priv->drmDevice.data();
}

static const char* wpeDisplayQtQuickGetDRMRenderNode(WPEDisplay* display)
{
auto* priv = WPE_DISPLAY_QTQUICK(display)->priv;
if (!priv->drmRenderNode.isNull())
return priv->drmRenderNode.data();
return priv->drmDevice.data();
}

static void wpe_display_qtquick_class_init(WPEDisplayQtQuickClass* displayQtQuickClass)
{
WPEDisplayClass* displayClass = WPE_DISPLAY_CLASS(displayQtQuickClass);
displayClass->connect = wpeDisplayQtQuickConnect;
displayClass->create_view = wpeDisplayQtQuickCreateView;
displayClass->get_egl_display = wpeDisplayQtQuickGetEGLDisplay;
displayClass->get_drm_device = wpeDisplayQtQuickGetDRMDevice;
displayClass->get_drm_render_node = wpeDisplayQtQuickGetDRMRenderNode;
}

WPEDisplay* wpe_display_qtquick_new(void)
{
return WPE_DISPLAY(g_object_new(WPE_TYPE_DISPLAY_QTQUICK, nullptr));
}
41 changes: 41 additions & 0 deletions Source/WebKit/UIProcess/API/wpe/qt6/WPEDisplayQtQuick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2024 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 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 WPEDisplayQtQuick_h
#define WPEDisplayQtQuick_h

#include <glib-object.h>
#include <wpe/wpe-platform.h>

G_BEGIN_DECLS

#define WPE_TYPE_DISPLAY_QTQUICK (wpe_display_qtquick_get_type())
G_DECLARE_FINAL_TYPE (WPEDisplayQtQuick, wpe_display_qtquick, WPE, DISPLAY_QTQUICK, WPEDisplay)

WPEDisplay *wpe_display_qtquick_new (void);

G_END_DECLS

#endif /* WPEDisplayQtQuick_h */
Loading