6#include <QtOpenGL/QOpenGLTexture>
7#include <QtGui/QOpenGLContext>
13 , m_integration(integration)
20 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
21 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
23#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
25 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_A8;
26 egl_format = EGL_DRM_BUFFER_FORMAT_A8_MESA;
30 qWarning(
"DrmEglServerBuffer: unsupported format");
31 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
32 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
35 EGLint imageAttribs[] = {
38 EGL_DRM_BUFFER_FORMAT_MESA, egl_format,
39 EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
47 qWarning(
"DrmEglServerBuffer: Failed to export egl image");
64 auto *bufferResource = resourceMap().value(client);
65 if (!bufferResource) {
66 auto integrationResource = m_integration->resourceMap().value(client);
67 if (!integrationResource) {
68 qWarning(
"DrmEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the drm_egl interface");
71 struct ::wl_resource *drm_egl_integration_resource = integrationResource->handle;
72 Resource *resource =
add(client, 1);
73 m_integration->send_server_buffer_created(drm_egl_integration_resource, resource->handle, m_name,
m_size.
width(),
m_size.
height(), m_stride, m_drm_format);
74 return resource->handle;
76 return bufferResource->handle;
83 qWarning(
"DrmEglServerBuffer::toOpenGlTexture: no texture defined");
90 return resourceMap().size() > 0;
106 if (!m_egl_display) {
107 qWarning(
"Can't initialize drm egl server buffer integration. Missing egl display from platform plugin");
111 const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
112 if (!extensionString || !strstr(extensionString,
"EGL_KHR_image")) {
113 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n");
116 m_egl_create_image =
reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC
>(eglGetProcAddress(
"eglCreateImageKHR"));
117 m_egl_destroy_image =
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC
>(eglGetProcAddress(
"eglDestroyImageKHR"));
118 if (!m_egl_create_image || !m_egl_destroy_image) {
119 qWarning(
"Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
123 if (!extensionString || !strstr(extensionString,
"EGL_MESA_drm_image")) {
124 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_MESA_drm_image extension.\n");
128 m_egl_create_drm_image =
reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC
>(eglGetProcAddress(
"eglCreateDRMImageMESA"));
129 m_egl_export_drm_image =
reinterpret_cast<PFNEGLEXPORTDRMIMAGEMESAPROC
>(eglGetProcAddress(
"eglExportDRMImageMESA"));
130 if (!m_egl_create_drm_image || !m_egl_export_drm_image) {
131 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find eglCreateDRMImageMESA or eglExportDRMImageMESA.\n");
135 m_gl_egl_image_target_texture_2d =
reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC
>(eglGetProcAddress(
"glEGLImageTargetTexture2DOES"));
136 if (!m_gl_egl_image_target_texture_2d) {
137 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n");
141 QtWaylandServer::qt_drm_egl_server_buffer::init(
compositor->display(), 1);
151#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
bool supportsFormat(QtWayland::ServerBuffer::Format format) const override
~DrmEglServerBufferIntegration() override
EGLBoolean eglExportDRMImageMESA(EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride)
QtWayland::ServerBuffer * createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
bool initializeHardware(QWaylandCompositor *) override
EGLImageKHR eglCreateDRMImageMESA(const EGLint *attrib_list)
DrmEglServerBufferIntegration()
bool bufferInUse() override
struct::wl_resource * resourceForClient(struct ::wl_client *) override
QOpenGLTexture * toOpenGlTexture() override
DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
static QPlatformNativeInterface * platformNativeInterface()
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
const uchar * constBits() const
Returns a pointer to the first pixel data.
void release()
Unbinds this texture from the currently active texture unit.
bool create()
Creates the underlying OpenGL texture object.
void bind()
Binds this texture to the currently active texture unit ready for rendering.
void setSize(int width, int height=1, int depth=1)
Sets the dimensions of this texture object to width, height, and depth.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
EGLImageKHR EGLint EGLint * handle
Combined button and popup list for selecting options.
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
static QOpenGLCompositor * compositor
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)