macOS: Big Sur performance patch

One of 4 that were applied on Gimp 2.99. Original authorship
@DesMcGuiness and adapted to Gtk3 by @lukaso
This commit is contained in:
Lukas Oberhuber 2021-12-18 22:59:58 +00:00
parent c3b3f4711d
commit 10b5f8a0d6
2 changed files with 36 additions and 4 deletions

View File

@ -289,6 +289,22 @@
gdk_screen_get_rgba_visual (_gdk_screen);
}
- (void) viewWillDraw
{
/* MacOS 11 (Big Sur) has added a new, dynamic "accent" as default.
* This uses a 10-bit colorspace so every GIMP drawing operation
* has the additional cost of an 8-bit (ARGB) to 10-bit conversion.
* Let's disable this mode to regain the lost performance.
*/
if(gdk_quartz_osx_version() >= GDK_OSX_BIGSUR)
{
CALayer* layer = self.layer;
layer.contentsFormat = kCAContentsFormatRGBA8Uint;
}
[super viewWillDraw];
}
-(void)drawRect: (NSRect)rect
{
GdkRectangle gdk_rect;

View File

@ -161,10 +161,18 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
* buttons in spinbuttons or the position marker in rulers.
*/
if (window_impl->in_paint_rect_count == 0)
{
/* The NSView focus-locking API set was deprecated in MacOS 10.14 and
* has a significant cost in MacOS 11 - every lock/unlock seems to
* trigger a drawRect: call for the entire window. To return the
* lost performance, do not use the locking API in MacOS 11+
*/
if(gdk_quartz_osx_version() < GDK_OSX_BIGSUR)
{
if (![window_impl->view lockFocusIfCanDraw])
return NULL;
}
}
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
#else
@ -201,6 +209,14 @@ gdk_window_impl_quartz_release_context (GdkWindowImplQuartz *window_impl,
if (window_impl->in_paint_rect_count == 0)
{
_gdk_quartz_window_flush (window_impl);
/* As per gdk_window_impl_quartz_get_context(), the NSView
* focus-locking API set was deprecated in MacOS 10.14 and has
* a significant cost in MacOS 11 - every lock/unlock seems to
* trigger a drawRect: call for the entire window. To return the
* lost performance, do not use the locking API in MacOS 11+
*/
if(gdk_quartz_osx_version() < GDK_OSX_BIGSUR)
[window_impl->view unlockFocus];
}
}