From 12e31ab7e86021c33072558acb68a2701058ab16 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 Mar 2025 02:24:00 +0200 Subject: [PATCH 01/12] [test] Allow running test suite under wine Set exe_wrapper in the Windows cross files, which will cause unit tests to be run with wine. When we call the binary ourselves, e.g. in shape run-tests.py, we need to check for MESON_EXE_WRAPPER env var (which meson sets automatically if exe_wrapper is set) and use it. --- .ci/win32-cross-file.txt | 1 + .ci/win64-cross-file.txt | 1 + test/shape/run-tests.py | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.ci/win32-cross-file.txt b/.ci/win32-cross-file.txt index 0c9b99beb..22e060d80 100644 --- a/.ci/win32-cross-file.txt +++ b/.ci/win32-cross-file.txt @@ -19,3 +19,4 @@ objcopy = 'i686-w64-mingw32-objcopy' strip = 'i686-w64-mingw32-strip' windres = 'i686-w64-mingw32-windres' pkg-config = 'i686-w64-mingw32-pkg-config' +exe_wrapper = 'wine' diff --git a/.ci/win64-cross-file.txt b/.ci/win64-cross-file.txt index 84f0766de..a03c049a1 100644 --- a/.ci/win64-cross-file.txt +++ b/.ci/win64-cross-file.txt @@ -19,3 +19,4 @@ objcopy = 'x86_64-w64-mingw32-objcopy' strip = 'x86_64-w64-mingw32-strip' windres = 'x86_64-w64-mingw32-windres' pkg-config = 'x86_64-w64-mingw32-pkg-config' +exe_wrapper = 'wine' diff --git a/test/shape/run-tests.py b/test/shape/run-tests.py index db1ffe9eb..5046aeabc 100755 --- a/test/shape/run-tests.py +++ b/test/shape/run-tests.py @@ -16,11 +16,18 @@ hb_shape, args = args[0], args[1:] env = os.environ.copy() env["LC_ALL"] = "C" +EXE_WRAPPER = os.environ.get("MESON_EXE_WRAPPER") + def open_shape_batch_process(): global hb_shape, env + + cmd = [hb_shape, "--batch"] + if EXE_WRAPPER: + cmd = [EXE_WRAPPER] + cmd + process = subprocess.Popen( - [hb_shape, "--batch"], + cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stdout, @@ -79,8 +86,12 @@ def all_whats(what): for what in ["shaper", "face-loader", "font-funcs"]: subcommand = "--list-" + plural(what) + cmd = [hb_shape, subcommand] + if EXE_WRAPPER: + cmd = [EXE_WRAPPER] + cmd + what_process = subprocess.Popen( - [hb_shape, subcommand], + cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stdout, From ca1498126294e4b2c94300c712be4c3ef9c54d1f Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 Mar 2025 02:31:28 +0200 Subject: [PATCH 02/12] [ci] Install wine on Windows cross-compile jobs --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a2dc098ae..f104cfada 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,7 +132,7 @@ jobs: executor: win32-executor steps: - checkout - - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-i686 zip + - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-i686 zip wine - run: | python3 -m venv venv source venv/bin/activate @@ -158,7 +158,7 @@ jobs: executor: win64-executor steps: - checkout - - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip + - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip wine wine64 - run: | python3 -m venv venv source venv/bin/activate From a189b0f77279726ef767ec486f500506770f124f Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 Mar 2025 03:02:19 +0200 Subject: [PATCH 03/12] Revert "[ci] Install wine on Windows cross-compile jobs" This reverts commit ca1498126294e4b2c94300c712be4c3ef9c54d1f. --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f104cfada..a2dc098ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,7 +132,7 @@ jobs: executor: win32-executor steps: - checkout - - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-i686 zip wine + - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-i686 zip - run: | python3 -m venv venv source venv/bin/activate @@ -158,7 +158,7 @@ jobs: executor: win64-executor steps: - checkout - - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip wine wine64 + - run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip - run: | python3 -m venv venv source venv/bin/activate From e3dc86bb0f6ac350fb0bbfa6dcd5e9106d036c1b Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 Mar 2025 03:02:56 +0200 Subject: [PATCH 04/12] =?UTF-8?q?[ci]=20Don=E2=80=99t=20set=20exe=5Fwrappe?= =?UTF-8?q?r=20in=20the=20cross=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complicates the build setup. Keep it commented in case one wants to enable it locally. --- .ci/win32-cross-file.txt | 2 +- .ci/win64-cross-file.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/win32-cross-file.txt b/.ci/win32-cross-file.txt index 22e060d80..cefb24d29 100644 --- a/.ci/win32-cross-file.txt +++ b/.ci/win32-cross-file.txt @@ -19,4 +19,4 @@ objcopy = 'i686-w64-mingw32-objcopy' strip = 'i686-w64-mingw32-strip' windres = 'i686-w64-mingw32-windres' pkg-config = 'i686-w64-mingw32-pkg-config' -exe_wrapper = 'wine' +#exe_wrapper = 'wine' diff --git a/.ci/win64-cross-file.txt b/.ci/win64-cross-file.txt index a03c049a1..acda4b622 100644 --- a/.ci/win64-cross-file.txt +++ b/.ci/win64-cross-file.txt @@ -19,4 +19,4 @@ objcopy = 'x86_64-w64-mingw32-objcopy' strip = 'x86_64-w64-mingw32-strip' windres = 'x86_64-w64-mingw32-windres' pkg-config = 'x86_64-w64-mingw32-pkg-config' -exe_wrapper = 'wine' +#exe_wrapper = 'wine' From cc0451c949518a8cf8490fdff39b462a3b396dc8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 Mar 2025 19:58:37 -0600 Subject: [PATCH 05/12] [cff2] Malloc-free draw of var blends --- src/hb-cff2-interp-cs.hh | 66 +++++++++++++++++++++++++++++++--------- src/hb-ot-cff2-table.hh | 9 ++++++ 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/src/hb-cff2-interp-cs.hh b/src/hb-cff2-interp-cs.hh index 06fbb72c6..790aae345 100644 --- a/src/hb-cff2-interp-cs.hh +++ b/src/hb-cff2-interp-cs.hh @@ -71,7 +71,8 @@ struct cff2_cs_interp_env_t : cs_interp_env_t template cff2_cs_interp_env_t (const hb_ubytes_t &str, ACC &acc, unsigned int fd, const int *coords_=nullptr, unsigned int num_coords_=0) - : SUPER (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs) + : SUPER (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs), + cached_scalars_vector (&acc.cached_scalars_vector) { coords = coords_; num_coords = num_coords_; @@ -80,9 +81,39 @@ struct cff2_cs_interp_env_t : cs_interp_env_t set_ivs (acc.privateDicts[fd].ivs); } - void fini () + ~cff2_cs_interp_env_t () { - SUPER::fini (); + release_scalars_vector (scalars); + } + + hb_vector_t *acquire_scalars_vector () const + { + hb_vector_t *scalars = cached_scalars_vector->get_acquire (); + + if (!scalars || !cached_scalars_vector->cmpexch (scalars, nullptr)) + { + scalars = (hb_vector_t *) hb_calloc (1, sizeof (hb_vector_t)); + if (unlikely (!scalars)) + return nullptr; + scalars->init (); + } + + return scalars; + } + + void release_scalars_vector (hb_vector_t *scalars) const + { + if (!scalars) + return; + + scalars->clear (); + + if (!cached_scalars_vector->cmpexch (nullptr, scalars)) + { + scalars->fini (); + hb_free (scalars); + } + scalars = nullptr; } op_code_t fetch_op () @@ -111,14 +142,20 @@ struct cff2_cs_interp_env_t : cs_interp_env_t { if (!seen_blend) { - region_count = varStore->varStore.get_region_index_count (get_ivs ()); - if (do_blend) + scalars = acquire_scalars_vector (); + if (unlikely (!scalars)) + SUPER::set_error (); + else { - if (unlikely (!scalars.resize_exact (region_count))) - SUPER::set_error (); - else - varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords, - &scalars[0], region_count); + region_count = varStore->varStore.get_region_index_count (get_ivs ()); + if (do_blend) + { + if (unlikely (!scalars->resize_exact (region_count))) + SUPER::set_error (); + else + varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords, + &(*scalars)[0], region_count); + } } seen_blend = true; } @@ -149,11 +186,11 @@ struct cff2_cs_interp_env_t : cs_interp_env_t double v = 0; if (do_blend) { - if (likely (scalars.length == deltas.length)) + if (likely (scalars && scalars->length == deltas.length)) { - unsigned count = scalars.length; + unsigned count = scalars->length; for (unsigned i = 0; i < count; i++) - v += (double) scalars.arrayZ[i] * deltas.arrayZ[i].to_real (); + v += (double) scalars->arrayZ[i] * deltas.arrayZ[i].to_real (); } } return v; @@ -167,7 +204,8 @@ struct cff2_cs_interp_env_t : cs_interp_env_t const CFF2ItemVariationStore *varStore; unsigned int region_count; unsigned int ivs; - hb_vector_t scalars; + hb_vector_t *scalars = nullptr; + hb_atomic_t *> *cached_scalars_vector = nullptr; bool do_blend; bool seen_vsindex_ = false; bool seen_blend = false; diff --git a/src/hb-ot-cff2-table.hh b/src/hb-ot-cff2-table.hh index f3b80a630..536c918f0 100644 --- a/src/hb-ot-cff2-table.hh +++ b/src/hb-ot-cff2-table.hh @@ -482,6 +482,13 @@ struct cff2 privateDicts.fini (); hb_blob_destroy (blob); blob = nullptr; + + auto *scalars = cached_scalars_vector.get_acquire (); + if (scalars && cached_scalars_vector.cmpexch (scalars, nullptr)) + { + scalars->fini (); + hb_free (scalars); + } } hb_vector_t *create_glyph_to_sid_map () const @@ -509,6 +516,8 @@ struct cff2 hb_vector_t fontDicts; hb_vector_t privateDicts; + mutable hb_atomic_t *> cached_scalars_vector; + unsigned int num_glyphs = 0; }; From 6a82561f00b9244f71bfa60261474da379080aaa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 Mar 2025 23:21:28 -0600 Subject: [PATCH 06/12] [hb-draw-all] Error handling --- test/draw/hb-draw-all.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/draw/hb-draw-all.c b/test/draw/hb-draw-all.c index 867083704..7284eeb8d 100644 --- a/test/draw/hb-draw-all.c +++ b/test/draw/hb-draw-all.c @@ -12,6 +12,13 @@ int main (int argc, char **argv) } hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0); + + if (!face) + { + fprintf (stderr, "Failed to create face\n"); + return 1; + } + hb_font_t *font = hb_font_create (face); if (argc > 2) From a551736532860120c17ec988878d1ee178fcdc24 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 Mar 2025 23:23:58 -0600 Subject: [PATCH 07/12] [test] Add hb-paint-all --- test/meson.build | 1 + test/paint/hb-paint-all.c | 45 +++++++++++++++++++++++++++++++++++++++ test/paint/meson.build | 6 ++++++ 3 files changed, 52 insertions(+) create mode 100644 test/paint/hb-paint-all.c create mode 100644 test/paint/meson.build diff --git a/test/meson.build b/test/meson.build index e7286932e..d2e3f5b29 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,3 +4,4 @@ subdir('threads') subdir('shape') subdir('api') subdir('draw') +subdir('paint') diff --git a/test/paint/hb-paint-all.c b/test/paint/hb-paint-all.c new file mode 100644 index 000000000..a29e2ef89 --- /dev/null +++ b/test/paint/hb-paint-all.c @@ -0,0 +1,45 @@ +#include + +#include +#include + +int main (int argc, char **argv) +{ + if (argc < 3) + { + fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]); + return 1; + } + + hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0); + + if (!face) + { + fprintf (stderr, "Failed to create face\n"); + return 1; + } + + hb_font_t *font = hb_font_create (face); + + if (argc > 2) + hb_font_set_funcs_using (font, argv[2]); + + if (argc > 3) + { + hb_variation_t variations[] = { + { HB_TAG ('w', 'g', 'h', 't'), atoi (argv[3]) }, + }; + hb_font_set_variations (font, variations, 1); + } + + hb_paint_funcs_t *funcs = hb_paint_funcs_create (); + + unsigned glyph_count = hb_face_get_glyph_count (face); + for (unsigned gid = 0; gid < glyph_count; gid++) + hb_font_paint_glyph (font, gid, funcs, NULL, 0, 0); + + hb_paint_funcs_destroy (funcs); + hb_font_destroy (font); + hb_face_destroy (face); + return 0; +} diff --git a/test/paint/meson.build b/test/paint/meson.build new file mode 100644 index 000000000..c0e3f76ea --- /dev/null +++ b/test/paint/meson.build @@ -0,0 +1,6 @@ +hb_paint_all = executable('hb-paint-all', ['hb-paint-all.c'], + cpp_args: cpp_args, + include_directories: [incconfig, incsrc], + link_with: [libharfbuzz], +) +meson.override_find_program('hb-paint-all', hb_paint_all) From c867bc976aaab486a0d2dc59a93aad98f1f50417 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Mar 2025 00:59:35 -0600 Subject: [PATCH 08/12] [test] Minor, adjust usage --- test/draw/hb-draw-all.c | 2 +- test/paint/hb-paint-all.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/draw/hb-draw-all.c b/test/draw/hb-draw-all.c index 7284eeb8d..8874f1921 100644 --- a/test/draw/hb-draw-all.c +++ b/test/draw/hb-draw-all.c @@ -5,7 +5,7 @@ int main (int argc, char **argv) { - if (argc < 3) + if (argc < 2) { fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]); return 1; diff --git a/test/paint/hb-paint-all.c b/test/paint/hb-paint-all.c index a29e2ef89..4f04fcec3 100644 --- a/test/paint/hb-paint-all.c +++ b/test/paint/hb-paint-all.c @@ -5,7 +5,7 @@ int main (int argc, char **argv) { - if (argc < 3) + if (argc < 2) { fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]); return 1; From 852f66a4187f59f169d0de2ea98725d1d78e8da8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Mar 2025 13:57:31 -0600 Subject: [PATCH 09/12] [fontations] Implement fill-glyph Gets rid of one Vec. Supersedes: https://github.com/harfbuzz/harfbuzz/pull/5180 https://github.com/harfbuzz/harfbuzz/pull/5184 --- src/fontations/lib.rs | 44 ++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index c9ba7d705..5b6e4b10f 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -199,7 +199,7 @@ extern "C" fn _hb_fontations_get_nominal_glyphs( let Some(glyph) = char_map.map(unicode) else { return i; }; - let glyph_id = u32::from(glyph) as hb_codepoint_t; + let glyph_id = glyph.to_u32() as hb_codepoint_t; *struct_at_offset_mut(first_glyph, i, glyph_stride) = glyph_id; } @@ -218,7 +218,7 @@ extern "C" fn _hb_fontations_get_variation_glyph( match char_map.map_variant(unicode, variation_selector) { Some(Variant(glyph_id)) => { - unsafe { *glyph = u32::from(glyph_id) as hb_codepoint_t }; + unsafe { *glyph = glyph_id.to_u32() as hb_codepoint_t }; true as hb_bool_t } _ => false as hb_bool_t, @@ -416,7 +416,6 @@ struct HbColorPainter<'a> { color_records: &'a [ColorRecord], foreground: hb_color_t, composite_mode: Vec, - clip_transform_stack: Vec, } impl HbColorPainter<'_> { @@ -544,22 +543,41 @@ impl ColorPainter for HbColorPainter<'_> { hb_paint_pop_transform(self.paint_funcs, self.paint_data); } } - fn push_clip_glyph(&mut self, glyph: GlyphId) { - let gid = u32::from(glyph); - self.clip_transform_stack.push(true); + fn fill_glyph( + &mut self, + glyph_id: GlyphId, + brush_transform: Option, + brush: Brush<'_>, + ) { unsafe { hb_paint_push_inverse_font_transform(self.paint_funcs, self.paint_data, self.font); + } + self.push_clip_glyph(glyph_id); + unsafe { + hb_paint_push_font_transform(self.paint_funcs, self.paint_data, self.font); + } + if let Some(wrap_in_transform) = brush_transform { + self.push_transform(wrap_in_transform); + self.fill(brush); + self.pop_transform(); + } else { + self.fill(brush); + } + self.pop_transform(); + self.pop_clip(); + self.pop_transform(); + } + fn push_clip_glyph(&mut self, glyph_id: GlyphId) { + unsafe { hb_paint_push_clip_glyph( self.paint_funcs, self.paint_data, - gid as hb_codepoint_t, + glyph_id.to_u32() as hb_codepoint_t, self.font, ); - hb_paint_push_font_transform(self.paint_funcs, self.paint_data, self.font); } } fn push_clip_box(&mut self, bbox: BoundingBox) { - self.clip_transform_stack.push(false); unsafe { hb_paint_push_clip_rectangle( self.paint_funcs, @@ -572,16 +590,9 @@ impl ColorPainter for HbColorPainter<'_> { } } fn pop_clip(&mut self) { - let pop_transforms = self.clip_transform_stack.pop().unwrap_or(false); - if pop_transforms { - self.pop_transform(); - } unsafe { hb_paint_pop_clip(self.paint_funcs, self.paint_data); } - if pop_transforms { - self.pop_transform(); - } } fn fill(&mut self, brush: Brush) { match brush { @@ -767,7 +778,6 @@ extern "C" fn _hb_fontations_paint_glyph( color_records, foreground, composite_mode: Vec::new(), - clip_transform_stack: Vec::new(), }; unsafe { hb_paint_push_font_transform(paint_funcs, paint_data, font); From 9fa31d1ed2927894544a537e7715bf6caf8fd82d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Mar 2025 14:44:03 -0600 Subject: [PATCH 10/12] [fontations] Enable lto in dev builds as well Otherwise our check-symbols test will fail. --- src/fontations/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fontations/Cargo.toml b/src/fontations/Cargo.toml index c02f16045..a363c5bf4 100644 --- a/src/fontations/Cargo.toml +++ b/src/fontations/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["staticlib"] [profile.release] strip = true -lto = true +lto = "fat" panic = "abort" overflow-checks = false codegen-units = 1 @@ -23,3 +23,6 @@ inherits = "release" debug = true codegen-units = 16 strip = false + +[profile.dev] +lto = "fat" From cfb962d73c70a73735b95e2b61d5163a4b6beea0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Mar 2025 14:53:34 -0600 Subject: [PATCH 11/12] [fontations] Use the proposed pop_layer_with_mode Reduces the last Vec use. https://github.com/googlefonts/fontations/pull/1419 --- src/fontations/Cargo.lock | 8 ++++---- src/fontations/Cargo.toml | 2 +- src/fontations/lib.rs | 13 +++---------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/fontations/Cargo.lock b/src/fontations/Cargo.lock index c8f163b63..b4cbe2d6e 100644 --- a/src/fontations/Cargo.lock +++ b/src/fontations/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "read-fonts" -version = "0.27.4" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1cb3d8f1eff7ebef84ca77c0ef99e84e40459132a71bd678e96c6b7f0e6c1e" +checksum = "f14974c88fb4fd0a7203719f98020209248c9dbebaf9d10d860337797a905097" dependencies = [ "bytemuck", "font-types", @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "skrifa" -version = "0.29.1" +version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d58313d717b05488e8c8bae9b4cb34191aa6168d07430e17a2c0a12695fe735" +checksum = "7c0ca53de9bb9bee1720c727606275148463cd938eb6bde249dcedeec4967747" dependencies = [ "bytemuck", "read-fonts", diff --git a/src/fontations/Cargo.toml b/src/fontations/Cargo.toml index a363c5bf4..e239a26c3 100644 --- a/src/fontations/Cargo.toml +++ b/src/fontations/Cargo.toml @@ -4,7 +4,7 @@ edition = "2021" [dependencies] read-fonts = "0.27" -skrifa = "0.29.1" +skrifa = "0.29.2" [lib] name = "harfbuzz_fontations" diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index 5b6e4b10f..250f81b79 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -415,7 +415,6 @@ struct HbColorPainter<'a> { paint_data: *mut c_void, color_records: &'a [ColorRecord], foreground: hb_color_t, - composite_mode: Vec, } impl HbColorPainter<'_> { @@ -706,18 +705,13 @@ impl ColorPainter for HbColorPainter<'_> { } } } - fn push_layer(&mut self, mode: CompositeMode) { - self.composite_mode.push(mode); + fn push_layer(&mut self, _mode: CompositeMode) { unsafe { hb_paint_push_group(self.paint_funcs, self.paint_data); } } - fn pop_layer(&mut self) { - let mode = self.composite_mode.pop(); - if mode.is_none() { - return; - } - let mode = mode.unwrap() as hb_paint_composite_mode_t; // They are the same + fn pop_layer_with_mode(&mut self, mode: CompositeMode) { + let mode = mode as hb_paint_composite_mode_t; // They are the same unsafe { hb_paint_pop_group(self.paint_funcs, self.paint_data, mode); } @@ -777,7 +771,6 @@ extern "C" fn _hb_fontations_paint_glyph( paint_data, color_records, foreground, - composite_mode: Vec::new(), }; unsafe { hb_paint_push_font_transform(paint_funcs, paint_data, font); From 0eeb6ccb42dc1212e5fb17102b4eb36f236d4eff Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 21 Mar 2025 17:36:43 -0600 Subject: [PATCH 12/12] [perf] Bikeshedding --- {test/draw => perf}/hb-draw-all.c | 0 {test/paint => perf}/hb-paint-all.c | 0 perf/meson.build | 14 ++++++++++++++ test/draw/meson.build | 6 ------ test/meson.build | 2 -- test/paint/meson.build | 6 ------ 6 files changed, 14 insertions(+), 14 deletions(-) rename {test/draw => perf}/hb-draw-all.c (100%) rename {test/paint => perf}/hb-paint-all.c (100%) delete mode 100644 test/draw/meson.build delete mode 100644 test/paint/meson.build diff --git a/test/draw/hb-draw-all.c b/perf/hb-draw-all.c similarity index 100% rename from test/draw/hb-draw-all.c rename to perf/hb-draw-all.c diff --git a/test/paint/hb-paint-all.c b/perf/hb-paint-all.c similarity index 100% rename from test/paint/hb-paint-all.c rename to perf/hb-paint-all.c diff --git a/perf/meson.build b/perf/meson.build index 2588fe50a..605b8e9a4 100644 --- a/perf/meson.build +++ b/perf/meson.build @@ -38,3 +38,17 @@ foreach source : benchmarks_subset install: false, ), workdir: meson.current_source_dir() / '..', timeout: 100) endforeach + +hb_draw_all = executable('hb-draw-all', ['hb-draw-all.c'], + cpp_args: cpp_args, + include_directories: [incconfig, incsrc], + link_with: [libharfbuzz], +) +meson.override_find_program('hb-draw-all', hb_draw_all) + +hb_paint_all = executable('hb-paint-all', ['hb-paint-all.c'], + cpp_args: cpp_args, + include_directories: [incconfig, incsrc], + link_with: [libharfbuzz], +) +meson.override_find_program('hb-paint-all', hb_paint_all) diff --git a/test/draw/meson.build b/test/draw/meson.build deleted file mode 100644 index 789a2753e..000000000 --- a/test/draw/meson.build +++ /dev/null @@ -1,6 +0,0 @@ -hb_draw_all = executable('hb-draw-all', ['hb-draw-all.c'], - cpp_args: cpp_args, - include_directories: [incconfig, incsrc], - link_with: [libharfbuzz], -) -meson.override_find_program('hb-draw-all', hb_draw_all) diff --git a/test/meson.build b/test/meson.build index d2e3f5b29..c9a3ec715 100644 --- a/test/meson.build +++ b/test/meson.build @@ -3,5 +3,3 @@ subdir('fuzzing') subdir('threads') subdir('shape') subdir('api') -subdir('draw') -subdir('paint') diff --git a/test/paint/meson.build b/test/paint/meson.build deleted file mode 100644 index c0e3f76ea..000000000 --- a/test/paint/meson.build +++ /dev/null @@ -1,6 +0,0 @@ -hb_paint_all = executable('hb-paint-all', ['hb-paint-all.c'], - cpp_args: cpp_args, - include_directories: [incconfig, incsrc], - link_with: [libharfbuzz], -) -meson.override_find_program('hb-paint-all', hb_paint_all)