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