summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qopenglcontext_p.h
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-17 11:20:46 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-17 16:00:43 +0200
commitbad2ac47f8a6a43df62208e80e114fdd554ed542 (patch)
tree85b5ad6c39e183694b1c2b376a83508282980b44 /src/gui/kernel/qopenglcontext_p.h
parentd6272d774c7415186aa398e59f234d0073458072 (diff)
Resolve OpenGL version functions in thread-safe manner
In 73f3f501f331444b3f188b21db7265f723e4f383, the classes were moved out of Qt Gui, and a mechanism to attach them to the QOpenGLContext was implemented using a QMap and a connection on destroyed to delete it. This solution was not thread-safe, so the suggestion was to either add a mutex or to make an opaque pointer for the storage in the (thread-affine) QOpenGLContextPrivate. I decided to go with the latter. A solution using hash lookups and mutexes seems to complex when the only benefit is to avoid forward declarations from Qt Gui to Qt OpenGL in private API. Especially since this dependency already exists with the "textureFunctions", which serve the same purpose, although the destructor is being passed in as an explicit function pointer there, probably because the ambition was to use a forward declaration rather than a superclass. Fixes: QTBUG-82742 Change-Id: I5c6b82c5b33d9cb73ad1ec05d3fc3e87a9eae4cf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/kernel/qopenglcontext_p.h')
-rw-r--r--src/gui/kernel/qopenglcontext_p.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index c017bf9a34..ede41d5a93 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -192,6 +192,12 @@ class QPaintEngineEx;
class QOpenGLFunctions;
class QOpenGLTextureHelper;
+class Q_GUI_EXPORT QOpenGLContextVersionFunctionHelper
+{
+public:
+ virtual ~QOpenGLContextVersionFunctionHelper() {}
+};
+
class Q_GUI_EXPORT QOpenGLContextPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QOpenGLContext)
@@ -204,6 +210,7 @@ public:
, surface(nullptr)
, functions(nullptr)
, textureFunctions(nullptr)
+ , versionFunctions(nullptr)
, max_texture_size(-1)
, workaround_brokenFBOReadBack(false)
, workaround_brokenTexSubImage(false)
@@ -220,6 +227,8 @@ public:
{
//do not delete the QOpenGLContext handle here as it is deleted in
//QWidgetPrivate::deleteTLSysExtra()
+
+ delete versionFunctions;
}
QSurfaceFormat requestedFormat;
@@ -232,6 +241,7 @@ public:
mutable QSet<QByteArray> extensionNames;
QOpenGLTextureHelper* textureFunctions;
std::function<void()> textureFunctionsDestroyCallback;
+ QOpenGLContextVersionFunctionHelper *versionFunctions;
GLint max_texture_size;