gsk: Avoid a crash with negative scales

Don't crash when both scale_x and scale_y are -1.

A test is included.
This commit is contained in:
Matthias Clasen 2022-11-19 22:24:20 -05:00
parent ab530b9e5a
commit b441c684ab
4 changed files with 10 additions and 1 deletions

View File

@ -2938,7 +2938,7 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
const PangoFont *font = gsk_text_node_get_font (node);
const PangoGlyphInfo *glyphs = gsk_text_node_get_glyphs (node, NULL);
const graphene_point_t *offset = gsk_text_node_get_offset (node);
float text_scale = MAX (job->scale_x, job->scale_y); /* TODO: Fix for uneven scales? */
float text_scale = MAX (fabs (job->scale_x), fabs (job->scale_y)); /* TODO: Fix for uneven scales? */
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
float x = offset->x + job->offset_x;
float y = offset->y + job->offset_y;

View File

@ -0,0 +1,8 @@
transform {
transform: scale(-1, -1) translate(-100, -100);
child: text {
font:"Cantarell 20";
glyphs:"ABC";
offset: 0 0;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

View File

@ -85,6 +85,7 @@ compare_render_tests = [
'transform-in-transform',
'transform-in-transform-in-transform',
'unaligned-offscreen',
'upside-down-label-3d', # not really 3d, but cairo fails it
'rounded-clip-in-clip-3d', # not really 3d, but cairo fails it
]