diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2016-02-03 12:42:52 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-03-02 12:16:05 +0000 |
commit | 6b0a577bf85845780e9a7b101260cdf72fa1d33c (patch) | |
tree | 2ce5d8b2166c50024e648c3ef61ebcee7674bfa7 /src/gui/opengl/qopenglfunctions_1_0.cpp | |
parent | 8f1fcb0142b26f8e12c51b6c646eca1242b35102 (diff) |
Refactor initialization/caching code for versioned opengl functions
Saves around 80k in Qt Gui.
Change-Id: I3f7068ae699136d0edf46a49694ade7e1df3c91d
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/gui/opengl/qopenglfunctions_1_0.cpp')
-rw-r--r-- | src/gui/opengl/qopenglfunctions_1_0.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/gui/opengl/qopenglfunctions_1_0.cpp b/src/gui/opengl/qopenglfunctions_1_0.cpp index dcaff4b300..9d5a76380a 100644 --- a/src/gui/opengl/qopenglfunctions_1_0.cpp +++ b/src/gui/opengl/qopenglfunctions_1_0.cpp @@ -74,14 +74,12 @@ QOpenGLFunctions_1_0::QOpenGLFunctions_1_0() QOpenGLFunctions_1_0::~QOpenGLFunctions_1_0() { - if (d_1_0_Core && !d_1_0_Core->refs.deref()) { - QAbstractOpenGLFunctionsPrivate::removeFunctionsBackend(d_1_0_Core->context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); - delete d_1_0_Core; - } - if (d_1_0_Deprecated && !d_1_0_Deprecated->refs.deref()) { - QAbstractOpenGLFunctionsPrivate::removeFunctionsBackend(d_1_0_Deprecated->context, QOpenGLFunctions_1_0_DeprecatedBackend::versionStatus()); - delete d_1_0_Deprecated; - } + if (d_1_0_Core) + d_1_0_Core->refs.deref(); + Q_ASSERT(d_1_0_Core->refs.load()); + if (d_1_0_Deprecated) + d_1_0_Deprecated->refs.deref(); + Q_ASSERT(d_1_0_Deprecated->refs.load()); } bool QOpenGLFunctions_1_0::initializeOpenGLFunctions() @@ -100,18 +98,10 @@ bool QOpenGLFunctions_1_0::initializeOpenGLFunctions() // Function pointers in the backends are resolved at creation time QOpenGLVersionFunctionsBackend* d = 0; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); - if (!d) { - d = new QOpenGLFunctions_1_0_CoreBackend(context); - QAbstractOpenGLFunctionsPrivate::insertFunctionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus(), d); - } d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_DeprecatedBackend::versionStatus()); - if (!d) { - d = new QOpenGLFunctions_1_0_DeprecatedBackend(context); - QAbstractOpenGLFunctionsPrivate::insertFunctionsBackend(context, QOpenGLFunctions_1_0_DeprecatedBackend::versionStatus(), d); - } d_1_0_Deprecated = static_cast<QOpenGLFunctions_1_0_DeprecatedBackend*>(d); d->refs.ref(); |