Skip to content
This repository has been archived by the owner on Nov 18, 2018. It is now read-only.

Commit

Permalink
Avoid repeated QByteArray creation when resolving opengl functions
Browse files Browse the repository at this point in the history
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.

Done-with: Lars Knoll <[email protected]>
  • Loading branch information
plfiorini committed Apr 10, 2016
1 parent 2c2cbc3 commit e95926e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform/eglconvenience/eglplatformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,19 @@ void EGLPlatformContext::swapBuffers(QPlatformSurface *surface)
}
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QFunctionPointer EGLPlatformContext::getProcAddress(const char *procName)
{
eglBindAPI(m_api);
return eglGetProcAddress(procName);
}
#else
void (*EGLPlatformContext::getProcAddress(const QByteArray &procName)) ()
{
eglBindAPI(m_api);
return eglGetProcAddress(procName.constData());
}
#endif

QSurfaceFormat EGLPlatformContext::format() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/platform/eglconvenience/eglplatformcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ class GREENISLANDPLATFORM_EXPORT EGLPlatformContext : public QPlatformOpenGLCont
bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
void doneCurrent() Q_DECL_OVERRIDE;
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QFunctionPointer getProcAddress(const char *procName) Q_DECL_OVERRIDE;
#else
QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
#endif

QSurfaceFormat format() const Q_DECL_OVERRIDE;
bool isSharing() const Q_DECL_OVERRIDE { return m_shareContext != EGL_NO_CONTEXT; }
Expand Down

0 comments on commit e95926e

Please sign in to comment.