1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

OpenGL: Avoid querying the native view hierarchy from a background thread on macOS

This commit is contained in:
reuk 2021-12-15 12:29:31 +00:00
parent 07dec2d369
commit 1ff05d3333
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -117,6 +117,11 @@ public:
{
if (nativeContext != nullptr)
{
#if JUCE_MAC
cvDisplayLinkWrapper = std::make_unique<CVDisplayLinkWrapper> (*this);
cvDisplayLinkWrapper->updateActiveDisplay();
#endif
renderThread = std::make_unique<ThreadPool> (1);
resume();
}
@ -142,6 +147,10 @@ public:
renderThread.reset();
}
#if JUCE_MAC
cvDisplayLinkWrapper = nullptr;
#endif
hasInitialised = false;
}
@ -587,8 +596,7 @@ public:
context.renderer->newOpenGLContextCreated();
#if JUCE_MAC
cvDisplayLinkWrapper = std::make_unique<CVDisplayLinkWrapper> (*this);
cvDisplayLinkWrapper->updateActiveDisplay();
jassert (cvDisplayLinkWrapper != nullptr);
nativeContext->setNominalVideoRefreshPeriodS (cvDisplayLinkWrapper->getNominalVideoRefreshPeriodS());
#endif
@ -597,10 +605,6 @@ public:
void shutdownOnThread()
{
#if JUCE_MAC
cvDisplayLinkWrapper = nullptr;
#endif
if (context.renderer != nullptr)
context.renderer->openGLContextClosing();
@ -735,6 +739,8 @@ public:
NSScreen* getCurrentScreen() const
{
JUCE_ASSERT_MESSAGE_THREAD;
if (auto* view = getCurrentView())
if (auto* window = [view window])
return [window screen];