From 144cd2d91cab008bc9a7e6d7ee8d30ef0118f616 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 Mar 2024 00:02:06 -0400 Subject: [PATCH 1/3] gsk: Avoid some allocations We can use a static font options object and allocate it only once. --- gsk/gskprivate.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/gsk/gskprivate.c b/gsk/gskprivate.c index 0ce4ab2898..2d89f66daf 100644 --- a/gsk/gskprivate.c +++ b/gsk/gskprivate.c @@ -44,9 +44,9 @@ gsk_reload_font (PangoFont *font, cairo_hint_style_t hint_style, cairo_antialias_t antialias) { - cairo_font_options_t *options; - cairo_scaled_font_t *sf; + static cairo_font_options_t *options = NULL; static PangoContext *context = NULL; + cairo_scaled_font_t *sf; #if !PANGO_VERSION_CHECK (1, 52, 0) PangoFontDescription *desc; FcPattern *pattern; @@ -80,7 +80,9 @@ gsk_reload_font (PangoFont *font, g_set_object (&last_font, font); g_clear_object (&last_result); - options = cairo_font_options_create (); + if (G_UNLIKELY (options == NULL)) + options = cairo_font_options_create (); + sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font)); cairo_scaled_font_get_font_options (sf, options); @@ -100,7 +102,6 @@ gsk_reload_font (PangoFont *font, cairo_font_options_get_subpixel_order (options) == CAIRO_SUBPIXEL_ORDER_DEFAULT) { last_result = g_object_ref (font); - cairo_font_options_destroy (options); return g_object_ref (font); } @@ -109,11 +110,10 @@ gsk_reload_font (PangoFont *font, cairo_font_options_set_antialias (options, antialias); cairo_font_options_set_subpixel_order (options, CAIRO_SUBPIXEL_ORDER_DEFAULT); - if (!context) + if (G_UNLIKELY (context == NULL)) context = pango_context_new (); pango_cairo_context_set_font_options (context, options); - cairo_font_options_destroy (options); #if PANGO_VERSION_CHECK (1, 52, 0) last_result = pango_font_map_reload_font (pango_font_get_font_map (font), font, scale, context, NULL); @@ -123,14 +123,9 @@ gsk_reload_font (PangoFont *font, if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultMatch) pango_cairo_context_set_resolution (context, dpi); - desc = pango_font_describe (font); + desc = pango_font_describe_with_absolute_size (font); size = pango_font_description_get_size (desc); - - if (pango_font_description_get_size_is_absolute (desc)) - pango_font_description_set_absolute_size (desc, size * scale); - else - pango_font_description_set_size (desc, (int) floor (size * scale + .5)); - + pango_font_description_set_absolute_size (desc, size * scale); last_result = pango_font_map_load_font (pango_font_get_font_map (font), context, desc); pango_font_description_free (desc); #endif @@ -178,15 +173,16 @@ gsk_get_unhinted_glyph_string_extents (PangoGlyphString *glyphs, cairo_hint_style_t gsk_font_get_hint_style (PangoFont *font) { + static cairo_font_options_t *options = NULL; cairo_scaled_font_t *sf; - cairo_font_options_t *options; cairo_hint_style_t style; + if (G_UNLIKELY (options == NULL)) + options = cairo_font_options_create (); + sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font)); - options = cairo_font_options_create (); cairo_scaled_font_get_font_options (sf, options); style = cairo_font_options_get_hint_style (options); - cairo_font_options_destroy (options); return style; } From 2408e227aab34da056c7a94edc74928a72bcb3fd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 Mar 2024 08:59:45 -0400 Subject: [PATCH 2/3] Add another xfail for clipped compare tests These just keep happening. --- testsuite/gsk/meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 9f1e21146d..a1c3e9cd6d 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -226,6 +226,7 @@ compare_xfails = { 'conic-gradient-with-64-colorstops': ['clipped', 'colorflipped'], 'blur-child-bounds-oversize-nogl': ['clipped'], # 6450 'rounded-clip-with-huge-bounds-nogl': ['plain','flipped','rotated','repeated','masked','replayed','clipped','colorflipped'], # 6532 + 'big-checkerboard': ['clipped'], # 6444 }, 'vulkan': { 'radial-gradient-with-64-colorstops': ['clipped', 'colorflipped'], @@ -234,6 +235,7 @@ compare_xfails = { 'repeat-repeats-nested-nogl': ['clipped'], # 6522 'repeating-radial-gradient-edge-colors': ['colorflipped'], 'rounded-clip-with-huge-bounds-nogl': ['plain','flipped','rotated','repeated','masked','replayed','clipped','colorflipped'], # 6532 + 'big-checkerboard': ['clipped'], # 6444 }, 'gl': { # 6525 From ee4a56ed4a91f5775372c492d2d2caa8d2f0e504 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 Mar 2024 21:44:02 -0400 Subject: [PATCH 3/3] settings: Mention the macOS implementation --- gtk/gtksettings.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 1aa52b6ff5..e44f35d11a 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -75,6 +75,8 @@ * On Wayland, the settings are obtained either via a settings portal, * or by reading desktop settings from DConf. * + * On macOS, the settings are obtained from `NSUserDefaults`. + * * In the absence of these sharing mechanisms, GTK reads default values for * settings from `settings.ini` files in `/etc/gtk-4.0`, `$XDG_CONFIG_DIRS/gtk-4.0` * and `$XDG_CONFIG_HOME/gtk-4.0`. These files must be valid key files (see