From 754d364efd479b7982d5881454a300ef48f48eab Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jan 2024 07:56:11 -0500 Subject: [PATCH 1/4] gsk: Allow custom fonts in tests The commit adds a custom fontconfig configuration in testsuite/gsk/fonts/fonts.conf and sets the FONTCONFIG_FILE environment variable for the gsk compare tests to point at it. To use a custom font in tests, just drop it into the testsuite/gsk/fonts/ directory. The font configuration includes the system configuration, so existing tests should not be affected. --- testsuite/gsk/fonts/fonts.conf | 7 +++++++ testsuite/gsk/meson.build | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 testsuite/gsk/fonts/fonts.conf diff --git a/testsuite/gsk/fonts/fonts.conf b/testsuite/gsk/fonts/fonts.conf new file mode 100644 index 0000000000..26d218edd9 --- /dev/null +++ b/testsuite/gsk/fonts/fonts.conf @@ -0,0 +1,7 @@ + + + + /tmp/cache + . + /etc/fonts/fonts.conf + diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 8891379cdb..398962ca7f 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -196,7 +196,8 @@ foreach renderer : renderers 'GSK_RENDERER=' + renderer_name, 'GTK_A11Y=test', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), - 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), + 'FONTCONFIG_FILE=@0@/fonts/fonts.conf'.format(meson.current_source_dir()) ] if ((not testname.contains(exclude_term)) and From 490a9f193d179ef56c3be74f898fe716d7a2b479 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 Jan 2024 20:51:22 -0500 Subject: [PATCH 2/4] gpu: Fix handling of mixed color text runs We need to decide per-glyph whether to use coloring or texture ops. --- gsk/gpu/gskgpunodeprocessor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 88465911a8..a0122b9989 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -3018,7 +3018,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self, glyph_offset = GRAPHENE_POINT_INIT (offset.x - glyph_offset.x * inv_scale + (float) glyphs[i].geometry.x_offset / PANGO_SCALE, offset.y - glyph_offset.y * inv_scale + (float) glyphs[i].geometry.y_offset / PANGO_SCALE); descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT); - if (gsk_text_node_has_color_glyphs (node)) + if (glyphs[i].attr.is_color) gsk_gpu_texture_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &glyph_offset, &glyph_bounds), self->desc, From a44ca6756a38a20b1013972ef955a07100aba79b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jan 2024 07:07:29 -0500 Subject: [PATCH 3/4] gpu: Use the right format for atlases The glyph atlas format needs to match the cairo memory format. NGL was getting this wrong, causing color glyphs to have their red and blue swapped. --- gsk/gpu/gskgldevice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gpu/gskgldevice.c b/gsk/gpu/gskgldevice.c index 4d7a4cc530..92567970c5 100644 --- a/gsk/gpu/gskgldevice.c +++ b/gsk/gpu/gskgldevice.c @@ -119,7 +119,7 @@ gsk_gl_device_create_atlas_image (GskGpuDevice *device, GskGLDevice *self = GSK_GL_DEVICE (device); return gsk_gl_image_new (self, - GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, + GDK_MEMORY_DEFAULT, GSK_GPU_IMAGE_RENDERABLE, width, height); From 781fe2d7faa2a710162fdf70c95b0aeee87658b1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jan 2024 07:56:52 -0500 Subject: [PATCH 4/4] gsk: Add a compare test for mixed color runs This tests the fixes in aa82190da659b5 and dcaa2c4ccb182c74cb40. The test uses a custom font named 'text-mixed-color' which contains six glyphs that are just boxes. Glyphs 1, 2, 3 are just plain glyphs, and glyphs 4, 5, 6 are color glyphs in red, green and blue. The glyphs are mapped to the characters A, B, C, D, E, F. The test is currently disabled for cairo, since it has some issues with transformed color glyphs. --- .../gsk/compare/text-mixed-color-nocairo.node | 7 + .../gsk/compare/text-mixed-color-nocairo.png | Bin 0 -> 176 bytes testsuite/gsk/fonts/text-mixed-color.ttf | Bin 0 -> 632 bytes testsuite/gsk/fonts/text-mixed-color.ttx | 189 ++++++++++++++++++ testsuite/gsk/meson.build | 1 + 5 files changed, 197 insertions(+) create mode 100644 testsuite/gsk/compare/text-mixed-color-nocairo.node create mode 100644 testsuite/gsk/compare/text-mixed-color-nocairo.png create mode 100644 testsuite/gsk/fonts/text-mixed-color.ttf create mode 100644 testsuite/gsk/fonts/text-mixed-color.ttx diff --git a/testsuite/gsk/compare/text-mixed-color-nocairo.node b/testsuite/gsk/compare/text-mixed-color-nocairo.node new file mode 100644 index 0000000000..db43dc1797 --- /dev/null +++ b/testsuite/gsk/compare/text-mixed-color-nocairo.node @@ -0,0 +1,7 @@ +transform { + transform: translate(0, 100); + child: text { + font: "text-mixed-color 20"; + glyphs: 1 20, 2 20, 3 20, 4 20 0 0 color, 5 20 0 0 color, 6 20 0 0 color; + } +} diff --git a/testsuite/gsk/compare/text-mixed-color-nocairo.png b/testsuite/gsk/compare/text-mixed-color-nocairo.png new file mode 100644 index 0000000000000000000000000000000000000000..adfcfdf6b183eea65279c9eb3aef81077e6f430f GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^B|t38!3HF&6Fs&9sd7&j$B>N1w--0^9x>oyFjVwT z`|tThSfzFK`9_l~Qk(MIme|htz54sxGjeA>*HxFq-K*Yo@1C*o_0#H~9Gi}DNGWIZ hEHEUEamfBR<6D-><8yUiuK+rM!PC{xWt~$(696GxLY@Es literal 0 HcmV?d00001 diff --git a/testsuite/gsk/fonts/text-mixed-color.ttf b/testsuite/gsk/fonts/text-mixed-color.ttf new file mode 100644 index 0000000000000000000000000000000000000000..b875433905c564ce3d19212988b41f940e111592 GIT binary patch literal 632 zcmc&xJxc>Y5Pf@hesXBkMy)OqB!z(pA{Ma-L9qxZ+6rvfs3HBT3yE&%79ZOJ5yOJSCu9M zXOnocmV_-FU=dIY#B)3G(RSzl^pW_OxZ8-r`tV z=ecC!W-UaFE^#b43DXt^&_mo$9PEWj)Ok3(WPP7_3eu~ZIBPB4y>1Pc-r-0Z@O;gd z#NJkK#CkBif>f5leKylp=PD8l^re2gQ9B1%}Xyy=$b%w|Wj9zLW~Q~e)!sXY4CZ3bvZX}gf@rcu36YsSre-pby2 g$lT90vM9co=+{fVt>!MRYt*+MAo-vw{3s3oPl-86l>h($ literal 0 HcmV?d00001 diff --git a/testsuite/gsk/fonts/text-mixed-color.ttx b/testsuite/gsk/fonts/text-mixed-color.ttx new file mode 100644 index 0000000000..deaf81f104 --- /dev/null +++ b/testsuite/gsk/fonts/text-mixed-color.ttx @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text-mixed-color + + + + + + + + + + + + + + + + + + diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 398962ca7f..a12e3a2922 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -129,6 +129,7 @@ compare_render_tests = [ 'stroke-clipped-nogl', 'stroke-opacity', 'stroke-with-3d-contents-nogl-nocairo', + 'text-mixed-color-nocairo', 'texture-coords', 'texture-scale-filters-nocairo', 'texture-scale-magnify-10000x',