summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-18 03:30:47 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-22 12:48:30 +0200
commit436b331b7127124b9720bf7a3f915439f2a25cf3 (patch)
treeb3cd72c2a3d59dfbefd3aa6f0fe3dfcc9b513862 /src/gui/kernel
parentf1f0aa4a3a7d364b5110122a8f77079a7742c4e9 (diff)
Enable access to the VAO resolvers through QOpenGLContextPrivate
This is a commit in preparation for an upcoming change in QtQuick. We want to store the resolved functions for managing VAOs somewhere; the "least worst" choice is next to the all other function resolvers, which are in QOpenGLContext(Private). To avoid moving the VAO resolvers themselves, leave a hook in QOGLCPrivate, similar to e.g. the texture function resolvers. The hook gets populated when the VAO resolvers for a given context are requested. This removes memory management burden from the users of those functions (again, just like other function resolvers), and makes the initialization of the functions automatic. Change-Id: I0eba30a85bf8ad82946a5d68e91009d8b4bd91cf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qopenglcontext.cpp7
-rw-r--r--src/gui/kernel/qopenglcontext_p.h6
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index d164f44e73..5c6d082f98 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -484,6 +484,13 @@ void QOpenGLContext::destroy()
}
d->textureFunctions = nullptr;
+ if (d->vaoHelperDestroyCallback) {
+ Q_ASSERT(d->vaoHelper);
+ d->vaoHelperDestroyCallback(d->vaoHelper);
+ d->vaoHelperDestroyCallback = nullptr;
+ }
+ d->vaoHelper = nullptr;
+
d->nativeHandle = QVariant();
}
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index ede41d5a93..c5f971fa4a 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -191,6 +191,7 @@ private:
class QPaintEngineEx;
class QOpenGLFunctions;
class QOpenGLTextureHelper;
+class QOpenGLVertexArrayObjectHelper;
class Q_GUI_EXPORT QOpenGLContextVersionFunctionHelper
{
@@ -211,6 +212,8 @@ public:
, functions(nullptr)
, textureFunctions(nullptr)
, versionFunctions(nullptr)
+ , vaoHelper(nullptr)
+ , vaoHelperDestroyCallback(nullptr)
, max_texture_size(-1)
, workaround_brokenFBOReadBack(false)
, workaround_brokenTexSubImage(false)
@@ -242,6 +245,9 @@ public:
QOpenGLTextureHelper* textureFunctions;
std::function<void()> textureFunctionsDestroyCallback;
QOpenGLContextVersionFunctionHelper *versionFunctions;
+ QOpenGLVertexArrayObjectHelper *vaoHelper;
+ using QOpenGLVertexArrayObjectHelperDestroyCallback_t = void (*)(QOpenGLVertexArrayObjectHelper *);
+ QOpenGLVertexArrayObjectHelperDestroyCallback_t vaoHelperDestroyCallback;
GLint max_texture_size;