1/****************************************************************************
2**
3** Copyright (C) 2020 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QEGLSTREAMCONVENIENCE_H
41#define QEGLSTREAMCONVENIENCE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtGui/qtguiglobal.h>
55
56#include <QtGui/private/qt_egl_p.h>
57
58// This provides runtime EGLDevice/Output/Stream support even when eglext.h in
59// the sysroot is not up-to-date.
60
61#ifndef EGL_VERSION_1_5
62typedef intptr_t EGLAttrib;
63#endif
64
65#ifndef EGL_EXT_platform_base
66typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
67#endif
68
69#ifndef EGL_EXT_device_base
70typedef void *EGLDeviceEXT;
71#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0))
72typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
73typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name);
74#endif
75
76#ifndef EGL_EXT_output_base
77typedef void *EGLOutputLayerEXT;
78typedef void *EGLOutputPortEXT;
79#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0)
80typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers);
81typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports);
82typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value);
83typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value);
84typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name);
85typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value);
86typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name);
87#endif
88
89#ifndef EGL_KHR_stream
90typedef void *EGLStreamKHR;
91typedef quint64 EGLuint64KHR;
92#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
93#define EGL_STREAM_STATE_KHR 0x3214
94#define EGL_STREAM_STATE_CREATED_KHR 0x3215
95#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
96#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
97#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
98#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
99#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
100#define EGL_BAD_STREAM_KHR 0x321B
101#define EGL_BAD_STATE_KHR 0x321C
102typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list);
103typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
104typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
105typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
106typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
107#endif
108
109#ifndef EGL_KHR_stream_fifo
110#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
111#endif
112
113#ifndef EGL_KHR_stream_producer_eglsurface
114#define EGL_STREAM_BIT_KHR 0x0800
115typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
116#endif
117
118#ifndef EGL_KHR_stream_cross_process_fd
119typedef int EGLNativeFileDescriptorKHR;
120#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
121typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
122typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
123#endif
124
125#ifndef EGL_KHR_stream_consumer_gltexture
126typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
127typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
128typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
129#endif
130
131#ifndef EGL_EXT_stream_consumer_egloutput
132typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer);
133#endif
134
135#ifndef EGL_EXT_platform_device
136#define EGL_PLATFORM_DEVICE_EXT 0x313F
137#endif
138
139#ifndef EGL_EXT_device_drm
140#define EGL_DRM_DEVICE_FILE_EXT 0x3233
141#endif
142
143#ifndef EGL_EXT_output_drm
144#define EGL_DRM_CRTC_EXT 0x3234
145#define EGL_DRM_PLANE_EXT 0x3235
146#endif
147
148#ifndef EGL_PLATFORM_X11_KHR
149#define EGL_PLATFORM_X11_KHR 0x31D5
150#endif
151
152#ifndef EGL_NV_stream_attrib
153typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBNVPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list);
154typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value);
155typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value);
156typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
157typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
158#endif
159
160QT_BEGIN_NAMESPACE
161
162class Q_GUI_EXPORT QEGLStreamConvenience
163{
164public:
165 QEGLStreamConvenience();
166 void initialize(EGLDisplay dpy);
167
168 PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display;
169 PFNEGLQUERYDEVICESEXTPROC query_devices;
170 PFNEGLQUERYDEVICESTRINGEXTPROC query_device_string;
171 PFNEGLCREATESTREAMKHRPROC create_stream;
172 PFNEGLCREATESTREAMATTRIBNVPROC create_stream_attrib_nv;
173 PFNEGLSETSTREAMATTRIBNVPROC set_stream_attrib_nv;
174 PFNEGLQUERYSTREAMATTRIBNVPROC query_stream_attrib_nv;
175 PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC acquire_stream_attrib_nv;
176 PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC release_stream_attrib_nv;
177 PFNEGLDESTROYSTREAMKHRPROC destroy_stream;
178 PFNEGLSTREAMATTRIBKHRPROC stream_attrib;
179 PFNEGLQUERYSTREAMKHRPROC query_stream;
180 PFNEGLQUERYSTREAMU64KHRPROC query_stream_u64;
181 PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC create_stream_producer_surface;
182 PFNEGLSTREAMCONSUMEROUTPUTEXTPROC stream_consumer_output;
183 PFNEGLGETOUTPUTLAYERSEXTPROC get_output_layers;
184 PFNEGLGETOUTPUTPORTSEXTPROC get_output_ports;
185 PFNEGLOUTPUTLAYERATTRIBEXTPROC output_layer_attrib;
186 PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC query_output_layer_attrib;
187 PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC query_output_layer_string;
188 PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC query_output_port_attrib;
189 PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC query_output_port_string;
190 PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC get_stream_file_descriptor;
191 PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC create_stream_from_file_descriptor;
192 PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC stream_consumer_gltexture;
193 PFNEGLSTREAMCONSUMERACQUIREKHRPROC stream_consumer_acquire;
194 PFNEGLSTREAMCONSUMERRELEASEKHRPROC stream_consumer_release;
195
196 bool initialized;
197
198 bool has_egl_platform_device;
199 bool has_egl_device_base;
200 bool has_egl_stream;
201 bool has_egl_stream_producer_eglsurface;
202 bool has_egl_stream_consumer_egloutput;
203 bool has_egl_output_drm;
204 bool has_egl_output_base;
205 bool has_egl_stream_cross_process_fd;
206 bool has_egl_stream_consumer_gltexture;
207};
208
209QT_END_NAMESPACE
210
211#endif
212