Browse Source

Linux: Fixed some potential deadlocks using OpenGL

tags/2021-05-28
Tom Poole 6 years ago
parent
commit
963e307ef8
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      modules/juce_opengl/native/juce_OpenGL_linux_X11.h

+ 6
- 0
modules/juce_opengl/native/juce_OpenGL_linux_X11.h View File

@@ -154,6 +154,7 @@ public:
void shutdownOnRenderThread() void shutdownOnRenderThread()
{ {
ScopedXLock xlock (display);
context = nullptr; context = nullptr;
deactivateCurrentContext(); deactivateCurrentContext();
glXDestroyContext (display, renderContext); glXDestroyContext (display, renderContext);
@@ -162,23 +163,27 @@ public:
bool makeActive() const noexcept bool makeActive() const noexcept
{ {
ScopedXLock xlock (display);
return renderContext != 0 return renderContext != 0
&& glXMakeCurrent (display, embeddedWindow, renderContext); && glXMakeCurrent (display, embeddedWindow, renderContext);
} }
bool isActive() const noexcept bool isActive() const noexcept
{ {
ScopedXLock xlock (display);
return glXGetCurrentContext() == renderContext && renderContext != 0; return glXGetCurrentContext() == renderContext && renderContext != 0;
} }
static void deactivateCurrentContext() static void deactivateCurrentContext()
{ {
ScopedXDisplay xDisplay; ScopedXDisplay xDisplay;
ScopedXLock xlock (xDisplay.display);
glXMakeCurrent (xDisplay.display, None, 0); glXMakeCurrent (xDisplay.display, None, 0);
} }
void swapBuffers() void swapBuffers()
{ {
ScopedXLock xlock (display);
glXSwapBuffers (display, embeddedWindow); glXSwapBuffers (display, embeddedWindow);
} }
@@ -202,6 +207,7 @@ public:
if (auto GLXSwapIntervalSGI if (auto GLXSwapIntervalSGI
= (PFNGLXSWAPINTERVALSGIPROC) OpenGLHelpers::getExtensionFunction ("glXSwapIntervalSGI")) = (PFNGLXSWAPINTERVALSGIPROC) OpenGLHelpers::getExtensionFunction ("glXSwapIntervalSGI"))
{ {
ScopedXLock xlock (display);
swapFrames = numFramesPerSwap; swapFrames = numFramesPerSwap;
GLXSwapIntervalSGI (numFramesPerSwap); GLXSwapIntervalSGI (numFramesPerSwap);
return true; return true;


Loading…
Cancel
Save