diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-05 10:40:18 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-09-15 21:19:08 +0200 |
commit | 45cfa386e312bf70c84fb971a9f7d541353b4809 (patch) | |
tree | fdec5aee8332a7196804f2286ede1f7634eae7e4 /vcl | |
parent | 8a398429cd7b8369af360def49989623176cd233 (diff) |
Resolves: tdf#107730 ensure per-thread epoxy_handle_external_wglMakeCurrent
Change-Id: Idc1e2da3a02715a09b5b8f4e8e736b8806e59f8e
Reviewed-on: https://gerrit.libreoffice.org/41927
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
(cherry picked from commit 4cc634327a752d633ea341252d8f4845157f887b)
Reviewed-on: https://gerrit.libreoffice.org/41936
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/opengl/win/gdiimpl.cxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index 41cbda7e7165..58b3178b6c10 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -8,6 +8,7 @@ */ #include <memory> +#include <thread> #include "opengl/win/gdiimpl.hxx" #include <comphelper/windowserrorstring.hxx> @@ -75,11 +76,24 @@ void WinOpenGLContext::resetCurrent() g_bAnyCurrent = false; } +thread_local bool bEpoxyDispatchMakeCurrentCalled = false; + +void ensureDispatchTable() +{ + if (!bEpoxyDispatchMakeCurrentCalled) + { + epoxy_handle_external_wglMakeCurrent(); + bEpoxyDispatchMakeCurrentCalled = true; + } +} + bool WinOpenGLContext::isCurrent() { OpenGLZone aZone; - return g_bAnyCurrent && m_aGLWin.hRC && wglGetCurrentContext() == m_aGLWin.hRC && - wglGetCurrentDC() == m_aGLWin.hDC; + if (!g_bAnyCurrent || !m_aGLWin.hRC) + return false; + ensureDispatchTable(); + return wglGetCurrentContext() == m_aGLWin.hRC && wglGetCurrentDC() == m_aGLWin.hDC; } bool WinOpenGLContext::isAnyCurrent() @@ -96,7 +110,7 @@ void WinOpenGLContext::makeCurrent() clearCurrent(); - epoxy_handle_external_wglMakeCurrent(); + ensureDispatchTable(); if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) { |