Merge branch 'fix-mis-scaled-text' into 'main'

gsk: Fix mis-scaled text rendering

Closes #6504

See merge request GNOME/gtk!6977
This commit is contained in:
Matthias Clasen 2024-03-06 23:22:42 +00:00
commit e04ea3f311
4 changed files with 26 additions and 5 deletions

View File

@ -1611,7 +1611,7 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
inverse = gsk_transform_invert (gsk_transform_ref (clip_transform));
gsk_transform_transform_bounds (inverse, &old_clip.rect.bounds, &new_bounds);
gsk_transform_unref (inverse);
gsk_gpu_clip_init_contained (&self->clip, &new_bounds);
gsk_gpu_clip_init_empty (&self->clip, &new_bounds);
}
else if (!gsk_gpu_clip_transform (&self->clip, &old_clip, clip_transform, &child->bounds))
{
@ -1649,10 +1649,13 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
extract_scale_from_transform (self->modelview, &scale_x, &scale_y);
old_pixels = graphene_vec2_get_x (&old_scale) * graphene_vec2_get_y (&old_scale) *
old_clip.rect.bounds.size.width * old_clip.rect.bounds.size.height;
new_pixels = scale_x * scale_y * self->clip.rect.bounds.size.width * self->clip.rect.bounds.size.height;
if (new_pixels > 2 * old_pixels)
old_pixels = MAX (graphene_vec2_get_x (&old_scale) * old_clip.rect.bounds.size.width,
graphene_vec2_get_y (&old_scale) * old_clip.rect.bounds.size.height);
new_pixels = MAX (scale_x * self->clip.rect.bounds.size.width,
scale_y * self->clip.rect.bounds.size.height);
/* Check that our offscreen doesn't get too big. 1.5 ~ sqrt(2) */
if (new_pixels > 1.5 * old_pixels)
{
float forced_downscale = 2 * old_pixels / new_pixels;
scale_x *= forced_downscale;

View File

@ -0,0 +1,17 @@
color {
bounds: -10 -10 20 120;
color: rgb(255,255,255);
}
transform {
transform: rotate(45);
child: transform {
transform: rotate(45);
child: shadow {
shadows: rgb(0,0,0) 0 1;
child: color {
bounds: 0 0 100 1;
color: rgb(255,0,0);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

View File

@ -104,6 +104,7 @@ compare_render_tests = [
'mask-texture-color-alpha',
'mipmap-generation-later',
'nested-rounded-clips',
'offscreen-forced-downscale',
'offscreen-fractional-translate-nogl',
'offscreen-pixel-alignment-nogl-nocairo',
'offscreen-pixel-alignment2',