From 4ede146739a1054ff20f5223dc6babf8a8ee5daa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 23 Feb 2025 14:39:31 -0700 Subject: [PATCH] [hvgl/transforms] Break up the four-iterator loop again --- src/hb-aat-var-hvgl-table.cc | 73 ++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/src/hb-aat-var-hvgl-table.cc b/src/hb-aat-var-hvgl-table.cc index 3849e8eaf..4acdd600c 100644 --- a/src/hb-aat-var-hvgl-table.cc +++ b/src/hb-aat-var-hvgl-table.cc @@ -408,13 +408,10 @@ PartComposite::apply_to_transforms (hb_array_t> transform auto extremum_rotation_indices = extremumRotationIndex.arrayZ; auto extremum_rotation_deltas = extremumRotationDelta.arrayZ; unsigned extremum_rotation_count = sparseExtremumRotationCount; + while (true) { unsigned row = transforms.length; - if (master_translation_count) - row = hb_min (row, *master_translation_indices); - if (master_rotation_count) - row = hb_min (row, *master_rotation_indices); if (extremum_translation_count) row = hb_min (row, extremum_translation_indices->row); if (extremum_rotation_count) @@ -425,31 +422,6 @@ PartComposite::apply_to_transforms (hb_array_t> transform hb_transform_t transform; bool is_translate_only = true; - if (master_rotation_count && - *master_rotation_indices == row) - { - // Since transform is identity by default, we can just replace it with - // rotation. This saves a multiplication. - if (true) - transform = hb_transform_t::rotation ((double) *master_rotation_deltas); - else - transform.rotate ((double) *master_rotation_deltas, true); - is_translate_only = false; - master_rotation_count--; - master_rotation_indices++; - master_rotation_deltas++; - } - if (master_translation_count && - *master_translation_indices == row) - { - transform.translate ((double) master_translation_deltas->x, - (double) master_translation_deltas->y, - true); - master_translation_count--; - master_translation_indices++; - master_translation_deltas++; - } - while (true) { bool has_row_translation = extremum_translation_count && @@ -512,6 +484,49 @@ PartComposite::apply_to_transforms (hb_array_t> transform } } + if (is_translate_only) + transforms[row].translate (transform.x0, transform.y0, true); + else + transforms[row].transform (transform, true); + } + while (true) + { + unsigned row = transforms.length; + if (master_translation_count) + row = hb_min (row, *master_translation_indices); + if (master_rotation_count) + row = hb_min (row, *master_rotation_indices); + if (row == transforms.length) + break; + + hb_transform_t transform; + bool is_translate_only = true; + + if (master_rotation_count && + *master_rotation_indices == row) + { + // Since transform is identity by default, we can just replace it with + // rotation. This saves a multiplication. + if (true) + transform = hb_transform_t::rotation ((double) *master_rotation_deltas); + else + transform.rotate ((double) *master_rotation_deltas, true); + is_translate_only = false; + master_rotation_count--; + master_rotation_indices++; + master_rotation_deltas++; + } + if (master_translation_count && + *master_translation_indices == row) + { + transform.translate ((double) master_translation_deltas->x, + (double) master_translation_deltas->y, + true); + master_translation_count--; + master_translation_indices++; + master_translation_deltas++; + } + if (is_translate_only) transforms[row].translate (transform.x0, transform.y0, true); else