qeglplatformcontext.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the plugins of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qeglplatformcontext_p.h"-
35#include "qeglconvenience_p.h"-
36#include "qeglpbuffer_p.h"-
37#include <qpa/qplatformwindow.h>-
38#include <QOpenGLContext>-
39#include <QtPlatformHeaders/QEGLNativeContext>-
40#include <QDebug>-
41-
42#ifdef Q_OS_ANDROID-
43#include <QtCore/private/qjnihelpers_p.h>-
44#endif-
45-
46QT_BEGIN_NAMESPACE-
47-
48/*!-
49 \class QEGLPlatformContext-
50 \brief An EGL context implementation.-
51 \since 5.2-
52 \internal-
53 \ingroup qpa-
54-
55 Implement QPlatformOpenGLContext using EGL. To use it in platform-
56 plugins a subclass must be created since-
57 eglSurfaceForPlatformSurface() has to be reimplemented. This-
58 function is used for mapping platform surfaces (windows) to EGL-
59 surfaces and is necessary since different platform plugins may-
60 have different ways of handling native windows (for example, a-
61 plugin may choose not to back every platform window by a real EGL-
62 surface). Other than that, no further customization is necessary.-
63 */-
64-
65// Constants from EGL_KHR_create_context-
66#ifndef EGL_CONTEXT_MINOR_VERSION_KHR-
67#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB-
68#endif-
69#ifndef EGL_CONTEXT_FLAGS_KHR-
70#define EGL_CONTEXT_FLAGS_KHR 0x30FC-
71#endif-
72#ifndef EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR-
73#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD-
74#endif-
75#ifndef EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR-
76#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001-
77#endif-
78#ifndef EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR-
79#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002-
80#endif-
81#ifndef EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR-
82#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001-
83#endif-
84#ifndef EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR-
85#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002-
86#endif-
87-
88// Constants for OpenGL which are not available in the ES headers.-
89#ifndef GL_CONTEXT_FLAGS-
90#define GL_CONTEXT_FLAGS 0x821E-
91#endif-
92#ifndef GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT-
93#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001-
94#endif-
95#ifndef GL_CONTEXT_FLAG_DEBUG_BIT-
96#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002-
97#endif-
98#ifndef GL_CONTEXT_PROFILE_MASK-
99#define GL_CONTEXT_PROFILE_MASK 0x9126-
100#endif-
101#ifndef GL_CONTEXT_CORE_PROFILE_BIT-
102#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001-
103#endif-
104#ifndef GL_CONTEXT_COMPATIBILITY_PROFILE_BIT-
105#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002-
106#endif-
107-
108QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,-
109 EGLConfig *config, const QVariant &nativeHandle, Flags flags)-
110 : m_eglDisplay(display)-
111 , m_swapInterval(-1)-
112 , m_swapIntervalEnvChecked(false)-
113 , m_swapIntervalFromEnv(-1)-
114 , m_flags(flags)-
115{-
116 if (nativeHandle.isNull()) {
nativeHandle.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
117 m_eglConfig = config ? *config : q_configFromGLFormat(display, format);
configDescription
TRUEnever evaluated
FALSEnever evaluated
0
118 m_ownsContext = true;-
119 init(format, share);-
120 } else {
never executed: end of block
0
121 m_ownsContext = false;-
122 adopt(nativeHandle, share);-
123 }
never executed: end of block
0
124}-
125-
126void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLContext *share)-
127{-
128 m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig);-
129 // m_format now has the renderableType() resolved (it cannot be Default anymore)-
130 // but does not yet contain version, profile, options.-
131 m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0;
shareDescription
TRUEnever evaluated
FALSEnever evaluated
0
132-
133 QVector<EGLint> contextAttrs;-
134 contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);-
135 contextAttrs.append(format.majorVersion());-
136 const bool hasKHRCreateContext = q_hasEglExtension(m_eglDisplay, "EGL_KHR_create_context");-
137 if (hasKHRCreateContext) {
hasKHRCreateContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
138 contextAttrs.append(EGL_CONTEXT_MINOR_VERSION_KHR);-
139 contextAttrs.append(format.minorVersion());-
140 int flags = 0;-
141 // The debug bit is supported both for OpenGL and OpenGL ES.-
142 if (format.testOption(QSurfaceFormat::DebugContext))
format.testOpt...:DebugContext)Description
TRUEnever evaluated
FALSEnever evaluated
0
143 flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
never executed: flags |= 0x00000001;
0
144 // The fwdcompat bit is only for OpenGL 3.0+.-
145 if (m_format.renderableType() == QSurfaceFormat::OpenGL
m_format.rende...Format::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
0
146 && format.majorVersion() >= 3
format.majorVersion() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
147 && !format.testOption(QSurfaceFormat::DeprecatedFunctions))
!format.testOp...atedFunctions)Description
TRUEnever evaluated
FALSEnever evaluated
0
148 flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
never executed: flags |= 0x00000002;
0
149 if (flags) {
flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 contextAttrs.append(EGL_CONTEXT_FLAGS_KHR);-
151 contextAttrs.append(flags);-
152 }
never executed: end of block
0
153 // Profiles are OpenGL only and mandatory in 3.2+. The value is silently ignored for < 3.2.-
154 if (m_format.renderableType() == QSurfaceFormat::OpenGL) {
m_format.rende...Format::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
0
155 contextAttrs.append(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);-
156 contextAttrs.append(format.profile() == QSurfaceFormat::CoreProfile-
157 ? EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR-
158 : EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);-
159 }
never executed: end of block
0
160 }
never executed: end of block
0
161 contextAttrs.append(EGL_NONE);-
162 m_contextAttrs = contextAttrs;-
163-
164 switch (m_format.renderableType()) {-
165 case QSurfaceFormat::OpenVG:
never executed: case QSurfaceFormat::OpenVG:
0
166 m_api = EGL_OPENVG_API;-
167 break;
never executed: break;
0
168#ifdef EGL_VERSION_1_4-
169 case QSurfaceFormat::OpenGL:
never executed: case QSurfaceFormat::OpenGL:
0
170 m_api = EGL_OPENGL_API;-
171 break;
never executed: break;
0
172#endif // EGL_VERSION_1_4-
173 default:
never executed: default:
0
174 m_api = EGL_OPENGL_ES_API;-
175 break;
never executed: break;
0
176 }-
177-
178 eglBindAPI(m_api);-
179 m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData());-
180 if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) {
m_eglContext =...(EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
m_shareContext...(EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
181 m_shareContext = 0;-
182 m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData());-
183 }
never executed: end of block
0
184-
185 if (m_eglContext == EGL_NO_CONTEXT) {
m_eglContext =...(EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
186 qWarning("QEGLPlatformContext: Failed to create context: %x", eglGetError());-
187 return;
never executed: return;
0
188 }-
189-
190 static const bool printConfig = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEBUG");-
191 if (printConfig) {
printConfigDescription
TRUEnever evaluated
FALSEnever evaluated
0
192 qDebug() << "Created context for format" << format << "with config:";-
193 q_printEglConfig(m_eglDisplay, m_eglConfig);-
194 }
never executed: end of block
0
195-
196 // Cannot just call updateFormatFromGL() since it relies on virtuals. Defer it to initialize().-
197}
never executed: end of block
0
198-
199void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLContext *share)-
200{-
201 if (!nativeHandle.canConvert<QEGLNativeContext>()) {
!nativeHandle....tiveContext>()Description
TRUEnever evaluated
FALSEnever evaluated
0
202 qWarning("QEGLPlatformContext: Requires a QEGLNativeContext");-
203 return;
never executed: return;
0
204 }-
205 QEGLNativeContext handle = nativeHandle.value<QEGLNativeContext>();-
206 EGLContext context = handle.context();-
207 if (!context) {
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
208 qWarning("QEGLPlatformContext: No EGLContext given");-
209 return;
never executed: return;
0
210 }-
211-
212 // A context belonging to a given EGLDisplay cannot be used with another one.-
213 if (handle.display() != m_eglDisplay) {
handle.display...= m_eglDisplayDescription
TRUEnever evaluated
FALSEnever evaluated
0
214 qWarning("QEGLPlatformContext: Cannot adopt context from different display");-
215 return;
never executed: return;
0
216 }-
217-
218 // Figure out the EGLConfig.-
219 EGLint value = 0;-
220 eglQueryContext(m_eglDisplay, context, EGL_CONFIG_ID, &value);-
221 EGLint n = 0;-
222 EGLConfig cfg;-
223 const EGLint attribs[] = { EGL_CONFIG_ID, value, EGL_NONE };-
224 if (eglChooseConfig(m_eglDisplay, attribs, &cfg, 1, &n) && n == 1) {
eglChooseConfi..., &cfg, 1, &n)Description
TRUEnever evaluated
FALSEnever evaluated
n == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
225 m_eglConfig = cfg;-
226 m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig);-
227 } else {
never executed: end of block
0
228 qWarning("QEGLPlatformContext: Failed to get framebuffer configuration for context");-
229 }
never executed: end of block
0
230-
231 // Fetch client API type.-
232 value = 0;-
233 eglQueryContext(m_eglDisplay, context, EGL_CONTEXT_CLIENT_TYPE, &value);-
234 if (value == EGL_OPENGL_API || value == EGL_OPENGL_ES_API) {
value == 0x30A2Description
TRUEnever evaluated
FALSEnever evaluated
value == 0x30A0Description
TRUEnever evaluated
FALSEnever evaluated
0
235 m_api = value;-
236 eglBindAPI(m_api);-
237 } else {
never executed: end of block
0
238 qWarning("QEGLPlatformContext: Failed to get client API type");-
239 m_api = EGL_OPENGL_ES_API;-
240 }
never executed: end of block
0
241-
242 m_eglContext = context;-
243 m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0;
shareDescription
TRUEnever evaluated
FALSEnever evaluated
0
244 updateFormatFromGL();-
245}
never executed: end of block
0
246-
247void QEGLPlatformContext::initialize()-
248{-
249 if (m_eglContext != EGL_NO_CONTEXT)
m_eglContext !...(EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
250 updateFormatFromGL();
never executed: updateFormatFromGL();
0
251}
never executed: end of block
0
252-
253// Base implementation for pbuffers. Subclasses will handle the specialized cases for-
254// platforms without pbuffers.-
255EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface()-
256{-
257 // Make the context current to ensure the GL version query works. This needs a surface too.-
258 const EGLint pbufferAttributes[] = {-
259 EGL_WIDTH, 1,-
260 EGL_HEIGHT, 1,-
261 EGL_LARGEST_PBUFFER, EGL_FALSE,-
262 EGL_NONE-
263 };-
264-
265 // Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead,-
266 // do what QEGLPbuffer would do: request a config with the same attributes but with-
267 // PBUFFER_BIT set.-
268 EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);-
269-
270 return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
never executed: return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
0
271}-
272-
273void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface)-
274{-
275 eglDestroySurface(m_eglDisplay, surface);-
276}
never executed: end of block
0
277-
278void QEGLPlatformContext::runGLChecks()-
279{-
280 // Nothing to do here, subclasses may override in order to perform OpenGL-
281 // queries needing a context.-
282}-
283-
284void QEGLPlatformContext::updateFormatFromGL()-
285{-
286#ifndef QT_NO_OPENGL-
287 // Have to save & restore to prevent QOpenGLContext::currentContext() from becoming-
288 // inconsistent after QOpenGLContext::create().-
289 EGLDisplay prevDisplay = eglGetCurrentDisplay();-
290 if (prevDisplay == EGL_NO_DISPLAY) // when no context is current
prevDisplay == ((EGLDisplay)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
291 prevDisplay = m_eglDisplay;
never executed: prevDisplay = m_eglDisplay;
0
292 EGLContext prevContext = eglGetCurrentContext();-
293 EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW);-
294 EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ);-
295-
296 // Rely on the surfaceless extension, if available. This is beneficial since we can-
297 // avoid creating an extra pbuffer surface which is apparently troublesome with some-
298 // drivers (Mesa) when certain attributes are present (multisampling).-
299 EGLSurface tempSurface = EGL_NO_SURFACE;-
300 EGLContext tempContext = EGL_NO_CONTEXT;-
301 if (m_flags.testFlag(NoSurfaceless) || !q_hasEglExtension(m_eglDisplay, "EGL_KHR_surfaceless_context"))
m_flags.testFl...NoSurfaceless)Description
TRUEnever evaluated
FALSEnever evaluated
!q_hasEglExten...less_context")Description
TRUEnever evaluated
FALSEnever evaluated
0
302 tempSurface = createTemporaryOffscreenSurface();
never executed: tempSurface = createTemporaryOffscreenSurface();
0
303-
304 EGLBoolean ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext);-
305 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
306 EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);-
307 tempContext = eglCreateContext(m_eglDisplay, config, 0, m_contextAttrs.constData());-
308 if (tempContext != EGL_NO_CONTEXT)
tempContext != ((EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
309 ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext);
never executed: ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext);
0
310 }
never executed: end of block
0
311 if (ok) {
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 if (m_format.renderableType() == QSurfaceFormat::OpenGL
m_format.rende...Format::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
0
313 || m_format.renderableType() == QSurfaceFormat::OpenGLES) {
m_format.rende...rmat::OpenGLESDescription
TRUEnever evaluated
FALSEnever evaluated
0
314 const GLubyte *s = glGetString(GL_VERSION);-
315 if (s) {
sDescription
TRUEnever evaluated
FALSEnever evaluated
0
316 QByteArray version = QByteArray(reinterpret_cast<const char *>(s));-
317 int major, minor;-
318 if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor)) {
QPlatformOpenG... major, minor)Description
TRUEnever evaluated
FALSEnever evaluated
0
319#ifdef Q_OS_ANDROID-
320 // Some Android 4.2.2 devices report OpenGL ES 3.0 without the functions being available.-
321 static int apiLevel = QtAndroidPrivate::androidSdkVersion();-
322 if (apiLevel <= 17 && major >= 3) {-
323 major = 2;-
324 minor = 0;-
325 }-
326#endif-
327 m_format.setMajorVersion(major);-
328 m_format.setMinorVersion(minor);-
329 }
never executed: end of block
0
330 }
never executed: end of block
0
331 m_format.setProfile(QSurfaceFormat::NoProfile);-
332 m_format.setOptions(QSurfaceFormat::FormatOptions());-
333 if (m_format.renderableType() == QSurfaceFormat::OpenGL) {
m_format.rende...Format::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
0
334 // Check profile and options.-
335 if (m_format.majorVersion() < 3) {
m_format.majorVersion() < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
336 m_format.setOption(QSurfaceFormat::DeprecatedFunctions);-
337 } else {
never executed: end of block
0
338 GLint value = 0;-
339 glGetIntegerv(GL_CONTEXT_FLAGS, &value);-
340 if (!(value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT))
!(value & 0x00000001)Description
TRUEnever evaluated
FALSEnever evaluated
0
341 m_format.setOption(QSurfaceFormat::DeprecatedFunctions);
never executed: m_format.setOption(QSurfaceFormat::DeprecatedFunctions);
0
342 if (value & GL_CONTEXT_FLAG_DEBUG_BIT)
value & 0x00000002Description
TRUEnever evaluated
FALSEnever evaluated
0
343 m_format.setOption(QSurfaceFormat::DebugContext);
never executed: m_format.setOption(QSurfaceFormat::DebugContext);
0
344 if (m_format.version() >= qMakePair(3, 2)) {
m_format.versi...MakePair(3, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
345 value = 0;-
346 glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value);-
347 if (value & GL_CONTEXT_CORE_PROFILE_BIT)
value & 0x00000001Description
TRUEnever evaluated
FALSEnever evaluated
0
348 m_format.setProfile(QSurfaceFormat::CoreProfile);
never executed: m_format.setProfile(QSurfaceFormat::CoreProfile);
0
349 else if (value & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
value & 0x00000002Description
TRUEnever evaluated
FALSEnever evaluated
0
350 m_format.setProfile(QSurfaceFormat::CompatibilityProfile);
never executed: m_format.setProfile(QSurfaceFormat::CompatibilityProfile);
0
351 }
never executed: end of block
0
352 }
never executed: end of block
0
353 }-
354 }
never executed: end of block
0
355 runGLChecks();-
356 eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);-
357 } else {
never executed: end of block
0
358 qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError());-
359 }
never executed: end of block
0
360 if (tempSurface != EGL_NO_SURFACE)
tempSurface != ((EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
361 destroyTemporaryOffscreenSurface(tempSurface);
never executed: destroyTemporaryOffscreenSurface(tempSurface);
0
362 if (tempContext != EGL_NO_CONTEXT)
tempContext != ((EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
363 eglDestroyContext(m_eglDisplay, tempContext);
never executed: eglDestroyContext(m_eglDisplay, tempContext);
0
364#endif // QT_NO_OPENGL-
365}
never executed: end of block
0
366-
367bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)-
368{-
369 Q_ASSERT(surface->surface()->supportsOpenGL());-
370-
371 eglBindAPI(m_api);-
372-
373 EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);-
374-
375 // shortcut: on some GPUs, eglMakeCurrent is not a cheap operation-
376 if (eglGetCurrentContext() == m_eglContext &&
eglGetCurrentC...= m_eglContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
377 eglGetCurrentDisplay() == m_eglDisplay &&
eglGetCurrentD...= m_eglDisplayDescription
TRUEnever evaluated
FALSEnever evaluated
0
378 eglGetCurrentSurface(EGL_READ) == eglSurface &&
eglGetCurrentS... == eglSurfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
379 eglGetCurrentSurface(EGL_DRAW) == eglSurface) {
eglGetCurrentS... == eglSurfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
380 return true;
never executed: return true;
0
381 }-
382-
383 const bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext);-
384 if (ok) {
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
385 if (!m_swapIntervalEnvChecked) {
!m_swapIntervalEnvCheckedDescription
TRUEnever evaluated
FALSEnever evaluated
0
386 m_swapIntervalEnvChecked = true;-
387 if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) {
qEnvironmentVa...SWAPINTERVAL")Description
TRUEnever evaluated
FALSEnever evaluated
0
388 QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");-
389 bool intervalOk;-
390 const int swapInterval = swapIntervalString.toInt(&intervalOk);-
391 if (intervalOk)
intervalOkDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 m_swapIntervalFromEnv = swapInterval;
never executed: m_swapIntervalFromEnv = swapInterval;
0
393 }
never executed: end of block
0
394 }
never executed: end of block
0
395 const int requestedSwapInterval = m_swapIntervalFromEnv >= 0
m_swapIntervalFromEnv >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
396 ? m_swapIntervalFromEnv-
397 : surface->format().swapInterval();-
398 if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) {
requestedSwapInterval >= 0Description
TRUEnever evaluated
FALSEnever evaluated
m_swapInterval...edSwapIntervalDescription
TRUEnever evaluated
FALSEnever evaluated
0
399 m_swapInterval = requestedSwapInterval;-
400 if (eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
eglSurface != ((EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
401 eglSwapInterval(eglDisplay(), m_swapInterval);
never executed: eglSwapInterval(eglDisplay(), m_swapInterval);
0
402 }
never executed: end of block
0
403 } else {
never executed: end of block
0
404 qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());-
405 }
never executed: end of block
0
406-
407 return ok;
never executed: return ok;
0
408}-
409-
410QEGLPlatformContext::~QEGLPlatformContext()-
411{-
412 if (m_ownsContext && m_eglContext != EGL_NO_CONTEXT)
m_ownsContextDescription
TRUEnever evaluated
FALSEnever evaluated
m_eglContext !...(EGLContext)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
413 eglDestroyContext(m_eglDisplay, m_eglContext);
never executed: eglDestroyContext(m_eglDisplay, m_eglContext);
0
414-
415 m_eglContext = EGL_NO_CONTEXT;-
416}
never executed: end of block
0
417-
418void QEGLPlatformContext::doneCurrent()-
419{-
420 eglBindAPI(m_api);-
421 bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);-
422 if (!ok)
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
423 qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());
never executed: QMessageLogger(__FILE__, 423, __PRETTY_FUNCTION__).warning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());
0
424}
never executed: end of block
0
425-
426void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface)-
427{-
428 eglBindAPI(m_api);-
429 EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);-
430 if (eglSurface != EGL_NO_SURFACE) { // skip if using surfaceless context
eglSurface != ((EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
431 bool ok = eglSwapBuffers(m_eglDisplay, eglSurface);-
432 if (!ok)
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
433 qWarning("QEGLPlatformContext: eglSwapBuffers failed: %x", eglGetError());
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__).warning("QEGLPlatformContext: eglSwapBuffers failed: %x", eglGetError());
0
434 }
never executed: end of block
0
435}
never executed: end of block
0
436-
437void (*QEGLPlatformContext::getProcAddress(const QByteArray &procName)) ()-
438{-
439 eglBindAPI(m_api);-
440 return eglGetProcAddress(procName.constData());
never executed: return eglGetProcAddress(procName.constData());
0
441}-
442-
443QSurfaceFormat QEGLPlatformContext::format() const-
444{-
445 return m_format;
never executed: return m_format;
0
446}-
447-
448EGLContext QEGLPlatformContext::eglContext() const-
449{-
450 return m_eglContext;
never executed: return m_eglContext;
0
451}-
452-
453EGLDisplay QEGLPlatformContext::eglDisplay() const-
454{-
455 return m_eglDisplay;
never executed: return m_eglDisplay;
0
456}-
457-
458EGLConfig QEGLPlatformContext::eglConfig() const-
459{-
460 return m_eglConfig;
never executed: return m_eglConfig;
0
461}-
462-
463QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9