Compare commits

...

21 Commits

Author SHA1 Message Date
Matthias Clasen
c6c039e11b tests: Add a difficult node
This node has the Fira e glyph in various sizes,
to demonstrate clipping of text bounds.
2024-05-03 19:05:36 -04:00
Matthias Clasen
20e269655b Hack: Debug for text bounds
Set DEBUG_TEXT_BOUNDS=1 to see the bounds of your text nodes
as beautiful yellow boxes.
2024-05-03 19:04:00 -04:00
Matthias Clasen
0c7d22207b Hack: Download atlases
Make ngl save its current atlas every frame.
2024-05-03 19:03:44 -04:00
Matthias Clasen
49c5692958 Just go back to +1 2024-05-03 19:03:44 -04:00
Matthias Clasen
a0faa99b80 Add a back a helper to get extents
Make a helper function that returns unhinted extents.
2024-05-03 19:03:18 -04:00
Matthias Clasen
ba354b6478 nodeparser: Accept antialias: good 2024-05-03 19:03:18 -04:00
Matthias Clasen
edbd13f36f gsk: Drop an unused private function
gsk_font_get_hint_style is no longer used.
2024-05-03 19:03:18 -04:00
Matthias Clasen
949aacb417 gsk: Use gsk_font_get_rendering
Use gsk_font_get_rendering to find the font options to use.
It is a bit unfortunate that we have to call that function
multiple times. Maybe we should pass the font options down.
2024-05-03 19:03:18 -04:00
Matthias Clasen
791ce9ba24 Add gsk_font_get_rendering
This function takes the font and scale, and determines what font
options to use, based on the passed down font rendering setting,
and the device pixel size of the font.

Currently, we use hinting if the font size is less than 31 pixels,
which corresponds to the size of an 11pt font at a dpi of 200.
2024-05-03 19:03:18 -04:00
Matthias Clasen
4ef73f74e5 widget: Delay deciding font rendering
Don't translate the font rendering setting into font options
ahead of time. Instead just avoid rounding to application pixels
during layout, and pass the font rendering setting to gsk for
a later decision.
2024-05-03 19:03:18 -04:00
Matthias Clasen
4184e09429 gtk-demo: Add smaller font size to waterfall 2024-05-03 19:03:18 -04:00
Matthias Clasen
f579b171a9 Merge branch 'gbsneto/more-win32-cleanups' into 'main'
Various cleanups around Win32

See merge request GNOME/gtk!7223
2024-05-03 17:27:05 +00:00
Georges Basile Stavracas Neto
f9929d15eb gtk-demo: Remove set-but-unused variable 2024-05-03 12:30:39 -03:00
Georges Basile Stavracas Neto
c45a6ad52d gsk/gpu: Use G_GSIZE_FORMAT for printing gsizes
On Windows, gsize is a long long unsigned. The compiler complains about
that.

Use G_GSIZE_FORMAT which translates to %llu on Windows, %lu on most
platforms, and sometimes just %u on rare cases.
2024-05-03 12:30:39 -03:00
Matthias Clasen
7233e38aa8 Merge branch 'gbsneto/cleanup-meson-profiler' into 'main'
testsuite: Remove leftover code from meson.build

See merge request GNOME/gtk!7222
2024-05-03 13:44:07 +00:00
Benjamin Otte
73ba97acd9 Merge branch 'duplicate-gl-version' into 'main'
glcontext: Remove duplicate check for GL version

See merge request GNOME/gtk!7221
2024-05-03 13:42:03 +00:00
Georges Basile Stavracas Neto
7d2ad604d2 win32/vulkancontext: Remove unused variable
Silences a compiler warning.
2024-05-03 09:52:57 -03:00
Georges Basile Stavracas Neto
45e64b915c win32/wgl: Initialize hwnd to NULL
Otherwise there's a valid code path that may return it uninitialized.
2024-05-03 09:51:46 -03:00
Georges Basile Stavracas Neto
ebaef9f18b win32/cursor: Ignore GdkPixbuf deprecation warning
Seems harmless to ignore this for now, other bits of code also ignore
this.
2024-05-03 09:49:46 -03:00
Robert Ancell
c73fe8ac4a glcontext: Remove duplicate check for GL version 2024-05-03 16:40:01 +12:00
Georges Basile Stavracas Neto
8ed8f883d1 testsuite: Remove leftover code from meson.build
Performance tests were dropped at 5dd0d39a6b. The 'profiler' option
was renamed to 'sysprof' by commit e915a1aa7f.
2024-05-02 20:28:27 -03:00
22 changed files with 306 additions and 140 deletions

View File

@@ -746,7 +746,7 @@ update_display (void)
if (do_waterfall)
{
waterfall = g_string_new ("");
int sizes[] = { 7, 8, 9, 10, 12, 14, 16, 20, 24, 30, 40, 50, 60, 70, 90 };
int sizes[] = { 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 20, 24, 30, 40, 50, 60, 70, 90 };
start = 0;
for (int i = 0; i < G_N_ELEMENTS (sizes); i++)
{

View File

@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
{
wchar_t *langname_w = NULL;
wchar_t locale_abbrev_w[9];
gchar *langname, *locale_abbrev, *locale, *p;
gchar *langname, *locale_abbrev, *locale;
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
@@ -59,7 +59,6 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);

View File

@@ -1956,8 +1956,6 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
return "#version 310 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else
return "#version 100";
}

View File

@@ -908,7 +908,9 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
width = cairo_image_surface_get_width (surface);
height = cairo_image_surface_get_height (surface);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
G_GNUC_END_IGNORE_DEPRECATIONS
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);

View File

@@ -267,7 +267,7 @@ create_dummy_gl_window (void)
{
WNDCLASS wclass = { 0, };
ATOM klass;
HWND hwnd;
HWND hwnd = NULL;
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;

View File

@@ -38,7 +38,6 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
{
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
VkWin32SurfaceCreateInfoKHR info;
VkResult result;

View File

@@ -132,6 +132,47 @@ gsk_gl_device_make_current (GskGpuDevice *device)
gdk_gl_context_make_current (gdk_display_get_gl_context (gsk_gpu_device_get_display (device)));
}
static void
save_texture_to_png (GdkDisplay *display,
int texture_id,
int width,
int height,
const char *filename)
{
GdkGLTextureBuilder *builder;
GdkTexture *texture;
builder = gdk_gl_texture_builder_new ();
gdk_gl_texture_builder_set_context (builder, gdk_display_get_gl_context (display));
gdk_gl_texture_builder_set_id (builder, texture_id);
gdk_gl_texture_builder_set_width (builder, width);
gdk_gl_texture_builder_set_height (builder, height);
texture = gdk_gl_texture_builder_build (builder, NULL, NULL);
gdk_texture_save_to_png (texture, filename);
g_object_unref (texture);
g_object_unref (builder);
}
static void
gsk_gl_device_end_frame (GskGpuDevice *device)
{
GskGpuImage *image;
static int count = 0;
char *filename;
image = gsk_gpu_device_get_atlas_image (device);
filename = g_strdup_printf ("atlas%d.png", count++);
save_texture_to_png (gsk_gpu_device_get_display (device),
gsk_gl_image_peek_texture (GSK_GL_IMAGE (image)),
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image),
filename);
g_free (filename);
}
static void
gsk_gl_device_finalize (GObject *object)
{
@@ -159,6 +200,7 @@ gsk_gl_device_class_init (GskGLDeviceClass *klass)
gpu_device_class->create_upload_image = gsk_gl_device_create_upload_image;
gpu_device_class->create_download_image = gsk_gl_device_create_download_image;
gpu_device_class->make_current = gsk_gl_device_make_current;
gpu_device_class->end_frame = gsk_gl_device_end_frame;
object_class->finalize = gsk_gl_device_finalize;
}
@@ -698,4 +740,3 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
/* fallbacks will always fallback to a supported format */
g_assert_not_reached ();
}

View File

@@ -316,3 +316,9 @@ gsk_gl_image_steal_texture (GskGLImage *self)
return self->texture_id;
}
GLuint
gsk_gl_image_peek_texture (GskGLImage *self)
{
return self->texture_id;
}

View File

@@ -39,4 +39,7 @@ GLenum gsk_gl_image_get_gl_type (GskGLIm
GLuint gsk_gl_image_steal_texture (GskGLImage *self);
GLuint gsk_gl_image_peek_texture (GskGLImage *self);
G_END_DECLS

View File

@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
{
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%lu dead pixels)", dead_texture_pixels);
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
gsk_gpu_device_gc (self, g_get_monotonic_time ());
}
}
@@ -907,7 +907,9 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
gsize atlas_x, atlas_y, padding;
float subpixel_x, subpixel_y;
PangoFont *scaled_font;
cairo_antialias_t antialias;
cairo_hint_metrics_t hint_metrics;
cairo_hint_style_t hint_style;
cache = g_hash_table_lookup (priv->glyph_cache, &lookup);
if (cache)
@@ -919,15 +921,8 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
return cache->image;
}
/* The combination of hint-style != none and hint-metrics == off
* leads to broken rendering with some fonts.
*/
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
hint_metrics = CAIRO_HINT_METRICS_ON;
else
hint_metrics = CAIRO_HINT_METRICS_DEFAULT;
scaled_font = gsk_reload_font (font, scale, hint_metrics, CAIRO_HINT_STYLE_DEFAULT, CAIRO_ANTIALIAS_DEFAULT);
gsk_font_get_rendering (font, scale, &hint_metrics, &hint_style, &antialias);
scaled_font = gsk_reload_font (font, scale, hint_metrics, hint_style, antialias);
subpixel_x = (flags & 3) / 4.f;
subpixel_y = ((flags >> 2) & 3) / 4.f;
@@ -991,5 +986,12 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
return cache->image;
}
void
gsk_gpu_device_end_frame (GskGpuDevice *self)
{
if (GSK_GPU_DEVICE_GET_CLASS (self))
GSK_GPU_DEVICE_GET_CLASS (self)->end_frame (self);
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

View File

@@ -42,7 +42,7 @@ struct _GskGpuDeviceClass
gsize width,
gsize height);
void (* make_current) (GskGpuDevice *self);
void (* end_frame) (GskGpuDevice *self);
};
GType gsk_gpu_device_get_type (void) G_GNUC_CONST;
@@ -99,6 +99,8 @@ GskGpuImage * gsk_gpu_device_lookup_glyph_image (GskGpuD
graphene_point_t *out_origin);
void gsk_gpu_device_end_frame (GskGpuDevice *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskGpuDevice, g_object_unref)
G_END_DECLS

View File

@@ -3008,6 +3008,9 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
GskGpuImage *last_image;
guint32 descriptor;
const float inv_pango_scale = 1.f / PANGO_SCALE;
cairo_hint_metrics_t hint_metrics;
cairo_hint_style_t hint_style;
cairo_antialias_t antialias;
if (self->opacity < 1.0 &&
gsk_text_node_has_color_glyphs (node))
@@ -3016,6 +3019,17 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
return;
}
if (g_getenv ("DEBUG_TEXT_BOUNDS"))
{
GdkRGBA color;
GskRenderNode *c;
gdk_rgba_parse (&color, "yellow");
c = gsk_color_node_new (&color, &node->bounds);
gsk_gpu_node_processor_add_color_node (self, c);
gsk_render_node_unref (c);
}
device = gsk_gpu_frame_get_device (self->frame);
color = *gsk_text_node_get_color (node);
@@ -3030,7 +3044,8 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
scale = MAX (graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale));
inv_scale = 1.f / scale;
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
gsk_font_get_rendering (font, scale, &hint_metrics, &hint_style, &antialias);
if (hint_style != CAIRO_HINT_STYLE_NONE)
{
align_scale_x = scale * 4;
align_scale_y = scale;
@@ -3128,6 +3143,9 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
float inv_align_scale_x, inv_align_scale_y;
unsigned int flags_mask;
const float inv_pango_scale = 1.f / PANGO_SCALE;
cairo_hint_metrics_t hint_metrics;
cairo_hint_style_t hint_style;
cairo_antialias_t antialias;
if (gsk_text_node_has_color_glyphs (node))
return FALSE;
@@ -3147,7 +3165,8 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
gsk_gpu_pattern_writer_append_rgba (self, gsk_text_node_get_color (node));
gsk_gpu_pattern_writer_append_uint (self, num_glyphs);
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
gsk_font_get_rendering (font, scale, &hint_metrics, &hint_style, &antialias);
if (hint_style != CAIRO_HINT_STYLE_NONE)
{
align_scale_x = scale * 4;
align_scale_y = scale;

View File

@@ -423,6 +423,7 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
gsk_gpu_device_queue_gc (priv->device);
gdk_draw_context_end_frame (priv->context);
gsk_gpu_device_end_frame (priv->device);
g_clear_pointer (&render_region, cairo_region_destroy);
}

View File

@@ -1139,7 +1139,7 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
format);
GSK_DEBUG (SHADERS,
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%lu/%lu/%lu)",
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT ")",
op_class->shader_name,
version_string + 1,
variation,

View File

@@ -25,11 +25,27 @@ gsk_ensure_resources (void)
g_once (&register_resources_once, register_resources, NULL);
}
static cairo_font_options_t *font_options = NULL;
static inline cairo_font_options_t *
pango_font_get_cairo_font_options (PangoFont *font)
{
cairo_scaled_font_t *sf;
if (G_UNLIKELY (font_options == NULL))
font_options = cairo_font_options_create ();
sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font));
cairo_scaled_font_get_font_options (sf, font_options);
return font_options;
}
/*< private >
* gsk_reload_font:
* @font: a `PangoFont`
* @scale: the scale to apply
* @hint_metris: hint metrics to use or `CAIRO_HINT_METRICS_DEFAILT` to keep the
* @hint_metris: hint metrics to use or `CAIRO_HINT_METRICS_DEFAULT` to keep the
* hint metrics of the font unchanged
* @hint_style: hint style to use or `CAIRO_HINT_STYLE_DEFAULT` to keep the
* hint style of @font unchanged
@@ -48,9 +64,8 @@ gsk_reload_font (PangoFont *font,
cairo_hint_style_t hint_style,
cairo_antialias_t antialias)
{
static cairo_font_options_t *options = NULL;
static PangoContext *context = NULL;
cairo_scaled_font_t *sf;
cairo_font_options_t *options;
/* These requests often come in sequentially so keep the result
* around and re-use it if everything matches.
@@ -78,11 +93,7 @@ gsk_reload_font (PangoFont *font,
g_set_object (&last_font, font);
g_clear_object (&last_result);
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);
options = pango_font_get_cairo_font_options (font);
if (hint_metrics == CAIRO_HINT_METRICS_DEFAULT)
hint_metrics = cairo_font_options_get_hint_metrics (options);
@@ -118,27 +129,103 @@ gsk_reload_font (PangoFont *font,
return g_object_ref (last_result);
}
/*< private >
* gsk_font_get_hint_style:
* @font: a `PangoFont`
*
* Get the hint style from the cairo font options.
*
* Returns: the hint style
*/
cairo_hint_style_t
gsk_font_get_hint_style (PangoFont *font)
static inline double
gsk_font_get_size (PangoFont *font)
{
static cairo_font_options_t *options = NULL;
cairo_scaled_font_t *sf;
cairo_hint_style_t style;
PangoFontDescription *desc;
double size;
if (G_UNLIKELY (options == NULL))
options = cairo_font_options_create ();
desc = pango_font_describe_with_absolute_size (font);
sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font));
cairo_scaled_font_get_font_options (sf, options);
style = cairo_font_options_get_hint_style (options);
size = pango_font_description_get_size (desc);
return style;
pango_font_description_free (desc);
return size / PANGO_SCALE;
}
/*< private >
* gsk_font_get_rendering:
* @font: a `PangoFont`
* @scale: the scale to use
* @hint_metrics: (out): return location for metrics hinting
* @hint_style: (out): return location for hint style
* @antialias: (out): return location for antialiasing
*
* Determines the font options to use for rendering with
* the font at the given scale.
*/
void
gsk_font_get_rendering (PangoFont *font,
float scale,
cairo_hint_metrics_t *hint_metrics,
cairo_hint_style_t *hint_style,
cairo_antialias_t *antialias)
{
const cairo_font_options_t *options;
options = pango_font_get_cairo_font_options (font);
/* Keep this in sync with gtkwidget.c:update_pango_context */
if (cairo_font_options_get_antialias (options) == CAIRO_ANTIALIAS_GOOD)
{
double font_size;
font_size = gsk_font_get_size (font) * scale;
*antialias = CAIRO_ANTIALIAS_GRAY;
*hint_metrics = CAIRO_HINT_METRICS_OFF;
/* 31 pixels is equivalent to an 11 pt font at 200 dpi */
if (font_size > 31)
*hint_style = CAIRO_HINT_STYLE_NONE;
else
*hint_style = CAIRO_HINT_STYLE_SLIGHT;
}
else
{
*antialias = cairo_font_options_get_antialias (options);
*hint_metrics = cairo_font_options_get_hint_metrics (options);
*hint_style = cairo_font_options_get_hint_style (options);
}
/* The combination of hint-style != none and hint-metrics == off
* leads to broken rendering with some fonts.
*/
if (*hint_style != CAIRO_HINT_STYLE_NONE)
*hint_metrics = CAIRO_HINT_METRICS_ON;
}
/*< private >
* gsk_font_get_extents:
* @font: a `PangoFont`
* @glyphs: a `PangoGlyphString`
* @ink_rect: (out): rectangle used to store the extents of the glyph
* string as drawn
*
* Compute the ink extents of a glyph string.
*
* This is like [method@Pango.GlyphString.extents], but it provides
* unhinted extents.
*/
void
gsk_font_get_extents (PangoFont *font,
PangoGlyphString *glyphs,
PangoRectangle *ink_rect)
{
PangoFont *unhinted;
unhinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF,
CAIRO_HINT_STYLE_NONE,
CAIRO_ANTIALIAS_GRAY);
pango_glyph_string_extents (glyphs, unhinted, ink_rect, NULL);
/* Hack: Without this, cff fonts like Fira get clipped */
ink_rect->x -= 1024;
ink_rect->y -= 1024;
ink_rect->width += 2048;
ink_rect->height += 2048;
g_object_unref (unhinted);
}

View File

@@ -6,15 +6,22 @@
G_BEGIN_DECLS
void gsk_ensure_resources (void);
void gsk_ensure_resources (void);
PangoFont *gsk_reload_font (PangoFont *font,
float scale,
cairo_hint_metrics_t hint_metrics,
cairo_hint_style_t hint_style,
cairo_antialias_t antialias);
PangoFont *gsk_reload_font (PangoFont *font,
float scale,
cairo_hint_metrics_t hint_metrics,
cairo_hint_style_t hint_style,
cairo_antialias_t antialias);
cairo_hint_style_t gsk_font_get_hint_style (PangoFont *font);
void gsk_font_get_rendering (PangoFont *font,
float scale,
cairo_hint_metrics_t *hint_metrics,
cairo_hint_style_t *hint_style,
cairo_antialias_t *antialias);
void gsk_font_get_extents (PangoFont *font,
PangoGlyphString *glyphs,
PangoRectangle *ink_rect);
G_END_DECLS

View File

@@ -5825,7 +5825,7 @@ gsk_text_node_new (PangoFont *font,
PangoGlyphInfo *glyph_infos;
int n;
pango_glyph_string_extents (glyphs, font, &ink_rect, NULL);
gsk_font_get_extents (font, glyphs, &ink_rect);
/* Don't create nodes with empty bounds */
if (ink_rect.width == 0 || ink_rect.height == 0)

View File

@@ -2302,7 +2302,8 @@ parse_antialias (GtkCssParser *parser,
return FALSE;
if (*(cairo_antialias_t *) out != CAIRO_ANTIALIAS_NONE &&
*(cairo_antialias_t *) out != CAIRO_ANTIALIAS_GRAY)
*(cairo_antialias_t *) out != CAIRO_ANTIALIAS_GRAY &&
*(cairo_antialias_t *) out != CAIRO_ANTIALIAS_GOOD)
{
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
g_type_name (CAIRO_GOBJECT_TYPE_ANTIALIAS));
@@ -3662,9 +3663,11 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
append_enum_param (p, "hint-style", CAIRO_GOBJECT_TYPE_HINT_STYLE, hint_style);
/* CAIRO_ANTIALIAS_NONE is the only value we ever emit here, since gray is the default,
* and we don't accept any other values.
* and we don't accept any other values. We do accept GOOD as GTK uses that to pass
* the gtk-font-rendering value down.
*/
if (antialias == CAIRO_ANTIALIAS_NONE)
if (antialias == CAIRO_ANTIALIAS_NONE ||
antialias == CAIRO_ANTIALIAS_GOOD)
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,

View File

@@ -6513,39 +6513,22 @@ gtk_widget_update_pango_context (GtkWidget *widget,
else
{
cairo_font_options_t *options;
double dpi = 96.;
GdkSurface *surface;
surface = gtk_widget_get_surface (widget);
if (surface)
{
GdkDisplay *display;
GdkMonitor *monitor;
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_monitor_at_surface (display, surface);
if (monitor)
dpi = gdk_monitor_get_dpi (monitor);
}
options = cairo_font_options_create ();
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
/* HACK: Use CAIRO_ANTIALIAS_GOOD to communicate 'automatic' to gsk */
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GOOD);
if (dpi < 200.)
{
/* Not high-dpi. Prefer sharpness by enabling hinting */
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_SLIGHT);
}
else
{
/* High-dpi. Prefer precise positioning */
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
}
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
/* Don't do any rounding during layout. In particular with fractional
* scaling, we want to avoid rounding to application pixels, since the
* may not align with the device pixel grid.
*/
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
pango_context_set_round_glyph_positions (context, FALSE);
pango_cairo_context_set_font_options (context, options);
cairo_font_options_destroy (options);

66
tests/demo.node Normal file
View File

@@ -0,0 +1,66 @@
transform {
transform: scale(1);
child: container {
color {
color: white;
bounds: -5 -20 140 30;
}
text {
font: "Fira Sans Medium 21px";
glyphs: "e";
offset: -2 0;
}
text {
font: "Fira Sans Medium 20.5px";
glyphs: "e";
offset: 11 0;
}
text {
font: "Fira Sans Medium 20px";
glyphs: "e";
offset: 24 0;
}
text {
font: "Fira Sans Medium 19.5px";
glyphs: "e";
offset: 36 0;
}
text {
font: "Fira Sans Medium 19px";
glyphs: "e";
offset: 48 0;
}
text {
font: "Fira Sans Medium 18.5px";
glyphs: "e";
offset: 60 0;
}
text {
font: "Fira Sans Medium 18px";
glyphs: "e";
offset: 72 0;
}
text {
font: "Fira Sans Medium 17.5px";
glyphs: "e";
offset: 84 0;
}
text {
font: "Fira Sans Medium 17px";
glyphs: "e";
offset: 96 0;
}
text {
font: "Fira Sans Medium 16.5px";
glyphs: "e";
offset: 108 0;
}
text {
font: "Fira Sans Medium 16px";
glyphs: "e";
offset: 120 0;
}
}
}

View File

@@ -52,31 +52,3 @@ test('transition', transition,
suite: 'css'
)
if false and get_option ('profiler')
adwaita_env = csstest_env
adwaita_env.set('GTK_THEME', 'Adwaita')
test('performance-adwaita', test_performance,
args: [
'--mark', 'css validation',
'--name', 'performance-adwaita',
'--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory'),
],
env: adwaita_env,
suite: [ 'css' ],
)
empty_env = csstest_env
empty_env.set('GTK_THEME', 'Empty')
test('performance-empty', test_performance,
args: [
'--mark', 'css validation',
'--name', 'performance-empty',
'--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory'),
],
env: empty_env,
suite: [ 'css' ],
)
endif

View File

@@ -277,27 +277,3 @@ make_pot = find_program ('make-pot', dirs: meson.project_source_root())
test('potfiles', make_pot,
workdir: meson.project_source_root(),
suite: ['gtk', 'translations' ])
if false and get_option ('profiler')
performance_env = test_env
performance_env.set('GTK_THEME', 'Empty')
test('performance-layout', test_performance,
args: [
'--mark', 'size allocation',
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory'),
],
env: performance_env,
suite: [ 'gtk' ],
)
test('performance-snapshot', test_performance,
args: [
'--mark', 'widget snapshot',
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory'),
],
env: performance_env,
suite: [ 'gtk' ],
)
endif