diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-11-17 21:51:50 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-11-17 21:57:49 +0000 |
commit | 5b14cd7d8d293365ebc03ee1442610180c07ab8d (patch) | |
tree | 44ce5f759380a41c15a537554712fdd640141332 | |
parent | 5fffe5e5ece8ab130c9024bd1f04f1d08a8e01c2 (diff) |
vcl: make OpenGLContext::makeCurrent unfeasibly faster.
Don't set the same context if it is already set. Apparently this is
something that is unbelievably costly on Windows, and very costly on
Linux. Instead check if the context is already set, and don't re-set it.
Change-Id: If4fed3e555e1388031446be76d6fdfde5b9f13e5
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 4cde114bea53..e7f7f7179e95 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -1073,7 +1073,11 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool) void OpenGLContext::makeCurrent() { #if defined( WNT ) - if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) + if (wglGetCurrentContext() == m_aGLWin.hRC) + { + SAL_INFO("vcl.opengl", "OpenGLContext::makeCurrent(): Avoid setting the same context"); + } + else if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) { SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError()); } @@ -1083,7 +1087,11 @@ void OpenGLContext::makeCurrent() #elif defined( IOS ) || defined( ANDROID ) // nothing #elif defined( UNX ) - if (!glXMakeCurrent( m_aGLWin.dpy, mbPixmap ? m_aGLWin.glPix : m_aGLWin.win, m_aGLWin.ctx )) + if (glXGetCurrentContext() == m_aGLWin.ctx) + { + SAL_INFO("vcl.opengl", "OpenGLContext::makeCurrent(): Avoid setting the same context"); + } + else if (!glXMakeCurrent( m_aGLWin.dpy, mbPixmap ? m_aGLWin.glPix : m_aGLWin.win, m_aGLWin.ctx )) SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed"); #endif } |