From d3f91fd76c9fd99dfeb2bfdfcf5caf3af31edf99 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 14 Jan 2021 15:54:47 +0000 Subject: [PATCH] macOS: Fixed repaint issue with JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS enabled that was introduced in 8d3fd927 --- .../native/juce_mac_NSViewComponentPeer.mm | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 8f14102e70..2ca227874d 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -856,6 +856,14 @@ public: if ([screen respondsToSelector: @selector (backingScaleFactor)]) displayScale = (float) screen.backingScaleFactor; + auto invalidateTransparentWindowShadow = [this] + { + // transparent NSWindows with a drop-shadow need to redraw their shadow when the content + // changes to avoid stale shadows being drawn behind the window + if (! isSharedWindow && ! [window isOpaque] && [window hasShadow]) + [window invalidateShadow]; + }; + #if USE_COREGRAPHICS_RENDERING && JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS // This option invokes a separate paint call for each rectangle of the clip region. // It's a long story, but this is a basically a workaround for a CGContext not having @@ -876,18 +884,15 @@ public: drawRect (cg, rect, displayScale); CGContextRestoreGState (cg); } + + invalidateTransparentWindowShadow(); + return; } } - else #endif - { - drawRect (cg, r, displayScale); - } - // transparent NSWindows with a drop-shadow need to redraw their shadow when the content - // changes to avoid stale shadows being drawn behind the window - if (! isSharedWindow && ! [window isOpaque] && [window hasShadow]) - [window invalidateShadow]; + drawRect (cg, r, displayScale); + invalidateTransparentWindowShadow(); } void drawRect (CGContextRef cg, NSRect r, float displayScale)