From f9c16f396274e60e74739cd270052c42008abd6e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 19 Jan 2016 12:41:04 +0100 Subject: De-inline the code resolving the GL symbols Saves around 200k in QtGui.so. Change-Id: I1a020445093a5612ed64ca98bf51435580478cda Reviewed-by: Laszlo Agocs Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglfunctions.cpp | 60 +++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'src/gui') 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 @@ -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 \ -- cgit v1.2.3