From b441c684abebad79c0f01147547c5c4b91c78ed3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 19 Nov 2022 22:24:20 -0500 Subject: [PATCH] gsk: Avoid a crash with negative scales Don't crash when both scale_x and scale_y are -1. A test is included. --- gsk/gl/gskglrenderjob.c | 2 +- testsuite/gsk/compare/upside-down-label-3d.node | 8 ++++++++ testsuite/gsk/compare/upside-down-label-3d.png | Bin 0 -> 806 bytes testsuite/gsk/meson.build | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 testsuite/gsk/compare/upside-down-label-3d.node create mode 100644 testsuite/gsk/compare/upside-down-label-3d.png diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c index e0c87cadf0..e30a1e1341 100644 --- a/gsk/gl/gskglrenderjob.c +++ b/gsk/gl/gskglrenderjob.c @@ -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; diff --git a/testsuite/gsk/compare/upside-down-label-3d.node b/testsuite/gsk/compare/upside-down-label-3d.node new file mode 100644 index 0000000000..af647250f3 --- /dev/null +++ b/testsuite/gsk/compare/upside-down-label-3d.node @@ -0,0 +1,8 @@ +transform { + transform: scale(-1, -1) translate(-100, -100); + child: text { + font:"Cantarell 20"; + glyphs:"ABC"; + offset: 0 0; + } +} diff --git a/testsuite/gsk/compare/upside-down-label-3d.png b/testsuite/gsk/compare/upside-down-label-3d.png new file mode 100644 index 0000000000000000000000000000000000000000..0cbbadb40d80ebec0a1347a1531b1960dfac6b98 GIT binary patch literal 806 zcmV+>1KIqEP)MZ}MYQHvxde&xKJ#m=&u&A#{c-BscrmiOMw?CkvK?anOx2bd4E0e68O zUEuy+BQ%uSVc9@DS()MuC!NJhA3%x8(IH;_i|;ovvb=XTk3t*?VA1!Xg)d zKh~TH*X@2-%?80h}+BSOCi6Zk9CVYbId;z?yJ z8@CG1Koz4QqWfT3I4%qJcy#knWxe1DNF!ajMsLE7} zx`97%bXAz^O|DG;HoD}wL!P_j*?}rX6(fi0Kl&=v7-6Ry^Q{!o}* zg#