summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglfunctions.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2016-01-19 12:41:04 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-01 14:45:58 +0000
commitf9c16f396274e60e74739cd270052c42008abd6e (patch)
tree2a3a431280fe973cfcc324c9b8df54ac84766bd0 /src/gui/opengl/qopenglfunctions.cpp
parent45ac7c962b4c196bba796c1dc7fc345f84c4b74e (diff)
De-inline the code resolving the GL symbols
Saves around 200k in QtGui.so. Change-Id: I1a020445093a5612ed64ca98bf51435580478cda Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopenglfunctions.cpp')
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp60
1 files changed, 41 insertions, 19 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index b55c878623..598bf5e179 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -2142,7 +2142,7 @@ public:
private:
FuncType Base::*funcPointerName;
FuncType fallbackFuncPointer;
- QByteArray funcName;
+ const char *funcName;
};
template <typename Base, typename FuncType, int Policy>
@@ -2194,31 +2194,53 @@ public:
private:
FuncType Base::*funcPointerName;
FuncType fallbackFuncPointer;
- QByteArray funcName;
+ const char *funcName;
};
+static QFunctionPointer getProcAddress(QOpenGLContext *context, const char *funcName, int policy)
+{
+ QByteArray fn = funcName;
+ int size = fn.size();
+ QFunctionPointer function = context->getProcAddress(fn);
+
+ // create room for the extension names
+ fn.resize(size + 5);
+ char *ext = fn.data() + size;
+ if (!function && (policy & ResolveOES)) {
+ memcpy(ext, "OES\0\0", 5);
+ function = context->getProcAddress(fn);
+ }
+
+ if (!function) {
+ memcpy(ext, "ARB\0\0", 5);
+ function = context->getProcAddress(fn);
+ }
+
+ if (!function && (policy & ResolveEXT)) {
+ memcpy(ext, "EXT\0\0", 5);
+ function = context->getProcAddress(fn);
+ }
+
+ if (!function && (policy & ResolveANGLE)) {
+ memcpy(ext, "ANGLE", 5);
+ function = context->getProcAddress(fn);
+ }
+
+ if (!function && (policy & ResolveNV)) {
+ memcpy(ext, "NV\0\0\0", 5);
+ function = context->getProcAddress(fn);
+ }
+
+ return function;
+}
+
#define RESOLVER_COMMON \
QOpenGLContext *context = QOpenGLContext::currentContext(); \
Base *funcs = qt_gl_functions(context); \
\
FuncType old = funcs->*funcPointerName; \
- \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName); \
- \
- if ((Policy & ResolveOES) && !(funcs->*funcPointerName)) \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName + "OES"); \
- \
- if (!(funcs->*funcPointerName)) \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName + "ARB"); \
- \
- if ((Policy & ResolveEXT) && !(funcs->*funcPointerName)) \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName + "EXT"); \
- \
- if ((Policy & ResolveANGLE) && !(funcs->*funcPointerName)) \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName + "ANGLE"); \
- \
- if ((Policy & ResolveNV) && !(funcs->*funcPointerName)) \
- funcs->*funcPointerName = (FuncType)context->getProcAddress(funcName + "NV");
+ funcs->*funcPointerName = (FuncType)getProcAddress(context, funcName, Policy);
+
#define RESOLVER_COMMON_NON_VOID \
RESOLVER_COMMON \