summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-01-22 17:01:30 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-16 07:14:51 +0200
commit73f3f501f331444b3f188b21db7265f723e4f383 (patch)
tree06eb8f50e1cbb71579210c678089e169cacb4977 /src/gui/kernel
parentca635c659c9d3d7418779a48b70b471abe25c577 (diff)
Move versioned OpenGL functions from QtGui to QtOpenGL
The context—which lives in QtGui—now knows nothing about versioned functions. This changes the public API for getting version functions for a context. [ChangeLog][QtGui][OpenGL] QOpenGLContext::versionFunctions() has been removed. QOpenGLVersionFunctionsFactory::get() from the QtOpenGL module should be used instead. Previously one would call context->versionFunctions<QOpenGLFunctions_4_0_Core>(); Which now becomes QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_4_0_Core>(context); The rest of the API should be identical. Since glgen no longer compiles, and the links to its input (gl.spec and gl.tm) are dead, I've edited the previously generated files manually. If glgen is fixed, it should be quite easy to make it generate the new way. Task-number: QTBUG-74409 Change-Id: I800527e0af16a79005b276eeb74417770193c62f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qopenglcontext.cpp151
-rw-r--r--src/gui/kernel/qopenglcontext.h16
-rw-r--r--src/gui/kernel/qopenglcontext_p.h4
3 files changed, 0 insertions, 171 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index b0474ceb3d..a004d9e10d 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -54,15 +54,9 @@
#include <qpa/qplatformnativeinterface.h>
#include <private/qopenglextensions_p.h>
-#include <private/qopenglversionfunctionsfactory_p.h>
#include <QDebug>
-#ifndef QT_OPENGL_ES_2
-#include <QOpenGLFunctions_1_0>
-#include <QOpenGLFunctions_3_2_Core>
-#endif
-
QT_BEGIN_NAMESPACE
class QGuiGLThreadContext
@@ -484,15 +478,6 @@ void QOpenGLContext::destroy()
delete d->functions;
d->functions = nullptr;
- for (QAbstractOpenGLFunctions *func : qAsConst(d->externalVersionFunctions)) {
- QAbstractOpenGLFunctionsPrivate *func_d = QAbstractOpenGLFunctionsPrivate::get(func);
- func_d->owningContext = nullptr;
- func_d->initialized = false;
- }
- d->externalVersionFunctions.clear();
- qDeleteAll(d->versionFunctions);
- d->versionFunctions.clear();
-
if (d->textureFunctionsDestroyCallback) {
d->textureFunctionsDestroyCallback();
d->textureFunctionsDestroyCallback = nullptr;
@@ -589,115 +574,6 @@ QOpenGLExtraFunctions *QOpenGLContext::extraFunctions() const
}
/*!
- \fn T *QOpenGLContext::versionFunctions() const
-
- \overload versionFunctions()
-
- Returns a pointer to an object that provides access to all functions for
- the version and profile of this context. There is no need to call
- QAbstractOpenGLFunctions::initializeOpenGLFunctions() as long as this context
- is current. It is also possible to call this function when the context is not
- current, but in that case it is the caller's responsibility to ensure proper
- initialization by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions()
- afterwards.
-
- Usually one would use the template version of this function to automatically
- have the result cast to the correct type.
-
- \code
- QOpenGLFunctions_3_3_Core* funcs = 0;
- funcs = context->versionFunctions<QOpenGLFunctions_3_3_Core>();
- if (!funcs) {
- qWarning() << "Could not obtain required OpenGL context version";
- exit(1);
- }
- \endcode
-
- It is possible to request a functions object for a different version and profile
- than that for which the context was created. To do this either use the template
- version of this function specifying the desired functions object type as the
- template parameter or by passing in a QOpenGLVersionProfile object as an argument
- to the non-template function.
-
- Note that requests for function objects of other versions or profiles can fail and
- in doing so will return \nullptr. Situations in which creation of the functions
- object can fail are if the request cannot be satisfied due to asking for functions
- that are not in the version or profile of this context. For example:
-
- \list
- \li Requesting a 3.3 core profile functions object would succeed.
- \li Requesting a 3.3 compatibility profile functions object would fail. We would fail
- to resolve the deprecated functions.
- \li Requesting a 4.3 core profile functions object would fail. We would fail to resolve
- the new core functions introduced in versions 4.0-4.3.
- \li Requesting a 3.1 functions object would succeed. There is nothing in 3.1 that is not
- also in 3.3 core.
- \endlist
-
- Note that if creating a functions object via this method that the QOpenGLContext
- retains ownership of the object. This is to allow the object to be cached and shared.
-*/
-
-/*!
- Returns a pointer to an object that provides access to all functions for the
- \a versionProfile of this context. There is no need to call
- QAbstractOpenGLFunctions::initializeOpenGLFunctions() as long as this context
- is current. It is also possible to call this function when the context is not
- current, but in that case it is the caller's responsibility to ensure proper
- initialization by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions()
- afterwards.
-
- Usually one would use the template version of this function to automatically
- have the result cast to the correct type.
-*/
-QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionProfile &versionProfile) const
-{
-#ifndef QT_OPENGL_ES_2
- if (isOpenGLES()) {
- qWarning("versionFunctions: Not supported on OpenGL ES");
- return nullptr;
- }
-#endif // QT_OPENGL_ES_2
-
- Q_D(const QOpenGLContext);
- const QSurfaceFormat f = format();
-
- // Ensure we have a valid version and profile. Default to context's if none specified
- QOpenGLVersionProfile vp = versionProfile;
- if (!vp.isValid())
- vp = QOpenGLVersionProfile(f);
-
- // Check that context is compatible with requested version
- const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
- if (v < vp.version())
- return nullptr;
-
- // If this context only offers core profile functions then we can't create
- // function objects for legacy or compatibility profile requests
- if (((vp.hasProfiles() && vp.profile() != QSurfaceFormat::CoreProfile) || vp.isLegacyVersion())
- && f.profile() == QSurfaceFormat::CoreProfile)
- return nullptr;
-
- // Create object if suitable one not cached
- QAbstractOpenGLFunctions* funcs = nullptr;
- auto it = d->versionFunctions.constFind(vp);
- if (it == d->versionFunctions.constEnd()) {
- funcs = QOpenGLVersionFunctionsFactory::create(vp);
- if (funcs) {
- funcs->setOwningContext(this);
- d->versionFunctions.insert(vp, funcs);
- }
- } else {
- funcs = it.value();
- }
-
- if (funcs && QOpenGLContext::currentContext() == this)
- funcs->initializeOpenGLFunctions();
-
- return funcs;
-}
-
-/*!
Returns the set of OpenGL extensions supported by this context.
The context or a sharing context must be current.
@@ -1146,33 +1022,6 @@ QOpenGLContext *QOpenGLContext::globalShareContext()
/*!
\internal
*/
-QOpenGLVersionFunctionsStorage *QOpenGLContext::functionsBackendStorage() const
-{
- Q_D(const QOpenGLContext);
- return &d->versionFunctionsStorage;
-}
-
-/*!
- \internal
- */
-void QOpenGLContext::insertExternalFunctions(QAbstractOpenGLFunctions *f)
-{
- Q_D(QOpenGLContext);
- d->externalVersionFunctions.insert(f);
-}
-
-/*!
- \internal
- */
-void QOpenGLContext::removeExternalFunctions(QAbstractOpenGLFunctions *f)
-{
- Q_D(QOpenGLContext);
- d->externalVersionFunctions.remove(f);
-}
-
-/*!
- \internal
-*/
QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const
{
Q_D(const QOpenGLContext);
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index b26a3e2ede..a0d8a3edba 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -58,9 +58,6 @@
#endif
#include <QtGui/qopengl.h>
-#include <QtGui/qopenglversionfunctions.h>
-// TODO: ideally get rid of this include
-#include <QtGui/qopenglversionprofile.h>
#include <QtCore/qvariant.h>
@@ -141,15 +138,6 @@ public:
QOpenGLFunctions *functions() const;
QOpenGLExtraFunctions *extraFunctions() const;
- QAbstractOpenGLFunctions *versionFunctions(const QOpenGLVersionProfile &versionProfile = QOpenGLVersionProfile()) const;
-
- template<class TYPE>
- TYPE *versionFunctions() const
- {
- QOpenGLVersionProfile v = TYPE::versionProfile();
- return static_cast<TYPE*>(versionFunctions(v));
- }
-
QSet<QByteArray> extensions() const;
bool hasExtension(const QByteArray &extension) const;
@@ -185,10 +173,6 @@ private:
friend class QAbstractOpenGLFunctionsPrivate;
friend class QOpenGLTexturePrivate;
- QOpenGLVersionFunctionsStorage* functionsBackendStorage() const;
- void insertExternalFunctions(QAbstractOpenGLFunctions *f);
- void removeExternalFunctions(QAbstractOpenGLFunctions *f);
-
QOpenGLTextureHelper* textureFunctions() const;
void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback);
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index d769f03fd3..c017bf9a34 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -222,10 +222,6 @@ public:
//QWidgetPrivate::deleteTLSysExtra()
}
- mutable QHash<QOpenGLVersionProfile, QAbstractOpenGLFunctions *> versionFunctions;
- mutable QOpenGLVersionFunctionsStorage versionFunctionsStorage;
- mutable QSet<QAbstractOpenGLFunctions *> externalVersionFunctions;
-
QSurfaceFormat requestedFormat;
QPlatformOpenGLContext *platformGLContext;
QOpenGLContext *shareContext;