From 951a3dd9a78c7882106b5c0d5c0a74454ffcd387 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 7 Feb 2023 09:48:16 -0800 Subject: [quartz]Conditionally Use Main Display ColorSpace instead of kCGColorSpaceDefaultRGB. The default RGB colorspace must be converted to the GPU's colorspace using CGColorTransformConvertUsingCMSConverter. Profiling has shown this function to consume as much as 48% of a redraw cycle in gdk-quartz. There seems to be no named colorspace that matches the one stored on the display, so we use the one associated with the main display. This has some risks for users with multiple monitors but in testing with my own two-monitor setup, one of which is HDR and the other not, the colorspace was the same for both. This is applied to quartz surfaces created with cairo_quartz_surface_create(); surfaces created with cairo_quartz_surface_create_for_cg_context will inherit the colorspace from the context. In order to generate PNGs that look right I've converted the existing debugging functions for writing a quartz surface to png into private functions and wired cairo-boilerplate-quartz to use them. Using the generic cairo routine produced washed-out PNGs. Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/330 --- boilerplate/cairo-boilerplate-quartz.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'boilerplate') diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c index d4ca35383..1a1417c75 100644 --- a/boilerplate/cairo-boilerplate-quartz.c +++ b/boilerplate/cairo-boilerplate-quartz.c @@ -26,7 +26,7 @@ #include "cairo-boilerplate-private.h" -#include +#include static cairo_surface_t * _cairo_boilerplate_quartz_create_surface (const char *name, @@ -56,7 +56,7 @@ static const cairo_boilerplate_target_t targets[] = { cairo_surface_create_similar, NULL, NULL, _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, + _cairo_quartz_surface_to_png, NULL, NULL, NULL, TRUE, FALSE, FALSE }, @@ -68,7 +68,7 @@ static const cairo_boilerplate_target_t targets[] = { cairo_surface_create_similar, NULL, NULL, _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, + _cairo_quartz_surface_to_png, NULL, NULL, NULL, FALSE, FALSE, FALSE }, -- cgit v1.2.1