Skip to content

Commit

Permalink
[GTK][WPE] Add USE_LIBDRM in addition to USE_GBM
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260384

Reviewed by Michael Catanzaro.

Right now we have USE_GBM to enable both GBM and DRM, because we only
need to use DRM for GBM in most of the cases. It would be possible to
get the device and render node files without GBM and we plan to add more
code that requires DRM but not GBM.

* Source/WebCore/platform/graphics/PlatformDisplay.cpp:
* Source/WebCore/platform/graphics/PlatformDisplay.h:
* Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp:
(WebKit::WebKitProtocolHandler::handleGPU):
* Source/cmake/OptionsGTK.cmake:
* Source/cmake/OptionsWPE.cmake:

Canonical link: https://commits.webkit.org/267039@main
  • Loading branch information
carlosgcampos committed Aug 18, 2023
1 parent 971943d commit b8ffa14
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
6 changes: 4 additions & 2 deletions Source/WebCore/platform/graphics/PlatformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#include <wtf/NeverDestroyed.h>
#endif

#if USE(EGL) && USE(GBM)
#if USE(EGL) && USE(LIBDRM)
#include "GBMDevice.h"
#include <xf86drm.h>
#ifndef EGL_DRM_RENDER_NODE_FILE_EXT
Expand Down Expand Up @@ -426,7 +426,7 @@ bool PlatformDisplay::destroyEGLImage(EGLImage image) const
#endif
}

#if USE(GBM)
#if USE(LIBDRM)
EGLDeviceEXT PlatformDisplay::eglDevice()
{
if (!GLContext::isExtensionSupported(eglQueryString(nullptr, EGL_EXTENSIONS), "EGL_EXT_device_query"))
Expand Down Expand Up @@ -532,7 +532,9 @@ const String& PlatformDisplay::drmRenderNodeFile()

return m_drmRenderNodeFile.value();
}
#endif // USE(LIBDRM)

#if USE(GBM)
struct gbm_device* PlatformDisplay::gbmDevice()
{
auto& device = GBMDevice::singleton();
Expand Down
12 changes: 8 additions & 4 deletions Source/WebCore/platform/graphics/PlatformDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLImage;
typedef unsigned EGLenum;
#if USE(GBM)
#if USE(LIBDRM)
typedef void *EGLDeviceEXT;
#endif
#if USE(GBM)
struct gbm_device;
#endif
#endif
Expand Down Expand Up @@ -113,9 +115,11 @@ class PlatformDisplay {

EGLImage createEGLImage(EGLContext, EGLenum target, EGLClientBuffer, const Vector<EGLAttrib>&) const;
bool destroyEGLImage(EGLImage) const;
#if USE(GBM)
#if USE(LIBDRM)
const String& drmDeviceFile();
const String& drmRenderNodeFile();
#endif
#if USE(GBM)
struct gbm_device* gbmDevice();
#endif

Expand Down Expand Up @@ -163,7 +167,7 @@ class PlatformDisplay {
bool m_eglDisplayOwned { true };
std::unique_ptr<GLContext> m_sharingGLContext;

#if USE(GBM)
#if USE(LIBDRM)
std::optional<String> m_drmDeviceFile;
std::optional<String> m_drmRenderNodeFile;
#endif
Expand Down Expand Up @@ -193,7 +197,7 @@ class PlatformDisplay {

#if USE(EGL)
void terminateEGLDisplay();
#if USE(GBM)
#if USE(LIBDRM)
EGLDeviceEXT eglDevice();
#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void WebKitProtocolHandler::handleGPU(WebKitURISchemeRequest* request)
addTableRow(displayObject, "Depth"_s, String::number(screenDepth(nullptr)));
addTableRow(displayObject, "Bits per color component"_s, String::number(screenDepthPerComponent(nullptr)));
addTableRow(displayObject, "DPI"_s, String::number(screenDPI()));
#if USE(GBM)
#if USE(LIBDRM)
if (strcmp(policy, "never")) {
auto deviceFile = PlatformDisplay::sharedDisplay().drmDeviceFile();
if (!deviceFile.isEmpty())
Expand Down
20 changes: 10 additions & 10 deletions Source/cmake/OptionsGTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ WEBKIT_OPTION_DEFINE(ENABLE_JOURNALD_LOG "Whether to enable journald logging" PU
WEBKIT_OPTION_DEFINE(ENABLE_QUARTZ_TARGET "Whether to enable support for the Quartz windowing target." PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_WAYLAND_TARGET "Whether to enable support for the Wayland windowing target." PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_X11_TARGET "Whether to enable support for the X11 windowing target." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_GBM "Whether to enable usage of GBM and libdrm." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_GBM "Whether to enable usage of GBM." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_GTK4 "Whether to enable usage of GTK4 instead of GTK3." PUBLIC OFF)
WEBKIT_OPTION_DEFINE(USE_LCMS "Whether to enable support for image color management using libcms2." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBDRM "Whether to enable usage of libdrm." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBHYPHEN "Whether to enable the default automatic hyphenation implementation." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBSECRET "Whether to enable the persistent credential storage using libsecret." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_OPENGL_OR_ES "Whether to use OpenGL or ES." PUBLIC ON)
Expand All @@ -66,6 +67,7 @@ WEBKIT_OPTION_DEPEND(ENABLE_3D_TRANSFORMS USE_OPENGL_OR_ES)
WEBKIT_OPTION_DEPEND(ENABLE_ASYNC_SCROLLING USE_OPENGL_OR_ES)
WEBKIT_OPTION_DEPEND(ENABLE_WEBGL USE_OPENGL_OR_ES)
WEBKIT_OPTION_DEPEND(USE_GBM USE_OPENGL_OR_ES)
WEBKIT_OPTION_DEPEND(USE_GBM USE_LIBDRM)
WEBKIT_OPTION_DEPEND(USE_GSTREAMER_GL USE_OPENGL_OR_ES)

WEBKIT_OPTION_CONFLICT(USE_GTK4 USE_SOUP2)
Expand Down Expand Up @@ -331,6 +333,13 @@ endif ()

SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER TRUE)

if (USE_LIBDRM)
find_package(LibDRM)
if (NOT LIBDRM_FOUND)
message(FATAL_ERROR "libdrm is required for USE_LIBDRM")
endif ()
endif ()

if (USE_OPENGL_OR_ES)

SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL ON)
Expand All @@ -354,20 +363,11 @@ if (USE_OPENGL_OR_ES)
endif ()

if (USE_GBM)
# ANGLE-backed WebGL depends on DMABuf support, which at the moment is leveraged
# through libgbm and libdrm dependencies. When libgbm is enabled, make
# libdrm a requirement and define USE_TEXTURE_MAPPER_DMABUF macros.
# When not available, ANGLE will be used in slower software-rasterization mode.
find_package(GBM)
if (NOT GBM_FOUND)
message(FATAL_ERROR "GBM is required for USE_GBM")
endif ()

find_package(LibDRM)
if (NOT LIBDRM_FOUND)
message(FATAL_ERROR "libdrm is required for USE_GBM")
endif ()

SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_DMABUF ON)
endif ()
endif ()
Expand Down
20 changes: 10 additions & 10 deletions Source/cmake/OptionsWPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ WEBKIT_OPTION_DEFINE(ENABLE_INTROSPECTION "Whether to enable GObject introspecti
WEBKIT_OPTION_DEFINE(ENABLE_JOURNALD_LOG "Whether to enable journald logging" PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC ${ENABLE_DEVELOPER_MODE})
WEBKIT_OPTION_DEFINE(ENABLE_WPE_1_1_API "Whether to build WPE 1.1 instead of WPE 2.0" PUBLIC OFF)
WEBKIT_OPTION_DEFINE(USE_GBM "Whether to enable usage of GBM and libdrm." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_GBM "Whether to enable usage of GBM." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LCMS "Whether to enable support for image color management using libcms2." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_LIBDRM "Whether to enable usage of libdrm." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Soup 3." PUBLIC OFF)
WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
Expand Down Expand Up @@ -136,6 +137,7 @@ if (ENABLE_DEVELOPER_MODE)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_COG PRIVATE ON)
endif ()

WEBKIT_OPTION_DEPEND(USE_GBM USE_LIBDRM)
WEBKIT_OPTION_DEPEND(USE_GSTREAMER_HOLEPUNCH ENABLE_VIDEO)
WEBKIT_OPTION_DEPEND(USE_EXTERNAL_HOLEPUNCH ENABLE_VIDEO)
WEBKIT_OPTION_DEPEND(USE_WESTEROS_SINK ENABLE_VIDEO)
Expand Down Expand Up @@ -375,21 +377,19 @@ SET_AND_EXPOSE_TO_BUILD(USE_ANGLE ${ENABLE_WEBGL})
SET_AND_EXPOSE_TO_BUILD(USE_THEME_ADWAITA TRUE)
SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)

if (USE_LIBDRM)
find_package(LibDRM)
if (NOT LIBDRM_FOUND)
message(FATAL_ERROR "libdrm is required for USE_LIBDRM")
endif ()
endif ()

if (USE_GBM)
# ANGLE-backed WebGL depends on DMABuf support, which at the moment is leveraged
# through libgbm and libdrm dependencies. When libgbm is enabled, make
# libdrm a requirement and define the USE_LIBGBM and USE_TEXTURE_MAPPER_DMABUF
# macros. When not available, ANGLE will be used in slower software-rasterization mode.
find_package(GBM)
if (NOT GBM_FOUND)
message(FATAL_ERROR "GBM is required for USE_GBM")
endif ()

find_package(LibDRM)
if (NOT LIBDRM_FOUND)
message(FATAL_ERROR "libdrm is required for USE_GBM")
endif ()

SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_DMABUF TRUE)
endif ()

Expand Down

0 comments on commit b8ffa14

Please sign in to comment.