summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/platform/egl/qeglconvenience.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/opengl/platform/egl/qeglconvenience.cpp')
-rw-r--r--src/gui/opengl/platform/egl/qeglconvenience.cpp56
1 files changed, 12 insertions, 44 deletions
diff --git a/src/gui/opengl/platform/egl/qeglconvenience.cpp b/src/gui/opengl/platform/egl/qeglconvenience.cpp
index 6076498b3e..4af50d72f2 100644
--- a/src/gui/opengl/platform/egl/qeglconvenience.cpp
+++ b/src/gui/opengl/platform/egl/qeglconvenience.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtCore/qbytearray.h>
@@ -124,13 +88,12 @@ QList<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format)
bool q_reduceConfigAttributes(QList<EGLint> *configAttributes)
{
- int i = -1;
// Reduce the complexity of a configuration request to ask for less
// because the previous request did not result in success. Returns
// true if the complexity was reduced, or false if no further
// reductions in complexity are possible.
- i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR);
+ qsizetype i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR);
if (i >= 0) {
configAttributes->remove(i,2);
}
@@ -252,14 +215,17 @@ EGLConfig QEglConfigChooser::chooseConfig()
configureAttributes.append(EGL_OPENVG_BIT);
break;
#ifdef EGL_VERSION_1_4
- case QSurfaceFormat::DefaultRenderableType:
+ case QSurfaceFormat::DefaultRenderableType: {
#ifndef QT_NO_OPENGL
- if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL)
+ // NVIDIA EGL only provides desktop GL for development purposes, and recommends against using it.
+ const char *vendor = eglQueryString(display(), EGL_VENDOR);
+ if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL && (!vendor || !strstr(vendor, "NVIDIA")))
configureAttributes.append(EGL_OPENGL_BIT);
else
#endif // QT_NO_OPENGL
needsES2Plus = true;
break;
+ }
case QSurfaceFormat::OpenGL:
configureAttributes.append(EGL_OPENGL_BIT);
break;
@@ -291,7 +257,7 @@ EGLConfig QEglConfigChooser::chooseConfig()
// Fetch all of the matching configurations and find the
// first that matches the pixel format we wanted.
- int i = configureAttributes.indexOf(EGL_RED_SIZE);
+ qsizetype i = configureAttributes.indexOf(EGL_RED_SIZE);
m_confAttrRed = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_GREEN_SIZE);
m_confAttrGreen = configureAttributes.at(i+1);
@@ -301,7 +267,8 @@ EGLConfig QEglConfigChooser::chooseConfig()
m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1);
QList<EGLConfig> configs(matching);
- eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching);
+ eglChooseConfig(display(), configureAttributes.constData(), configs.data(),
+ EGLint(configs.size()), &matching);
if (!cfg && matching > 0)
cfg = configs.first();
@@ -389,6 +356,7 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config,
else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
#ifndef QT_NO_OPENGL
&& QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
+ && !strstr(eglQueryString(display, EGL_VENDOR), "NVIDIA")
#endif
&& (renderableType & EGL_OPENGL_BIT))
format.setRenderableType(QSurfaceFormat::OpenGL);