7#include "qwayland-server-linux-dmabuf-unstable-v1.h"
9#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
10#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h>
12#include <QtOpenGL/QOpenGLTexture>
13#include <QtCore/QObject>
14#include <QtCore/QHash>
15#include <QtCore/QSize>
16#include <QtCore/QTextStream>
19#include <QtGui/QOpenGLContext>
20#include <QtCore/QMutex>
23#include <EGL/eglext.h>
26#ifndef DRM_FORMAT_RESERVED
27#define DRM_FORMAT_RESERVED ((1ULL
<< 56
) - 1
)
29#ifndef DRM_FORMAT_MOD_VENDOR_NONE
30#define DRM_FORMAT_MOD_VENDOR_NONE 0
32#ifndef DRM_FORMAT_MOD_LINEAR
33#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0
)
35#ifndef DRM_FORMAT_MOD_INVALID
40#ifndef EGL_WL_bind_wayland_display
41typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy,
struct wl_display *display);
42typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy,
struct wl_display *display);
47class QWaylandCompositor;
48class QWaylandResource;
71 QHash<uint32_t, QList<uint64_t>> m_modifiers;
82 bool handleCreateParams(Resource *resource,
int width,
int height, uint format, uint flags);
87 QMap<uint, Plane> m_planes;
92 void zwp_linux_buffer_params_v1_add(Resource *resource, int32_t fd, uint32_t plane_idx, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo)
override;
97 friend class LinuxDmabufClientBufferIntegrationPrivate;
106 void initImage(uint32_t plane, EGLImageKHR image);
107 void initTexture(uint32_t plane, QOpenGLTexture *texture);
109 inline uint32_t
flags()
const {
return m_flags; }
110 inline uint32_t
drmFormat()
const {
return m_drmFormat; }
111 inline Plane&
plane(uint index) {
return m_planes.at(index); }
113 inline EGLImageKHR
image(uint32_t plane) {
return m_eglImages.at(plane); }
121 uint32_t m_flags = 0;
124 uint32_t m_planesNumber = 1;
126 std::array<EGLImageKHR,
MaxDmabufPlanes> m_eglImages = { {EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR} };
127 std::array<QOpenGLTexture *, MaxDmabufPlanes> m_textures = { {
nullptr,
nullptr,
nullptr,
nullptr} };
128 std::array<QOpenGLContext *, MaxDmabufPlanes> m_texturesContext = { {
nullptr,
nullptr,
nullptr,
nullptr} };
130 QMutex m_texturesLock;
132 void freeResources();
QtWayland::ClientBuffer * createBufferFor(wl_resource *resource) override
bool importBuffer(wl_resource *resource, LinuxDmabufWlBuffer *linuxDmabufBuffer)
void deleteImage(EGLImageKHR image)
LinuxDmabufClientBufferIntegration()
~LinuxDmabufClientBufferIntegration() override
void initializeHardware(struct ::wl_display *display) override
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d
void removeBuffer(wl_resource *resource)
~LinuxDmabufClientBuffer() override
void setDestroyed() override
QOpenGLTexture * toOpenGlTexture(int plane) override
QSize size() const override
QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const override
QWaylandSurface::Origin origin() const override
void zwp_linux_buffer_params_v1_create_immed(Resource *resource, uint32_t buffer_id, int32_t width, int32_t height, uint32_t format, uint32_t flags) override
~LinuxDmabufParams() override
LinuxDmabufParams(LinuxDmabufClientBufferIntegration *clientBufferIntegration, wl_resource *resource)
void zwp_linux_buffer_params_v1_create(Resource *resource, int32_t width, int32_t height, uint32_t format, uint32_t flags) override
void zwp_linux_buffer_params_v1_destroy(Resource *resource) override
void zwp_linux_buffer_params_v1_add(Resource *resource, int32_t fd, uint32_t plane_idx, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo) override
void zwp_linux_buffer_params_v1_destroy_resource(Resource *resource) override
Plane & plane(uint index)
void initTexture(uint32_t plane, QOpenGLTexture *texture)
uint32_t drmFormat() const
void initImage(uint32_t plane, EGLImageKHR image)
void buffer_destroy(Resource *resource) override
~LinuxDmabufWlBuffer() override
LinuxDmabufWlBuffer(::wl_client *client, LinuxDmabufClientBufferIntegration *clientBufferIntegration, uint id=0)
static const uint32_t MaxDmabufPlanes
QOpenGLTexture * texture(uint32_t plane) const
void buffer_destroy_resource(Resource *resource) override
EGLImageKHR image(uint32_t plane)
uint32_t planesNumber() const
void zwp_linux_dmabuf_v1_bind_resource(Resource *resource) override
LinuxDmabuf(wl_display *display, LinuxDmabufClientBufferIntegration *clientBufferIntegration)
void setSupportedModifiers(const QHash< uint32_t, QList< uint64_t > > &modifiers)
void zwp_linux_dmabuf_v1_create_params(Resource *resource, uint32_t params_id) override
#define DRM_FORMAT_RESERVED
EGLint EGLint EGLuint64KHR EGLBoolean EGLint * num_modifiers
QT_BEGIN_NAMESPACE typedef struct wl_resource EGLint attribute
EGLint EGLint EGLuint64KHR EGLBoolean * external_only
EGLint EGLint max_modifiers
EGLint EGLint EGLint * num_formats
QT_BEGIN_NAMESPACE typedef struct wl_resource * buffer
QT_BEGIN_NAMESPACE typedef struct wl_resource EGLint EGLint * value
EGLint EGLint EGLuint64KHR * modifiers
Combined button and popup list for selecting options.