Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
drmeglserverbufferintegration.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef DRMEGLSERVERBUFFERINTEGRATION_H
5#define DRMEGLSERVERBUFFERINTEGRATION_H
6
7#include <QtCore/QVariant>
8#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
9
10#include "qwayland-server-drm-egl-server-buffer.h"
11
12#include <QtGui/QWindow>
13#include <QtGui/qpa/qplatformnativeinterface.h>
14#include <QtGui/QGuiApplication>
15
16#include <QtWaylandCompositor/qwaylandcompositor.h>
17#include <QtWaylandCompositor/private/qwayland-server-server-buffer-extension.h>
18
19#include <QtCore/QDebug>
20#include <EGL/egl.h>
21#include <EGL/eglext.h>
22
23#ifndef EGL_KHR_image
24typedef void *EGLImageKHR;
25typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
26typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
27#endif
28
29#ifndef GL_OES_EGL_image
31#endif
32#ifndef EGL_MESA_drm_image
33typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
34typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
35#endif
36
37QT_BEGIN_NAMESPACE
38
39class DrmEglServerBufferIntegration;
40class QImage;
41
43{
44public:
45 DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format);
46
47 struct ::wl_resource *resourceForClient(struct ::wl_client *) override;
48 bool bufferInUse() override;
50
51private:
52 DrmEglServerBufferIntegration *m_integration = nullptr;
53
54 EGLImageKHR m_image;
55
56 int32_t m_name;
57 int32_t m_stride;
58 QOpenGLTexture *m_texture = nullptr;
59 QtWaylandServer::qt_drm_egl_server_buffer::format m_drm_format;
60};
61
65{
66public:
69
70 bool initializeHardware(QWaylandCompositor *) override;
71
72 bool supportsFormat(QtWayland::ServerBuffer::Format format) const override;
73 QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override;
74
75 EGLDisplay display() const { return m_egl_display; }
76
77 inline EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
78 inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image);
79 inline EGLImageKHR eglCreateDRMImageMESA (const EGLint *attrib_list);
80 inline EGLBoolean eglExportDRMImageMESA (EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
81 inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
82
83private:
84 EGLDisplay m_egl_display = EGL_NO_DISPLAY;
85 PFNEGLCREATEDRMIMAGEMESAPROC m_egl_create_drm_image;
86 PFNEGLEXPORTDRMIMAGEMESAPROC m_egl_export_drm_image;
87 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture_2d;
88
89 PFNEGLCREATEIMAGEKHRPROC m_egl_create_image;
90 PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image;
91};
92
93EGLImageKHR DrmEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
94{
95 if (!m_egl_create_image) {
96 qWarning("DrmEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR");
97 return EGL_NO_IMAGE_KHR;
98 }
99 return m_egl_create_image(m_egl_display, ctx, target, buffer,attrib_list);
100}
101
103{
104 if (!m_egl_destroy_image) {
105 qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglDestroyImageKHR");
106 return false;
107 }
108 return m_egl_destroy_image(m_egl_display, image);
109}
110
111EGLImageKHR DrmEglServerBufferIntegration::eglCreateDRMImageMESA (const EGLint *attrib_list)
112{
113 if (m_egl_create_drm_image)
114 return m_egl_create_drm_image(m_egl_display, attrib_list);
115 else
116 qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglCreateDRMImageMESA");
117 return EGL_NO_IMAGE_KHR;
118
119}
120
121EGLBoolean DrmEglServerBufferIntegration::eglExportDRMImageMESA (EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride)
122{
123 if (m_egl_export_drm_image)
124 return m_egl_export_drm_image(m_egl_display, image, name, handle, stride);
125 else
126 qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglExportDRMImageMESA");
127 return 0;
128}
129
130void DrmEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
131{
132 if (m_gl_egl_image_target_texture_2d)
133 return m_gl_egl_image_target_texture_2d(target, image);
134 else
135 qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function glEGLImageTargetTexture2DOES");
136}
137QT_END_NAMESPACE
138
139#endif
bool supportsFormat(QtWayland::ServerBuffer::Format format) const 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 eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
EGLImageKHR eglCreateDRMImageMESA(const EGLint *attrib_list)
EGLBoolean eglDestroyImageKHR(EGLImageKHR image)
QOpenGLTexture * toOpenGlTexture() override
DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
GLeglImageOES image
typedef void(GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target
Combined button and popup list for selecting options.