Diff
Modified: trunk/Source/WebCore/ChangeLog (289105 => 289106)
--- trunk/Source/WebCore/ChangeLog 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/ChangeLog 2022-02-04 07:16:39 UTC (rev 289106)
@@ -1,3 +1,66 @@
+2022-02-03 Chris Lord <[email protected]>
+
+ [GTK][WPE] Use dmabuf when possible to transfer ANGLE rendering to the compositor
+ https://bugs.webkit.org/show_bug.cgi?id=235946
+
+ Reviewed by Žan Doberšek.
+
+ Use dmabuf when available to transfer ANGLE WebGL rendering contents
+ to the compositor.
+
+ No new tests, no change in behaviour.
+
+ * PlatformGTK.cmake:
+ * PlatformWPE.cmake:
+ * SourcesGTK.txt:
+ * SourcesWPE.txt:
+ * platform/TextureMapper.cmake:
+ * platform/graphics/OpenGLShims.cpp:
+ (WebCore::initializeOpenGLShims):
+ * platform/graphics/OpenGLShims.h:
+ * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::prepareTextureImpl):
+ * platform/graphics/angle/GraphicsContextGLANGLE.h:
+ * platform/graphics/egl/GLContextEGL.cpp:
+ (WebCore::GLContextEGL::GLContextEGL):
+ (WebCore::GLContextEGL::createImage const):
+ (WebCore::GLContextEGL::destroyImage const):
+ * platform/graphics/egl/GLContextEGL.h:
+ * platform/graphics/gbm/GBMDevice.cpp: Added.
+ (WebCore::threadSpecificDevice):
+ (WebCore::GBMDevice::get):
+ (WebCore::GBMDevice::GBMDevice):
+ (WebCore::GBMDevice::~GBMDevice):
+ * platform/graphics/gbm/GBMDevice.h: Added.
+ (WebCore::GBMDevice::device const):
+ * platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp:
+ (Nicosia::GCGLANGLEPipeSource::swapBuffersIfNeeded):
+ * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::GraphicsContextGLANGLE):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::format const):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::stride const):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::releaseResources):
+ (WebCore::GraphicsContextGLANGLE::EGLImageBacking::reset):
+ (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
+ (WebCore::GraphicsContextGLANGLE::reshapeDisplayBufferBacking):
+ * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
+ (WebCore::TextureMapperPlatformLayerBuffer::textureVariant const):
+ (WebCore::TextureMapperPlatformLayerBuffer::size const):
+ (WebCore::TextureMapperPlatformLayerBuffer::textureVariant): Deleted.
+ * platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp: Added.
+ (WebCore::createFourCC):
+ (WebCore::fourCCToGLFormat):
+ (WebCore::formatHasAlpha):
+ (WebCore::TextureMapperPlatformLayerDmabuf::TextureMapperPlatformLayerDmabuf):
+ (WebCore::m_fd):
+ (WebCore::TextureMapperPlatformLayerDmabuf::~TextureMapperPlatformLayerDmabuf):
+ (WebCore::TextureMapperPlatformLayerDmabuf::validateTexture):
+ (WebCore::TextureMapperPlatformLayerDmabuf::paintToTextureMapper):
+ (WebCore::TextureMapperPlatformLayerDmabuf::clone):
+ * platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.h: Added.
+
2022-02-03 Ryosuke Niwa <[email protected]>
Delete SelectionAcrossShadowBoundariesEnabled
Modified: trunk/Source/WebCore/PlatformGTK.cmake (289105 => 289106)
--- trunk/Source/WebCore/PlatformGTK.cmake 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2022-02-04 07:16:39 UTC (rev 289106)
@@ -26,6 +26,7 @@
"${WEBCORE_DIR}/platform/gtk"
"${WEBCORE_DIR}/platform/graphics/egl"
"${WEBCORE_DIR}/platform/graphics/glx"
+ "${WEBCORE_DIR}/platform/graphics/gbm"
"${WEBCORE_DIR}/platform/graphics/gstreamer"
"${WEBCORE_DIR}/platform/graphics/gtk"
"${WEBCORE_DIR}/platform/graphics/opengl"
Modified: trunk/Source/WebCore/PlatformWPE.cmake (289105 => 289106)
--- trunk/Source/WebCore/PlatformWPE.cmake 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/PlatformWPE.cmake 2022-02-04 07:16:39 UTC (rev 289106)
@@ -24,6 +24,7 @@
"${WEBCORE_DIR}/platform/glib"
"${WEBCORE_DIR}/platform/graphics/egl"
"${WEBCORE_DIR}/platform/graphics/epoxy"
+ "${WEBCORE_DIR}/platform/graphics/gbm"
"${WEBCORE_DIR}/platform/graphics/glx"
"${WEBCORE_DIR}/platform/graphics/gstreamer"
"${WEBCORE_DIR}/platform/graphics/opengl"
Modified: trunk/Source/WebCore/SourcesGTK.txt (289105 => 289106)
--- trunk/Source/WebCore/SourcesGTK.txt 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/SourcesGTK.txt 2022-02-04 07:16:39 UTC (rev 289106)
@@ -101,6 +101,8 @@
platform/graphics/egl/GLContextEGLWayland.cpp @no-unify
platform/graphics/egl/GLContextEGLX11.cpp @no-unify
+platform/graphics/gbm/GBMDevice.cpp
+
platform/graphics/glx/GLContextGLX.cpp
platform/graphics/gtk/ColorGtk.cpp
Modified: trunk/Source/WebCore/SourcesWPE.txt (289105 => 289106)
--- trunk/Source/WebCore/SourcesWPE.txt 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/SourcesWPE.txt 2022-02-04 07:16:39 UTC (rev 289106)
@@ -89,6 +89,8 @@
platform/graphics/egl/GLContextEGL.cpp
platform/graphics/egl/GLContextEGLLibWPE.cpp
+platform/graphics/gbm/GBMDevice.cpp
+
platform/graphics/libwpe/PlatformDisplayLibWPE.cpp
platform/graphics/opentype/OpenTypeVerticalData.cpp
Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (289105 => 289106)
--- trunk/Source/WebCore/platform/TextureMapper.cmake 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake 2022-02-04 07:16:39 UTC (rev 289106)
@@ -59,6 +59,7 @@
)
list(APPEND WebCore_SOURCES
platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp
+ platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp
platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp
platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
Modified: trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -143,6 +143,7 @@
ASSIGN_FUNCTION_TABLE_ENTRY(glDrawBuffers, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glDrawElementsInstanced, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray, success);
+ ASSIGN_FUNCTION_TABLE_ENTRY(glEGLImageTargetTexture2DOES, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glFramebufferRenderbuffer, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glFramebufferTexture2D, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glGenBuffers, success);
Modified: trunk/Source/WebCore/platform/graphics/OpenGLShims.h (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/OpenGLShims.h 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/OpenGLShims.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -78,6 +78,7 @@
typedef void (GLAPIENTRY *glDrawArraysInstancedType) (GLenum, GLint, GLsizei, GLsizei);
typedef void (GLAPIENTRY *glDrawBuffersType) (GLsizei, const GLenum*);
typedef void (GLAPIENTRY *glDrawElementsInstancedType) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei);
+typedef void (GLAPIENTRY *glEGLImageTargetTexture2DOESType) (GLenum target, GLeglImageOES);
typedef void (GLAPIENTRY *glEnableVertexAttribArrayType) (GLuint);
typedef void (GLAPIENTRY *glFramebufferRenderbufferType) (GLenum, GLenum, GLenum, GLuint);
typedef void (GLAPIENTRY *glFramebufferTexture2DType) (GLenum, GLenum, GLenum, GLuint, GLint);
@@ -186,6 +187,7 @@
FUNCTION_TABLE_ENTRY(glDrawArraysInstanced);
FUNCTION_TABLE_ENTRY(glDrawBuffers);
FUNCTION_TABLE_ENTRY(glDrawElementsInstanced);
+ FUNCTION_TABLE_ENTRY(glEGLImageTargetTexture2DOES);
FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray);
FUNCTION_TABLE_ENTRY(glFramebufferRenderbuffer);
FUNCTION_TABLE_ENTRY(glFramebufferTexture2D);
@@ -306,6 +308,7 @@
#define glDrawBuffers LOOKUP_GL_FUNCTION(glDrawBuffers)
#define glDrawElementsInstancedEXT glDrawElementsInstanced
#define glDrawElementsInstanced LOOKUP_GL_FUNCTION(glDrawElementsInstanced)
+#define glEGLImageTargetTexture2DOES LOOKUP_GL_FUNCTION(glEGLImageTargetTexture2DOES)
#define glEnableVertexAttribArray LOOKUP_GL_FUNCTION(glEnableVertexAttribArray)
#define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
#define glFramebufferRenderbuffer LOOKUP_GL_FUNCTION(glFramebufferRenderbuffer)
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -540,14 +540,15 @@
#if USE(COORDINATED_GRAPHICS)
std::swap(m_texture, m_compositorTexture);
std::swap(m_texture, m_intermediateTexture);
+ std::swap(m_textureBacking, m_compositorTextureBacking);
+ std::swap(m_textureBacking, m_intermediateTextureBacking);
+
GL_BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
- GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, m_texture, 0);
+ GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, drawingBufferTextureTarget(), m_texture, 0);
GL_Flush();
if (m_state.boundDrawFBO != m_fbo)
GL_BindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
- else
- GL_BindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_fbo);
#else
if (m_preserveDrawingBufferTexture) {
// Blit m_preserveDrawingBufferTexture into m_texture.
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -43,8 +43,12 @@
#if USE(NICOSIA)
namespace Nicosia {
class GCGLANGLEPipe;
+class GCGLANGLEPipeSource;
class GCGLLayer;
}
+
+struct gbm_device;
+struct gbm_bo;
#endif
namespace WebCore {
@@ -51,6 +55,7 @@
class ExtensionsGL;
class ExtensionsGLANGLE;
+class GLContext;
class HostWindow;
class ImageBuffer;
class MediaPlayer;
@@ -450,11 +455,35 @@
GCGLuint m_intermediateTexture { 0 };
#endif
#if USE(NICOSIA)
-#if USE(ANGLE)
std::unique_ptr<Nicosia::GCGLANGLEPipe> m_nicosiaPipe;
-#else
- std::unique_ptr<Nicosia::GCGLLayer> m_nicosiaLayer;
-#endif
+
+ class EGLImageBacking {
+ WTF_MAKE_FAST_ALLOCATED;
+ public:
+ EGLImageBacking(gbm_device*, PlatformGraphicsContextGLDisplay);
+ ~EGLImageBacking();
+
+ bool reset(int width, int height, bool hasAlpha);
+
+ EGLImage image() const { return m_image; }
+ int fd() const { return m_FD; }
+
+ uint32_t format() const;
+ uint32_t stride() const;
+ private:
+ void releaseResources();
+
+ gbm_device* m_device;
+ PlatformGraphicsContextGLDisplay m_display;
+
+ gbm_bo* m_BO { nullptr };
+ int m_FD { -1 };
+ EGLImage m_image { EGL_NO_IMAGE };
+ };
+
+ std::unique_ptr<EGLImageBacking> m_textureBacking;
+ std::unique_ptr<EGLImageBacking> m_compositorTextureBacking;
+ std::unique_ptr<EGLImageBacking> m_intermediateTextureBacking;
#elif USE(TEXTURE_MAPPER)
std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
#endif
@@ -461,6 +490,7 @@
friend class ExtensionsGLANGLE;
#if USE(NICOSIA)
+ friend class Nicosia::GCGLANGLEPipeSource;
friend class Nicosia::GCGLLayer;
#elif USE(TEXTURE_MAPPER)
friend class TextureMapperGCGLPlatformLayer;
Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -364,6 +364,19 @@
ASSERT(type == Surfaceless || surface != EGL_NO_SURFACE);
RELEASE_ASSERT(m_display.eglDisplay() != EGL_NO_DISPLAY);
RELEASE_ASSERT(context != EGL_NO_CONTEXT);
+
+ if (display.eglCheckVersion(1, 5)) {
+ m_eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEPROC>(eglGetProcAddress("eglCreateImage"));
+ m_eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEPROC>(eglGetProcAddress("eglDestroyImage"));
+ RELEASE_ASSERT(!m_eglCreateImage == !m_eglDestroyImage);
+ } else {
+ const char* extensions = eglQueryString(display.eglDisplay(), EGL_EXTENSIONS);
+ if (GLContext::isExtensionSupported(extensions, "EGL_KHR_image_base")) {
+ m_eglCreateImageKHR = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ m_eglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ }
+ RELEASE_ASSERT(!m_eglCreateImageKHR == !m_eglDestroyImageKHR);
+ }
}
GLContextEGL::~GLContextEGL()
@@ -386,6 +399,31 @@
#endif
}
+EGLImage GLContextEGL::createImage(EGLenum target, EGLClientBuffer clientBuffer, const EGLAttrib* attribList) const
+{
+ if (m_eglCreateImage)
+ return m_eglCreateImage(m_display.eglDisplay(), attribList ? EGL_NO_CONTEXT : m_context, target, clientBuffer, attribList);
+ if (m_eglCreateImageKHR) {
+ Vector<EGLint> intAttribList;
+ for (int i = 0; attribList[i] != EGL_NONE; i += 2) {
+ intAttribList.append(attribList[i]);
+ intAttribList.append(attribList[i+1]);
+ }
+ intAttribList.append(EGL_NONE);
+ return m_eglCreateImageKHR(m_display.eglDisplay(), attribList ? EGL_NO_CONTEXT : m_context, target, clientBuffer, intAttribList.data());
+ }
+ return EGL_NO_IMAGE;
+}
+
+bool GLContextEGL::destroyImage(EGLImage image) const
+{
+ if (m_eglDestroyImage)
+ return m_eglDestroyImage(m_display.eglDisplay(), image);
+ if (m_eglDestroyImageKHR)
+ return m_eglDestroyImageKHR(m_display.eglDisplay(), image);
+ return false;
+}
+
bool GLContextEGL::canRenderToDefaultFramebuffer()
{
return m_type == WindowSurface;
Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -36,11 +36,31 @@
struct wpe_renderer_backend_egl_offscreen_target;
#endif
+typedef intptr_t EGLAttrib;
+typedef unsigned EGLBoolean;
+typedef void *EGLClientBuffer;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
+typedef void *EGLImage;
+typedef void *EGLImageKHR;
typedef void *EGLSurface;
+typedef unsigned EGLenum;
+typedef int32_t EGLint;
+#if !defined(PFNEGLCREATEIMAGEPROC)
+typedef EGLImage (*PFNEGLCREATEIMAGEPROC) (EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLAttrib*);
+#endif
+#if !defined(PFNEGLDESTROYIMAGEPROC)
+typedef EGLBoolean (*PFNEGLDESTROYIMAGEPROC) (EGLDisplay, EGLImage);
+#endif
+#if !defined(PFNEGLCREATEIMAGEKHRPROC)
+typedef EGLImageKHR (*PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay, EGLContext, EGLenum target, EGLClientBuffer, const EGLint* attribList);
+#endif
+#if !defined(PFNEGLDESTROYIMAGEKHRPROC)
+typedef EGLBoolean (*PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay, EGLImageKHR);
+#endif
+
namespace WebCore {
class GLContextEGL final : public GLContext {
@@ -53,6 +73,8 @@
static const char* lastErrorString();
EGLConfig config() const { return m_config; }
+ EGLImage createImage(EGLenum target, EGLClientBuffer, const EGLAttrib*) const;
+ bool destroyImage(EGLImage) const;
virtual ~GLContextEGL();
@@ -106,6 +128,10 @@
EGLSurface m_surface { nullptr };
EGLConfig m_config { nullptr };
EGLSurfaceType m_type;
+ PFNEGLCREATEIMAGEPROC m_eglCreateImage { nullptr };
+ PFNEGLDESTROYIMAGEPROC m_eglDestroyImage { nullptr };
+ PFNEGLCREATEIMAGEKHRPROC m_eglCreateImageKHR { nullptr };
+ PFNEGLDESTROYIMAGEKHRPROC m_eglDestroyImageKHR { nullptr };
#if PLATFORM(X11)
XUniquePixmap m_pixmap;
#endif
Added: trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp (0 => 289106)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2022 Metrological Group B.V.
+ * Copyright (C) 2022 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "GBMDevice.h"
+
+#if USE(ANGLE) && USE(NICOSIA)
+
+#include <fcntl.h>
+#include <gbm.h>
+#include <mutex>
+#include <wtf/ThreadSpecific.h>
+
+namespace WebCore {
+
+static ThreadSpecific<GBMDevice>& threadSpecificDevice()
+{
+ static ThreadSpecific<GBMDevice>* s_gbmDevice;
+ static std::once_flag s_onceFlag;
+ std::call_once(s_onceFlag,
+ [] {
+ s_gbmDevice = new ThreadSpecific<GBMDevice>;
+ });
+ return *s_gbmDevice;
+}
+
+const GBMDevice& GBMDevice::get()
+{
+ return *threadSpecificDevice();
+}
+
+GBMDevice::GBMDevice()
+{
+ int fd;
+ char deviceName[30];
+ for (int i = 128; i < 192; ++i) {
+ snprintf(deviceName, sizeof(deviceName), "/dev/dri/renderD%d", i);
+ fd = open(deviceName, O_RDWR | O_CLOEXEC);
+ if (fd >= 0) {
+ m_device = gbm_create_device(fd);
+ if (m_device)
+ break;
+ close(fd);
+ }
+ }
+}
+
+GBMDevice::~GBMDevice()
+{
+ if (m_device) {
+ gbm_device_destroy(m_device);
+ m_device = nullptr;
+ }
+}
+
+} // namespace WebCore
+
+#endif // USE(ANGLE) && USE(NICOSIA)
Added: trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h (0 => 289106)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMDevice.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2022 Metrological Group B.V.
+ * Copyright (C) 2022 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(ANGLE) && USE(NICOSIA)
+
+struct gbm_device;
+
+namespace WebCore {
+
+class GBMDevice {
+ WTF_MAKE_NONCOPYABLE(GBMDevice);
+ WTF_MAKE_FAST_ALLOCATED();
+public:
+ static const GBMDevice& get();
+
+ GBMDevice();
+ ~GBMDevice();
+
+ struct gbm_device* device() const { return m_device; }
+
+private:
+ struct gbm_device* m_device { nullptr };
+};
+
+} // namespace WebCore
+
+#endif // USE(ANGLE) && USE(NICOSIA)
Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -35,7 +35,7 @@
#include "ImageBuffer.h"
#include "Logging.h"
#include "TextureMapperGL.h"
-#include "TextureMapperPlatformLayerBuffer.h"
+#include "TextureMapperPlatformLayerDmabuf.h"
#include "TextureMapperPlatformLayerProxy.h"
namespace Nicosia {
@@ -57,6 +57,24 @@
return;
m_context.prepareTexture();
+
+ if (m_context.m_compositorTextureBacking) {
+ auto size = m_context.getInternalFramebufferSize();
+ auto format = m_context.m_compositorTextureBacking->format();
+ auto stride = m_context.m_compositorTextureBacking->stride();
+ auto fd = m_context.m_compositorTextureBacking->fd();
+
+ auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(platformLayer()->impl()).proxy();
+ {
+ Locker locker { proxy.lock() };
+ proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerDmabuf>(size, format, stride, fd));
+ }
+
+ m_context.markLayerComposited();
+ return;
+ }
+
+ // Fallback path, read back texture to main memory
RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(m_context.getInternalFramebufferSize(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
if (!imageBuffer)
return;
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -36,7 +36,11 @@
#include "PixelBuffer.h"
#if USE(NICOSIA)
+#include "GBMDevice.h"
#include "NicosiaGCGLANGLEPipe.h"
+
+#include <fcntl.h>
+#include <gbm.h>
#else
#include "TextureMapperGCGLPlatformLayer.h"
#endif
@@ -51,6 +55,13 @@
#endif
#if USE(NICOSIA)
m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this);
+
+ const auto& gbmDevice = GBMDevice::get();
+ if (auto* device = gbmDevice.device()) {
+ m_textureBacking = makeUnique<EGLImageBacking>(device, platformDisplay());
+ m_compositorTextureBacking = makeUnique<EGLImageBacking>(device, platformDisplay());
+ m_intermediateTextureBacking = makeUnique<EGLImageBacking>(device, platformDisplay());
+ }
#else
m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this);
#endif
@@ -112,6 +123,79 @@
GL_ClearColor(0, 0, 0, 0);
}
+#if USE(NICOSIA)
+GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking(gbm_device* device, PlatformGraphicsContextGLDisplay display)
+ : m_device(device)
+ , m_display(display)
+{
+}
+
+GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking()
+{
+ releaseResources();
+}
+
+uint32_t GraphicsContextGLANGLE::EGLImageBacking::format() const
+{
+ if (m_BO)
+ return gbm_bo_get_format(m_BO);
+ return 0;
+}
+
+uint32_t GraphicsContextGLANGLE::EGLImageBacking::stride() const
+{
+ if (m_BO)
+ return gbm_bo_get_stride(m_BO);
+ return 0;
+}
+
+void GraphicsContextGLANGLE::EGLImageBacking::releaseResources()
+{
+ if (m_BO) {
+ gbm_bo_destroy(m_BO);
+ m_BO = nullptr;
+ }
+ if (m_image) {
+ EGL_DestroyImageKHR(m_display, m_image);
+ m_image = EGL_NO_IMAGE;
+ }
+ if (m_FD >= 0) {
+ close(m_FD);
+ m_FD = -1;
+ }
+}
+
+bool GraphicsContextGLANGLE::EGLImageBacking::reset(int width, int height, bool hasAlpha)
+{
+ releaseResources();
+
+ if (!width || !height)
+ return false;
+
+ m_BO = gbm_bo_create(m_device, width, height, hasAlpha ? GBM_BO_FORMAT_ARGB8888 : GBM_BO_FORMAT_XRGB8888, GBM_BO_USE_RENDERING);
+ if (m_BO) {
+ m_FD = gbm_bo_get_fd(m_BO);
+ if (m_FD >= 0) {
+ EGLint imageAttributes[] = {
+ EGL_WIDTH, width,
+ EGL_HEIGHT, height,
+ EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLint>(gbm_bo_get_format(m_BO)),
+ EGL_DMA_BUF_PLANE0_FD_EXT, m_FD,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<EGLint>(gbm_bo_get_stride(m_BO)),
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
+ EGL_NONE
+ };
+ m_image = EGL_CreateImageKHR(m_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)nullptr, imageAttributes);
+ if (m_image)
+ return true;
+ }
+ }
+
+ releaseResources();
+ return false;
+}
+#endif
+
GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
{
GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
@@ -189,18 +273,40 @@
GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB;
GLenum textureTarget = drawingBufferTextureTarget();
GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat;
+
+#if USE(COORDINATED_GRAPHICS)
+ if (m_textureBacking)
+ m_textureBacking->reset(width, height, attrs.alpha);
+ if (m_compositorTextureBacking)
+ m_compositorTextureBacking->reset(width, height, attrs.alpha);
+ if (m_intermediateTextureBacking)
+ m_intermediateTextureBacking->reset(width, height, attrs.alpha);
+#endif
+
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
#if USE(COORDINATED_GRAPHICS)
if (m_compositorTexture) {
GL_BindTexture(textureTarget, m_compositorTexture);
- GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+ if (m_compositorTextureBacking && m_compositorTextureBacking->image())
+ GL_EGLImageTargetTexture2DOES(textureTarget, m_compositorTextureBacking->image());
+ else
+ GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
GL_BindTexture(textureTarget, m_intermediateTexture);
- GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+ if (m_intermediateTextureBacking && m_intermediateTextureBacking->image())
+ GL_EGLImageTargetTexture2DOES(textureTarget, m_intermediateTextureBacking->image());
+ else
+ GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
}
#endif
GL_BindTexture(textureTarget, m_texture);
+#if USE(COORDINATED_GRAPHICS)
+ if (m_textureBacking && m_textureBacking->image())
+ GL_EGLImageTargetTexture2DOES(textureTarget, m_textureBacking->image());
+ else
+#endif
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0);
+
return true;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h (289105 => 289106)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h 2022-02-04 06:58:12 UTC (rev 289105)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -62,7 +62,7 @@
virtual ~TextureMapperPlatformLayerBuffer();
- void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) final;
+ void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) override;
bool canReuseWithoutReset(const IntSize&, GLint internalFormat);
BitmapTextureGL& textureGL() { return static_cast<BitmapTextureGL&>(*m_texture); }
@@ -86,7 +86,7 @@
void setUnmanagedBufferDataHolder(std::unique_ptr<UnmanagedBufferDataHolder> holder) { m_unmanagedBufferDataHolder = WTFMove(holder); }
void setExtraFlags(TextureMapperGL::Flags flags) { m_extraFlags = flags; }
- std::unique_ptr<TextureMapperPlatformLayerBuffer> clone();
+ virtual std::unique_ptr<TextureMapperPlatformLayerBuffer> clone();
class HolePunchClient {
WTF_MAKE_FAST_ALLOCATED();
@@ -97,14 +97,16 @@
void setHolePunchClient(std::unique_ptr<HolePunchClient>&& client) { m_holePunchClient = WTFMove(client); }
- const TextureVariant& textureVariant() { return m_variant; }
+ const TextureVariant& textureVariant() const { return m_variant; }
+ IntSize size() const { return m_size; }
+protected:
+ TextureVariant m_variant;
+
private:
-
RefPtr<BitmapTexture> m_texture;
MonotonicTime m_timeLastUsed;
- TextureVariant m_variant;
IntSize m_size;
GLint m_internalFormat;
TextureMapperGL::Flags m_extraFlags;
Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp (0 => 289106)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp 2022-02-04 07:16:39 UTC (rev 289106)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2022 Metrological Group B.V.
+ * Copyright (C) 2022 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "TextureMapperPlatformLayerDmabuf.h"
+
+#if USE(ANGLE) && USE(NICOSIA)
+
+#include "GLContextEGL.h"
+
+#if USE(LIBEPOXY)
+#include "EpoxyEGL.h"
+#else
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#endif
+
+#include <unistd.h>
+
+namespace WebCore {
+
+static constexpr uint32_t createFourCC(char a, char b, char c, char d)
+{
+ return uint32_t(a) | (uint32_t(b) << 8) | (uint32_t(c) << 16) | (uint32_t(d) << 24);
+}
+
+static GLint fourCCToGLFormat(uint32_t format)
+{
+ ASSERT((format == createFourCC('X', 'R', '2', '4')) || (format == createFourCC('A', 'R', '2', '4')));
+ return (format == createFourCC('A', 'R', '2', '4')) ? GL_RGBA : GL_RGB;
+}
+
+static bool formatHasAlpha(uint32_t format)
+{
+ ASSERT((format == createFourCC('X', 'R', '2', '4')) || (format == createFourCC('A', 'R', '2', '4')));
+ return (format == createFourCC('A', 'R', '2', '4')) ? true : false;
+}
+
+TextureMapperPlatformLayerDmabuf::TextureMapperPlatformLayerDmabuf(const IntSize& size, uint32_t format, uint32_t stride, int fd)
+ : TextureMapperPlatformLayerBuffer({ RGBTexture { 0 } }, size, TextureMapperGL::ShouldFlipTexture | (formatHasAlpha(format) ? TextureMapperGL::ShouldBlend : 0), fourCCToGLFormat(format))
+ , m_format(format)
+ , m_stride(stride)
+ , m_fd(dup(fd))
+{
+}
+
+TextureMapperPlatformLayerDmabuf::~TextureMapperPlatformLayerDmabuf()
+{
+ ASSERT(std::holds_alternative<RGBTexture>(m_variant));
+ auto& texture = std::get<RGBTexture>(m_variant);
+ if (texture.id)
+ glDeleteTextures(1, &texture.id);
+ close(m_fd);
+}
+
+void TextureMapperPlatformLayerDmabuf::validateTexture()
+{
+ ASSERT(std::holds_alternative<RGBTexture>(m_variant));
+ auto& texture = std::get<RGBTexture>(m_variant);
+ if (texture.id)
+ return;
+
+ auto* context = GLContext::current();
+ ASSERT(context->isEGLContext());
+
+ context->makeContextCurrent();
+
+ auto size = TextureMapperPlatformLayerBuffer::size();
+ EGLAttrib imageAttributes[] = {
+ EGL_WIDTH, size.width(),
+ EGL_HEIGHT, size.height(),
+ EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLAttrib>(m_format),
+ EGL_DMA_BUF_PLANE0_FD_EXT, m_fd,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<EGLAttrib>(m_stride),
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
+ EGL_NONE
+ };
+ auto image = downcast<GLContextEGL>(*context).createImage(EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)nullptr, imageAttributes);
+ if (!image)
+ return;
+
+ glGenTextures(1, &texture.id);
+ glBindTexture(GL_TEXTURE_2D, texture.id);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ RELEASE_ASSERT(downcast<GLContextEGL>(*context).destroyImage(image));
+}
+
+void TextureMapperPlatformLayerDmabuf::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity)
+{
+ validateTexture();
+ TextureMapperPlatformLayerBuffer::paintToTextureMapper(textureMapper, targetRect, modelViewMatrix, opacity);
+}
+
+std::unique_ptr<TextureMapperPlatformLayerBuffer> TextureMapperPlatformLayerDmabuf::clone()
+{
+ validateTexture();
+ return TextureMapperPlatformLayerBuffer::clone();
+}
+
+} // namespace WebCore
+
+#endif // USE(ANGLE) && USE(NICOSIA)
Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.h (0 => 289106)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.h 2022-02-04 07:16:39 UTC (rev 289106)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 Metrological Group B.V.
+ * Copyright (C) 2022 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(ANGLE) && USE(NICOSIA)
+
+#include "TextureMapperPlatformLayerBuffer.h"
+
+namespace WebCore {
+
+class TextureMapperPlatformLayerDmabuf : public TextureMapperPlatformLayerBuffer {
+ WTF_MAKE_NONCOPYABLE(TextureMapperPlatformLayerDmabuf);
+ WTF_MAKE_FAST_ALLOCATED();
+public:
+ TextureMapperPlatformLayerDmabuf(const IntSize&, uint32_t format, uint32_t stride, int fd);
+
+ virtual ~TextureMapperPlatformLayerDmabuf();
+
+private:
+ void validateTexture();
+
+ void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity) final;
+ std::unique_ptr<TextureMapperPlatformLayerBuffer> clone() final;
+
+ uint32_t m_format;
+ uint32_t m_stride;
+ int m_fd;
+};
+
+} // namespace WebCore
+
+#endif // USE(ANGLE) && USE(NICOSIA)