Skip to content

Commit

Permalink
Cherry-pick 263069@main (3cb14d2). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=255588

    [GTK][WPE] Unify USE(GBM) and USE(LIBGBM)
    https://bugs.webkit.org/show_bug.cgi?id=255588

    Reviewed by Žan Doberšek.

    GTK exposes both, but WPE only USE(LIBGBM), let's use just one.

    * Source/WebCore/PlatformGTK.cmake:
    * Source/WebCore/PlatformWPE.cmake:
    * Source/WebCore/platform/TextureMapper.cmake:
    * Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp:
    * Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h:
    * Source/WebCore/platform/graphics/gbm/GBMDevice.cpp:
    * Source/WebCore/platform/graphics/gbm/GBMDevice.h:
    * Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp:
    * Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.h:
    * Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBMTextureMapper.cpp:
    * Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBMTextureMapper.h:
    * Source/WebCore/platform/graphics/gstreamer/DMABufVideoSinkGStreamer.cpp:
    (webKitDMABufVideoSinkIsEnabled):
    * Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp:
    * Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h:
    * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
    * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h:
    * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
    * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLGBM.cpp:
    * Source/WebKit/PlatformGTK.cmake:
    * Source/WebKit/WebProcess/GPU/graphics/gbm/RemoteGraphicsContextGLProxyGBM.cpp:
    * Source/cmake/OptionsGTK.cmake:
    * Source/cmake/OptionsWPE.cmake:
    * Tools/Scripts/generate-gpup-webgl:

    Canonical link: https://commits.webkit.org/263069@main
  • Loading branch information
carlosgcampos authored and aperezdc committed Apr 28, 2023
1 parent 20c448b commit 8971e9a
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/PlatformGTK.cmake
Expand Up @@ -186,7 +186,7 @@ if (USE_ATSPI)
)
endif ()

if (USE_LIBGBM)
if (USE_GBM)
list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
${GBM_INCLUDE_DIR}
${LIBDRM_INCLUDE_DIR}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/PlatformWPE.cmake
Expand Up @@ -121,7 +121,7 @@ if (USE_ATSPI)
)
endif ()

if (USE_LIBGBM)
if (USE_GBM)
list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
${GBM_INCLUDE_DIR}
${LIBDRM_INCLUDE_DIR}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/TextureMapper.cmake
Expand Up @@ -151,7 +151,7 @@ if (USE_GRAPHICS_LAYER_WC)
)
endif ()

if (USE_LIBGBM)
if (USE_GBM)
list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/gbm/DMABufColorSpace.h
platform/graphics/gbm/DMABufEGLUtilities.h
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp
Expand Up @@ -27,7 +27,7 @@
#include "config.h"
#include "GBMBufferSwapchain.h"

#if USE(LIBGBM)
#if USE(GBM)

#include "DMABufColorSpace.h"
#include "GBMDevice.h"
Expand Down Expand Up @@ -178,4 +178,4 @@ GBMBufferSwapchain::Buffer::PlaneData::~PlaneData()

} // namespace WebCore

#endif // USE(LIBGBM)
#endif // USE(GBM)
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h
Expand Up @@ -26,7 +26,7 @@

#pragma once

#if USE(LIBGBM)
#if USE(GBM)

#include "DMABufFormat.h"
#include "DMABufObject.h"
Expand Down Expand Up @@ -134,4 +134,4 @@ class GBMBufferSwapchain : public ThreadSafeRefCounted<GBMBufferSwapchain> {

} // namespace WebCore

#endif // USE(LIBGBM)
#endif // USE(GBM)
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GBMDevice.cpp
Expand Up @@ -27,7 +27,7 @@
#include "config.h"
#include "GBMDevice.h"

#if USE(LIBGBM)
#if USE(GBM)

#include <fcntl.h>
#include <gbm.h>
Expand Down Expand Up @@ -86,4 +86,4 @@ GBMDevice::~GBMDevice()

} // namespace WebCore

#endif // USE(LIBGBM)
#endif // USE(GBM)
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GBMDevice.h
Expand Up @@ -26,7 +26,7 @@

#pragma once

#if USE(LIBGBM)
#if USE(GBM)

#include <wtf/Noncopyable.h>

Expand All @@ -52,4 +52,4 @@ class GBMDevice {

} // namespace WebCore

#endif // USE(LIBGBM)
#endif // USE(GBM)
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp
Expand Up @@ -27,7 +27,7 @@
#include "config.h"
#include "GraphicsContextGLGBM.h"

#if ENABLE(WEBGL) && USE(LIBGBM)
#if ENABLE(WEBGL) && USE(GBM)

#include "ANGLEHeaders.h"
#include "DMABufEGLUtilities.h"
Expand Down Expand Up @@ -329,4 +329,4 @@ GraphicsContextGLGBM::Swapchain::~Swapchain()

} // namespace WebCore

#endif // ENABLE(WEBGL) && USE(LIBGBM)
#endif // ENABLE(WEBGL) && USE(GBM)
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.h
Expand Up @@ -26,7 +26,7 @@

#pragma once

#if ENABLE(WEBGL) && USE(LIBGBM)
#if ENABLE(WEBGL) && USE(GBM)

#include "GBMBufferSwapchain.h"
#include "GraphicsContextGLANGLE.h"
Expand Down Expand Up @@ -110,4 +110,4 @@ class GraphicsContextGLGBM : public GraphicsContextGLANGLE {

} // namespace WebCore

#endif // ENABLE(WEBGL) && USE(LIBGBM)
#endif // ENABLE(WEBGL) && USE(GBM)
Expand Up @@ -27,7 +27,7 @@
#include "config.h"
#include "GraphicsContextGLGBMTextureMapper.h"

#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(LIBGBM)
#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(GBM)

#include "NicosiaGCGLANGLELayer.h"
#include "PlatformLayerDisplayDelegate.h"
Expand Down Expand Up @@ -63,4 +63,4 @@ bool GraphicsContextGLGBMTextureMapper::platformInitialize()

} // namespace WebCore

#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(LIBGBM)
#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(GBM)
Expand Up @@ -26,7 +26,7 @@

#pragma once

#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(LIBGBM)
#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(GBM)

#include "GraphicsContextGLGBM.h"
#include <memory>
Expand Down Expand Up @@ -57,4 +57,4 @@ class GraphicsContextGLGBMTextureMapper final : public GraphicsContextGLGBM {

} // namespace WebCore

#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(LIBGBM)
#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(GBM)
Expand Up @@ -163,12 +163,14 @@ static void webkit_dmabuf_video_sink_class_init(WebKitDMABufVideoSinkClass* klas
bool webKitDMABufVideoSinkIsEnabled()
{
static bool s_enabled = false;
#if USE(GBM)
static std::once_flag s_flag;
std::call_once(s_flag,
[&] {
const char* value = g_getenv("WEBKIT_GST_DMABUF_SINK_ENABLED");
s_enabled = value && (equalLettersIgnoringASCIICase(value, "true"_s) || equalLettersIgnoringASCIICase(value, "1"_s));
});
#endif
return s_enabled;
}

Expand Down
Expand Up @@ -115,7 +115,7 @@ GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLFallback& context)
{
}

#if USE(LIBGBM)
#if USE(GBM)
GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLGBM& context)
: m_contextType(ContextType::Gbm)
, m_context(context)
Expand Down
Expand Up @@ -41,7 +41,7 @@ namespace WebCore {
class IntSize;
class GraphicsContextGLANGLE;
class GraphicsContextGLFallback;
#if USE(LIBGBM)
#if USE(GBM)
class GraphicsContextGLGBM;
#endif
class PlatformDisplay;
Expand All @@ -53,7 +53,7 @@ class GCGLANGLELayer final : public ContentLayerTextureMapperImpl::Client {
WTF_MAKE_FAST_ALLOCATED;
public:
GCGLANGLELayer(WebCore::GraphicsContextGLFallback&);
#if USE(LIBGBM)
#if USE(GBM)
GCGLANGLELayer(WebCore::GraphicsContextGLGBM&);
#endif
virtual ~GCGLANGLELayer();
Expand All @@ -74,4 +74,4 @@ class GCGLANGLELayer final : public ContentLayerTextureMapperImpl::Client {

} // namespace Nicosia

#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER) && USE(LIBGBM)
#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)
4 changes: 2 additions & 2 deletions Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
Expand Up @@ -66,7 +66,7 @@ IPC::StreamConnectionWorkQueue& remoteGraphicsContextGLStreamWorkQueue()
return instance.get();
}

#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(LIBGBM)
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(GBM)
Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLAttributes&& attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamServerConnection::Handle&& connectionHandle)
{
ASSERT_NOT_REACHED();
Expand Down Expand Up @@ -182,7 +182,7 @@ void RemoteGraphicsContextGL::reshape(int32_t width, int32_t height)
forceContextLost();
}

#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(LIBGBM)
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(GBM)
void RemoteGraphicsContextGL::prepareForDisplay(CompletionHandler<void()>&& completionHandler)
{
assertIsCurrent(workQueue());
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h
Expand Up @@ -44,7 +44,7 @@

#if PLATFORM(COCOA)
#include <WebCore/GraphicsContextGLCocoa.h>
#elif USE(LIBGBM)
#elif USE(GBM)
#include <WebCore/GraphicsContextGLGBM.h>
#else
#include <WebCore/GraphicsContextGLTextureMapperANGLE.h>
Expand Down Expand Up @@ -116,7 +116,7 @@ class RemoteGraphicsContextGL : private WebCore::GraphicsContextGL::Client, publ
virtual void prepareForDisplay(CompletionHandler<void(WTF::MachSendRight&&)>&&) = 0;
#elif USE(GRAPHICS_LAYER_WC)
virtual void prepareForDisplay(CompletionHandler<void(std::optional<WCContentBufferIdentifier>)>&&) = 0;
#elif USE(LIBGBM)
#elif USE(GBM)
virtual void prepareForDisplay(CompletionHandler<void(WebCore::DMABufObject&&)>&&) = 0;
#else
void prepareForDisplay(CompletionHandler<void()>&&);
Expand Down Expand Up @@ -157,7 +157,7 @@ class RemoteGraphicsContextGL : private WebCore::GraphicsContextGL::Client, publ
RefPtr<IPC::StreamServerConnection> m_streamConnection;
#if PLATFORM(COCOA)
using GCGLContext = WebCore::GraphicsContextGLCocoa;
#elif USE(LIBGBM)
#elif USE(GBM)
using GCGLContext = WebCore::GraphicsContextGLGBM;
#else
using GCGLContext = WebCore::GraphicsContextGLTextureMapperANGLE;
Expand Down
Expand Up @@ -32,10 +32,10 @@ messages -> RemoteGraphicsContextGL NotRefCounted Stream {
#if USE(GRAPHICS_LAYER_WC)
void PrepareForDisplay() -> (std::optional<WebKit::WCContentBufferIdentifier> contentBuffer) Synchronous
#endif
#if USE(LIBGBM)
#if USE(GBM)
void PrepareForDisplay() -> (WebCore::DMABufObject dmabufObject) Synchronous NotStreamEncodableReply
#endif
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(LIBGBM)
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(GBM)
void PrepareForDisplay() -> () Synchronous
#endif
void EnsureExtensionEnabled(String extension)
Expand Down
Expand Up @@ -27,7 +27,7 @@
#include "config.h"
#include "RemoteGraphicsContextGL.h"

#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(LIBGBM)
#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GBM)

namespace WebKit {

Expand Down Expand Up @@ -75,4 +75,4 @@ Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebP

} // namespace WebKit

#endif // ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(LIBGBM)
#endif // ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GBM)
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp
Expand Up @@ -49,7 +49,6 @@
#include <wpe/wpe.h>
#include <wpe/fdo.h>
#endif
#endif

#if USE(LIBEPOXY)
#include <epoxy/gl.h>
Expand All @@ -66,6 +65,7 @@
#include <EGL/egl.h>
#endif
#endif
#endif

#if PLATFORM(X11)
#include <WebCore/PlatformDisplayX11.h>
Expand Down
Expand Up @@ -28,7 +28,7 @@
#include "RemoteGraphicsContextGLProxy.h"
#include "RemoteRenderingBackendProxy.h"

#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(LIBGBM)
#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GBM)

// This is a standalone check of additional requirements in this implementation,
// avoiding having to place an overwhelming amount of build guards over the rest of the code.
Expand Down Expand Up @@ -144,4 +144,4 @@ RefPtr<RemoteGraphicsContextGLProxy> RemoteGraphicsContextGLProxy::create(IPC::C

} // namespace WebKit

#endif // ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(LIBGBM)
#endif // ENABLE(GPU_PROCESS) && ENABLE(WEBGL) && USE(GBM)
5 changes: 2 additions & 3 deletions Source/cmake/OptionsGTK.cmake
Expand Up @@ -406,8 +406,8 @@ if (USE_OPENGL_OR_ES)
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.
# 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")
Expand All @@ -418,7 +418,6 @@ if (USE_OPENGL_OR_ES)
message(FATAL_ERROR "libdrm is required for USE_GBM")
endif ()

SET_AND_EXPOSE_TO_BUILD(USE_LIBGBM TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_DMABUF TRUE)
endif ()
endif ()
Expand Down
2 changes: 1 addition & 1 deletion Source/cmake/OptionsWPE.cmake
Expand Up @@ -359,9 +359,9 @@ SET_AND_EXPOSE_TO_BUILD(HAVE_ACCESSIBILITY ${ENABLE_ACCESSIBILITY})
SET_AND_EXPOSE_TO_BUILD(USE_ATSPI ${ENABLE_ACCESSIBILITY})
SET_AND_EXPOSE_TO_BUILD(USE_CAIRO TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_EGL TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_GBM TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_GCRYPT TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_LIBEPOXY TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_LIBGBM TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE TRUE)
SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES TRUE)
SET_AND_EXPOSE_TO_BUILD(HAVE_OPENGL_ES_3 TRUE)
Expand Down
4 changes: 2 additions & 2 deletions Tools/Scripts/generate-gpup-webgl
Expand Up @@ -96,10 +96,10 @@ messages -> RemoteGraphicsContextGL NotRefCounted Stream {{
#if USE(GRAPHICS_LAYER_WC)
void PrepareForDisplay() -> (std::optional<WebKit::WCContentBufferIdentifier> contentBuffer) Synchronous
#endif
#if USE(LIBGBM)
#if USE(GBM)
void PrepareForDisplay() -> (WebCore::DMABufObject dmabufObject) Synchronous NotStreamEncodableReply
#endif
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(LIBGBM)
#if !PLATFORM(COCOA) && !USE(GRAPHICS_LAYER_WC) && !USE(GBM)
void PrepareForDisplay() -> () Synchronous
#endif
void EnsureExtensionEnabled(String extension)
Expand Down

0 comments on commit 8971e9a

Please sign in to comment.