summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsglcontext.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2016-01-29 10:43:35 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-01 14:46:14 +0000
commit29d8159c4478a5275d2ea102daf270a91ed7e92e (patch)
tree709a145107cdfc58e67b4fabe6a76534d5cc7801 /src/plugins/platforms/windows/qwindowsglcontext.cpp
parent7ee585bbffb4350ec327116d30cd63e3d1142581 (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/plugins/platforms/windows/qwindowsglcontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 48f2e3aaef..8eac7cca9e 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -1381,7 +1381,7 @@ void QWindowsGLContext::doneCurrent()
releaseDCs();
}
-QFunctionPointer QWindowsGLContext::getProcAddress(const QByteArray &procName)
+QFunctionPointer QWindowsGLContext::getProcAddress(const char *procName)
{
// We support AllGLFunctionsQueryable, which means this function must be able to
// return a function pointer even for functions that are in GL.h and exported
@@ -1444,17 +1444,17 @@ QFunctionPointer QWindowsGLContext::getProcAddress(const QByteArray &procName)
{ "glDepthRange", (void *) QOpenGLStaticContext::opengl32.glDepthRange },
};
for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i)
- if (procName == standardFuncs[i].name)
+ if (!qstrcmp(procName, standardFuncs[i].name))
return reinterpret_cast<QFunctionPointer>(standardFuncs[i].func);
// Even though we use QFunctionPointer, it does not mean the function can be called.
// It will need to be cast to the proper function type with the correct calling
// convention. QFunctionPointer is nothing more than a glorified void* here.
- QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName.constData()));
+ QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName));
if (QWindowsContext::verbose > 1)
qCDebug(lcQpaGl) << __FUNCTION__ << procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress;
if (!procAddress && QWindowsContext::verbose)
- qWarning("%s: Unable to resolve '%s'", __FUNCTION__, procName.constData());
+ qWarning("%s: Unable to resolve '%s'", __FUNCTION__, procName);
return procAddress;
}