diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2016-01-29 10:43:35 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-03-01 14:46:14 +0000 |
commit | 29d8159c4478a5275d2ea102daf270a91ed7e92e (patch) | |
tree | 709a145107cdfc58e67b4fabe6a76534d5cc7801 /src/gui/kernel | |
parent | 7ee585bbffb4350ec327116d30cd63e3d1142581 (diff) |
Avoid repeated QByteArray creation when resolving opengl functions
Add an getProcAddress(const char *) overload to QOpenGLContext,
and refactor the QPA interface to take a const char *. Like this
we can avoid lots of mallocs when resoving GL methods.
Change-Id: Ic45b985fbaa0da8d32ba3e3b485351173352ca6f
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qplatformopenglcontext.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformopenglcontext.h | 2 |
4 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index b45396ab3c..f301b21ec1 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1070,9 +1070,18 @@ void QOpenGLContext::swapBuffers(QSurface *surface) */ QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const { + return getProcAddress(procName.constData()); +} + +/*! + \overload + \since 5.8 + */ +QFunctionPointer QOpenGLContext::getProcAddress(const char *procName) const +{ Q_D(const QOpenGLContext); if (!d->platformGLContext) - return 0; + return nullptr; return d->platformGLContext->getProcAddress(procName); } diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 56eb6f0e12..130d55464f 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -174,6 +174,7 @@ public: void swapBuffers(QSurface *surface); QFunctionPointer getProcAddress(const QByteArray &procName) const; + QFunctionPointer getProcAddress(const char *procName) const; QSurface *surface() const; diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp index 2457a5237d..5b375f7883 100644 --- a/src/gui/kernel/qplatformopenglcontext.cpp +++ b/src/gui/kernel/qplatformopenglcontext.cpp @@ -71,10 +71,9 @@ QT_BEGIN_NAMESPACE The implementation must support being called in a thread different than the gui-thread. */ -/*! \fn QFunctionPointer QPlatformOpenGLContext::getProcAddress(const QByteArray &procName) - Reimplement in subclass to native getProcAddr calls. +/*! \fn QFunctionPointer QPlatformOpenGLContext::getProcAddress(const char *procName) - Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer + Reimplement in subclass to native getProcAddr calls. */ class QPlatformOpenGLContextPrivate diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h index f2ec1c1a7e..1a38a5fed3 100644 --- a/src/gui/kernel/qplatformopenglcontext.h +++ b/src/gui/kernel/qplatformopenglcontext.h @@ -83,7 +83,7 @@ public: virtual bool isSharing() const { return false; } virtual bool isValid() const { return true; } - virtual QFunctionPointer getProcAddress(const QByteArray &procName) = 0; + virtual QFunctionPointer getProcAddress(const char *procName) = 0; QOpenGLContext *context() const; |