1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-05 03:50:07 +00:00

macOS/iOS: Enable asynchronous Core Graphics rendering by default

The helper function setComponentAsyncLayerBackedViewDisabled has been replaced
by a windowRequiresSynchronousCoreGraphicsRendering ComponentPeer style flag.
This commit is contained in:
Tom Poole 2022-02-24 10:11:31 +00:00
parent dea3fe60e4
commit 89a67ec556
5 changed files with 58 additions and 55 deletions

View file

@ -4,6 +4,32 @@ JUCE breaking changes
develop
=======
Change
------
The optional JUCE_COREGRAPHICS_DRAW_ASYNC preprocessor flag has been removed
and asynchronous Core Graphics rendering is now the default. The helper
function setComponentAsyncLayerBackedViewDisabled has also been removed.
Possible Issues
---------------
Components that were previously using setComponentAsyncLayerBackedViewDisabled
to conditionally opt out of asynchronous Core Graphics rendering will no longer
be able to do so.
Workaround
----------
To opt out of asynchronous Core Graphics rendering the
windowRequiresSynchronousCoreGraphicsRendering ComponentPeer style flag can be
used when adding a component to the desktop.
Rationale
---------
Asynchronous Core Graphics rendering provides a substantial performance
benefit. Asynchronous rendering is a property of a Peer, rather than a
Component, so a Peer style flag to conditionally opt out of asynchronous
rendering is more appropriate.
Change
------
Constructors of AudioParameterBool, AudioParameterChoice, AudioParameterFloat,

View file

@ -254,29 +254,6 @@ namespace juce
#include "native/accessibility/juce_AccessibilityTextHelpers.h"
#endif
namespace juce
{
static const juce::Identifier disableAsyncLayerBackedViewIdentifier { "disableAsyncLayerBackedView" };
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wmissing-prototypes")
/** 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];
}
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
} // namespace juce
#if JUCE_MAC || JUCE_IOS
#include "native/accessibility/juce_mac_AccessibilitySharedCode.mm"

View file

@ -659,10 +659,8 @@ UIViewComponentPeer::UIViewComponentPeer (Component& comp, int windowStyleFlags,
view.opaque = component.isOpaque();
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
#if JUCE_COREGRAPHICS_DRAW_ASYNC
if (! getComponentAsyncLayerBackedViewDisabled (component))
if ((windowStyleFlags & ComponentPeer::windowRequiresSynchronousCoreGraphicsRendering) == 0)
[[view layer] setDrawsAsynchronously: YES];
#endif
if (isSharedWindow)
{

View file

@ -134,8 +134,8 @@ public:
[view setPostsFrameChangedNotifications: YES];
#if USE_COREGRAPHICS_RENDERING && JUCE_COREGRAPHICS_DRAW_ASYNC
if (! getComponentAsyncLayerBackedViewDisabled (component))
#if USE_COREGRAPHICS_RENDERING
if ((windowStyleFlags & ComponentPeer::windowRequiresSynchronousCoreGraphicsRendering) == 0)
{
if (@available (macOS 10.8, *))
{
@ -776,11 +776,9 @@ public:
name: NSWindowWillMiniaturizeNotification
object: currentWindow];
#if JUCE_COREGRAPHICS_DRAW_ASYNC
[notificationCenter removeObserver: view
name: NSWindowDidBecomeKeyNotification
object: currentWindow];
#endif
}
if (isSharedWindow && [view window] == window && newWindow == nullptr)

View file

@ -40,31 +40,35 @@ public:
/** A combination of these flags is passed to the ComponentPeer constructor. */
enum StyleFlags
{
windowAppearsOnTaskbar = (1 << 0), /**< Indicates that the window should have a corresponding
entry on the taskbar (ignored on MacOSX) */
windowIsTemporary = (1 << 1), /**< Indicates that the window is a temporary popup, like a menu,
tooltip, etc. */
windowIgnoresMouseClicks = (1 << 2), /**< Indicates that the window should let mouse clicks pass
through it (may not be possible on some platforms). */
windowHasTitleBar = (1 << 3), /**< Indicates that the window should have a normal OS-specific
title bar and frame. if not specified, the window will be
borderless. */
windowIsResizable = (1 << 4), /**< Indicates that the window should have a resizable border. */
windowHasMinimiseButton = (1 << 5), /**< Indicates that if the window has a title bar, it should have a
minimise button on it. */
windowHasMaximiseButton = (1 << 6), /**< Indicates that if the window has a title bar, it should have a
maximise button on it. */
windowHasCloseButton = (1 << 7), /**< Indicates that if the window has a title bar, it should have a
close button on it. */
windowHasDropShadow = (1 << 8), /**< Indicates that the window should have a drop-shadow (this may
not be possible on all platforms). */
windowRepaintedExplictly = (1 << 9), /**< Not intended for public use - this tells a window not to
do its own repainting, but only to repaint when the
performAnyPendingRepaintsNow() method is called. */
windowIgnoresKeyPresses = (1 << 10), /**< Tells the window not to catch any keypresses. This can
be used for things like plugin windows, to stop them interfering
with the host's shortcut keys. */
windowIsSemiTransparent = (1 << 30) /**< Not intended for public use - makes a window transparent. */
windowAppearsOnTaskbar = (1 << 0), /**< Indicates that the window should have a corresponding
entry on the taskbar (ignored on MacOSX) */
windowIsTemporary = (1 << 1), /**< Indicates that the window is a temporary popup, like a menu,
tooltip, etc. */
windowIgnoresMouseClicks = (1 << 2), /**< Indicates that the window should let mouse clicks pass
through it (may not be possible on some platforms). */
windowHasTitleBar = (1 << 3), /**< Indicates that the window should have a normal OS-specific
title bar and frame. if not specified, the window will be
borderless. */
windowIsResizable = (1 << 4), /**< Indicates that the window should have a resizable border. */
windowHasMinimiseButton = (1 << 5), /**< Indicates that if the window has a title bar, it should have a
minimise button on it. */
windowHasMaximiseButton = (1 << 6), /**< Indicates that if the window has a title bar, it should have a
maximise button on it. */
windowHasCloseButton = (1 << 7), /**< Indicates that if the window has a title bar, it should have a
close button on it. */
windowHasDropShadow = (1 << 8), /**< Indicates that the window should have a drop-shadow (this may
not be possible on all platforms). */
windowRepaintedExplictly = (1 << 9), /**< Not intended for public use - this tells a window not to
do its own repainting, but only to repaint when the
performAnyPendingRepaintsNow() method is called. */
windowIgnoresKeyPresses = (1 << 10), /**< Tells the window not to catch any keypresses. This can
be used for things like plugin windows, to stop them interfering
with the host's shortcut keys. */
windowRequiresSynchronousCoreGraphicsRendering = (1 << 11), /**< Indicates that the window should not be rendered with
asynchronous Core Graphics drawing operations. Use this if there
are issues with regions not being redrawn at the expected time
(macOS and iOS only). */
windowIsSemiTransparent = (1 << 30) /**< Not intended for public use - makes a window transparent. */
};