forked from AuroraMiddleware/gtk
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:
parent
c3b3f4711d
commit
10b5f8a0d6
@ -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;
|
||||
@ -416,7 +432,7 @@
|
||||
{
|
||||
if (GDK_WINDOW_DESTROYED (gdk_window))
|
||||
return;
|
||||
|
||||
|
||||
[super setFrame: frame];
|
||||
|
||||
if ([self window])
|
||||
|
@ -162,8 +162,16 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
|
||||
*/
|
||||
if (window_impl->in_paint_rect_count == 0)
|
||||
{
|
||||
if (![window_impl->view lockFocusIfCanDraw])
|
||||
return NULL;
|
||||
/* 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];
|
||||
@ -201,7 +209,15 @@ gdk_window_impl_quartz_release_context (GdkWindowImplQuartz *window_impl,
|
||||
if (window_impl->in_paint_rect_count == 0)
|
||||
{
|
||||
_gdk_quartz_window_flush (window_impl);
|
||||
[window_impl->view unlockFocus];
|
||||
|
||||
/* 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user