From 5d23645ca28be32429729a7591f3376f5efed6ed Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 23 Feb 2016 10:01:57 +0000 Subject: [PATCH] Workaround for some OSX10.11 repaint region coalescing problems --- .../geometry/juce_RectangleList.h | 2 +- .../native/juce_mac_NSViewComponentPeer.mm | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index 8863a0e20a..ac3bc7d82f 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -524,7 +524,7 @@ public: */ void consolidate() { - for (int i = 0; i < getNumRectangles() - 1; ++i) + for (int i = 0; i < rects.size() - 1; ++i) { RectangleType& r = rects.getReference (i); const ValueType rx1 = r.getX(); diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index b6b551ef48..d786ac61a4 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -859,18 +859,14 @@ public: void repaint (const Rectangle& area) override { - Rectangle r ((float) area.getX(), [view frame].size.height - (float) area.getBottom(), - (float) area.getWidth(), (float) area.getHeight()); - - if (insideDrawRect || areAnyWindowsInLiveResize()) - { - deferredRepaints.add (r); - triggerAsyncUpdate(); - } - else - { - [view setNeedsDisplayInRect: makeNSRect (r)]; - } + // 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. + // As a work around for this, we use a RectangleList to do our own coalescing of regions before + // asynchronously asking the OS to repaint them. + deferredRepaints.add ((float) area.getX(), (float) ([view frame].size.height - area.getBottom()), + (float) area.getWidth(), (float) area.getHeight()); + triggerAsyncUpdate(); } void invokePaint (LowLevelGraphicsContext& context)