Skip to content

Commit

Permalink
iOS: Enable support for layered/async drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
reuk committed May 24, 2021
1 parent bc796b1 commit bad031a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
21 changes: 21 additions & 0 deletions BREAKING-CHANGES.txt
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions modules/juce_gui_basics/juce_gui_basics.cpp
Expand Up @@ -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"
Expand Down
Expand Up @@ -583,6 +583,13 @@ - (void) becomeKeyWindow
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];
Expand Down
16 changes: 0 additions & 16 deletions modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
Expand Up @@ -28,22 +28,6 @@ - (float)deviceDeltaX;
- (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
{
Expand Down

0 comments on commit bad031a

Please sign in to comment.