Browse Source

OpenGL: Allow setting window bounds from repaint callback

On Windows, the OpenGL context window sometimes receives a repaint
request after moving between screens with different scale factors.
If the screen has changed size/scale since the last paint operation,
failing to invalidate the painted area may cause the screen contents
to be drawn at the wrong scale until paint is next called.
v7.0.9
reuk 2 years ago
parent
commit
e64f87b26c
2 changed files with 7 additions and 8 deletions
  1. +1
    -0
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  2. +6
    -8
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp

+ 1
- 0
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -68,6 +68,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996 4100)
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion",
"-Wshadow",
"-Wdeprecated-register",
"-Wdeprecated-declarations",
"-Wunused-parameter",
"-Wdeprecated-writable-strings",
"-Wnon-virtual-dtor",


+ 6
- 8
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -214,7 +214,7 @@ public:
//==============================================================================
void paint (Graphics&) override
{
updateViewportSize (false);
updateViewportSize();
}
bool invalidateAll() override
@@ -352,7 +352,7 @@ public:
return true;
}
void updateViewportSize (bool canTriggerUpdate)
void updateViewportSize()
{
JUCE_ASSERT_MESSAGE_THREAD
@@ -400,9 +400,7 @@ public:
(float) newArea.getHeight() / (float) localBounds.getHeight());
nativeContext->updateWindowPosition (peer->getAreaCoveredBy (component));
if (canTriggerUpdate)
invalidateAll();
invalidateAll();
});
}
}
@@ -420,7 +418,7 @@ public:
if (lastScreenBounds != screenBounds)
{
updateViewportSize (true);
updateViewportSize();
lastScreenBounds = screenBounds;
}
}
@@ -523,7 +521,7 @@ public:
void handleResize()
{
updateViewportSize (true);
updateViewportSize();
#if JUCE_MAC
if (hasInitialised)
@@ -1052,7 +1050,7 @@ private:
if (auto* cachedImage = CachedImage::get (comp))
{
cachedImage->start(); // (must wait until this is attached before starting its thread)
cachedImage->updateViewportSize (true);
cachedImage->updateViewportSize();
startTimer (400);
}


Loading…
Cancel
Save