From 0ebd5bcd3e9253ecf86dcf1e429d93545ba5df79 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 10 Jan 2017 17:54:41 +0000 Subject: [PATCH] Modified the repaint throttling to detect whether the app is a plugin using JUCEApplication::isStandaloneApp() rather than macros --- .../native/juce_mac_NSViewComponentPeer.mm | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index a092eaebc2..64b86bfdf0 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -891,12 +891,6 @@ public: void repaint (const Rectangle& area) override { - #if JucePlugin_Build_AAX || JucePlugin_Build_RTAS || JucePlugin_Build_AUv3 || JucePlugin_Build_AU || JucePlugin_Build_VST3 || JucePlugin_Build_VST - const bool shouldThrottle = true; - #else - const bool shouldThrottle = areAnyWindowsInLiveResize(); - #endif - // In 10.11 changes were made to the way the OS handles repaint regions, and it seems that it can // no longer be trusted to coalesce all the regions, or to even remember them all without losing // a few when there's a lot of activity. @@ -905,21 +899,19 @@ public: deferredRepaints.add ((float) area.getX(), (float) ([view frame].size.height - area.getBottom()), (float) area.getWidth(), (float) area.getHeight()); - // already a timer running -> stop - if (isTimerRunning()) return; + if (isTimerRunning()) + return; const uint32 now = Time::getMillisecondCounter(); - uint32 msSinceLastRepaint = - (lastRepaintTime >= now ? now - lastRepaintTime - : (std::numeric_limits::max() - lastRepaintTime) + now); + uint32 msSinceLastRepaint = (lastRepaintTime >= now) ? now - lastRepaintTime + : (std::numeric_limits::max() - lastRepaintTime) + now; static uint32 minimumRepaintInterval = 1000 / 30; // 30fps // When windows are being resized, artificially throttling high-frequency repaints helps // to stop the event queue getting clogged, and keeps everything working smoothly. // For some reason Logic also needs this throttling to recored parameter events correctly. - if (shouldThrottle - && msSinceLastRepaint < minimumRepaintInterval) + if (msSinceLastRepaint < minimumRepaintInterval && shouldThrottleRepaint()) { startTimer (static_cast (minimumRepaintInterval - msSinceLastRepaint)); return; @@ -928,6 +920,11 @@ public: setNeedsDisplayRectangles(); } + static bool shouldThrottleRepaint() + { + return areAnyWindowsInLiveResize() || ! JUCEApplication::isStandaloneApp(); + } + void timerCallback() override { setNeedsDisplayRectangles();