Commit Graph

3 Commits

Author SHA1 Message Date
Eskil Abrahamsen Blomfeldt
bad2ac47f8 Resolve OpenGL version functions in thread-safe manner
In 73f3f501f3, 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>
2020-04-17 16:00:43 +02:00
Eskil Abrahamsen Blomfeldt
009d583eef Minor tidying for header guard in qopenglversionfunctions_p.h
The original was too close to QOPENGLVERSIONFUNCTIONS_H for comfort
so to avoid future confusion or errors, just use the convention
of matching the file name.

Change-Id: I57fcc4da239ddec329f75ac29b254b5909c39bf0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-04-17 11:49:50 +02:00
Johan Klokkhammer Helsing
73f3f501f3 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>
2020-04-16 07:14:51 +02:00