From 29d8159c4478a5275d2ea102daf270a91ed7e92e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 29 Jan 2016 10:43:35 +0100 Subject: 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 Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglvertexarrayobject.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/gui/opengl/qopenglvertexarrayobject.cpp') diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 8e0b536909b..fe1e308532c 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -70,26 +70,26 @@ void qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, helper->IsVertexArray = es3->IsVertexArray; tryARB = false; } else if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) { - helper->GenVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES"))); - helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES"))); - helper->BindVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES"))); - helper->IsVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glIsVertexArrayOES"))); + helper->GenVertexArrays = reinterpret_cast(context->getProcAddress("glGenVertexArraysOES")); + helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress("glDeleteVertexArraysOES")); + helper->BindVertexArray = reinterpret_cast(context->getProcAddress("glBindVertexArrayOES")); + helper->IsVertexArray = reinterpret_cast(context->getProcAddress("glIsVertexArrayOES")); tryARB = false; } } else if (context->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object")) && !context->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) { - helper->GenVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysAPPLE"))); - helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysAPPLE"))); - helper->BindVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayAPPLE"))); - helper->IsVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glIsVertexArrayAPPLE"))); + helper->GenVertexArrays = reinterpret_cast(context->getProcAddress("glGenVertexArraysAPPLE")); + helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress("glDeleteVertexArraysAPPLE")); + helper->BindVertexArray = reinterpret_cast(context->getProcAddress("glBindVertexArrayAPPLE")); + helper->IsVertexArray = reinterpret_cast(context->getProcAddress("glIsVertexArrayAPPLE")); tryARB = false; } if (tryARB && context->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) { - helper->GenVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glGenVertexArrays"))); - helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArrays"))); - helper->BindVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glBindVertexArray"))); - helper->IsVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glIsVertexArray"))); + helper->GenVertexArrays = reinterpret_cast(context->getProcAddress("glGenVertexArrays")); + helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress("glDeleteVertexArrays")); + helper->BindVertexArray = reinterpret_cast(context->getProcAddress("glBindVertexArray")); + helper->IsVertexArray = reinterpret_cast(context->getProcAddress("glIsVertexArray")); } } -- cgit v1.2.3