From bad031aa031a5cc6935e0a0eeb2ca764e9dbe580 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 24 May 2021 15:43:58 +0100 Subject: [PATCH] iOS: Enable support for layered/async drawing --- BREAKING-CHANGES.txt | 21 +++++++++++++++++++ modules/juce_gui_basics/juce_gui_basics.cpp | 19 +++++++++++++++++ .../native/juce_ios_UIViewComponentPeer.mm | 7 +++++++ .../native/juce_mac_NSViewComponentPeer.mm | 16 -------------- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index cde55acaee..6f33212989 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -4,6 +4,27 @@ JUCE breaking changes Develop ======= +Change +------ +The functions `getComponentAsyncLayerBackedViewDisabled` +and `setComponentAsyncLayerBackedViewDisabled` were moved into the juce +namespace. + +Possible Issues +--------------- +Code that declares these functions may fail to link. + +Workaround +---------- +Move declarations of these functions into the juce namespace. + +Rationale +--------- +Although the names of these functions are unlikely to collide with functions +from other libraries, we can make such collisions much more unlikely by keeping +JUCE code in the juce namespace. + + Change ------ The `juce_blocks_basics` module was removed. diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index 8261f09192..ea68735186 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -236,6 +236,25 @@ namespace juce #include "native/juce_MultiTouchMapper.h" #endif +namespace juce +{ + +static const juce::Identifier disableAsyncLayerBackedViewIdentifier { "disableAsyncLayerBackedView" }; + +/** Used by the macOS and iOS peers. */ +void setComponentAsyncLayerBackedViewDisabled (juce::Component& comp, bool shouldDisableAsyncLayerBackedView) +{ + comp.getProperties().set (disableAsyncLayerBackedViewIdentifier, shouldDisableAsyncLayerBackedView); +} + +/** Used by the macOS and iOS peers. */ +bool getComponentAsyncLayerBackedViewDisabled (juce::Component& comp) +{ + return comp.getProperties()[disableAsyncLayerBackedViewIdentifier]; +} + +} // namespace juce + #if JUCE_MAC || JUCE_IOS #if JUCE_IOS #include "native/juce_ios_UIViewComponentPeer.mm" diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 3d0a56ede4..2c68402ac1 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -583,6 +583,13 @@ UIViewComponentPeer::UIViewComponentPeer (Component& comp, int windowStyleFlags, view.opaque = component.isOpaque(); view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0]; + #if JUCE_COREGRAPHICS_DRAW_ASYNC + if (! getComponentAsyncLayerBackedViewDisabled (component)) + { + [[view layer] setDrawsAsynchronously: YES]; + } + #endif + if (isSharedWindow) { window = [viewToAttachTo window]; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 9bd73caf04..4931fff271 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -28,22 +28,6 @@ - (float)deviceDeltaY; @end -//============================================================================== -#if defined (MAC_OS_X_VERSION_10_8) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8) \ - && USE_COREGRAPHICS_RENDERING && JUCE_COREGRAPHICS_DRAW_ASYNC -static const juce::Identifier disableAsyncLayerBackedViewIdentifier { "disableAsyncLayerBackedView" }; - -void setComponentAsyncLayerBackedViewDisabled (juce::Component& comp, bool shouldDisableAsyncLayerBackedView) -{ - comp.getProperties().set (disableAsyncLayerBackedViewIdentifier, shouldDisableAsyncLayerBackedView); -} - -bool getComponentAsyncLayerBackedViewDisabled (juce::Component& comp) -{ - return comp.getProperties()[disableAsyncLayerBackedViewIdentifier]; -} -#endif - //============================================================================== namespace juce {