From 833c1e590f1ece51bf6fbb4542a06f57717ebe1c Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Fri, 17 Sep 2021 11:51:34 +0100 Subject: [PATCH] macOS/iOS: Add a Metal layer renderer This restores the functionality of JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS. Using this preprocessor flag may avoid Core Graphics rendering much larger regions than necessary, but the small regions that are rendered will likely be rendered slower. Whether using this flag improves or degrades the performance of your rendering overall will be specific to each application. Previously enabling JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS was ineffective from versions of macOS around 10.13, but enabling it didn't have any negative impact on performance. Now enabling JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS may result in slower rendering. --- .../native/juce_mac_NSViewComponentPeer.mm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 630e6d3270..aa145e37cf 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1089,14 +1089,17 @@ public: auto dispatchRectangles = [this] () { - if (metalRenderer != nullptr) + if (@available (macOS 10.14, *)) { - return metalRenderer->drawRectangleList ((CAMetalLayer*) view.layer, - (float) [[view window] backingScaleFactor], - view.frame, - getComponent(), - [this] (CGContextRef ctx, CGRect r) { drawRectWithContext (ctx, r); }, - deferredRepaints); + if (metalRenderer != nullptr) + { + return metalRenderer->drawRectangleList ((CAMetalLayer*) view.layer, + (float) [[view window] backingScaleFactor], + view.frame, + getComponent(), + [this] (CGContextRef ctx, CGRect r) { drawRectWithContext (ctx, r); }, + deferredRepaints); + } } for (auto& i : deferredRepaints)