From 07a15ec7945ecc6cae61237359438bbc39a6526c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 Feb 2025 23:18:14 -0700 Subject: [PATCH] [hvgl] Micro-optimize transformations --- src/hb-aat-var-hvgl-table.cc | 2 +- src/hb-geometry.hh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hb-aat-var-hvgl-table.cc b/src/hb-aat-var-hvgl-table.cc index 61245a1b3..805e1151c 100644 --- a/src/hb-aat-var-hvgl-table.cc +++ b/src/hb-aat-var-hvgl-table.cc @@ -328,9 +328,9 @@ PartShape::get_path_at (const struct hvgl &hvgl, double x1 = segment[SEGMENT_POINT_OFF_CURVE_X]; double y1 = segment[SEGMENT_POINT_OFF_CURVE_Y]; - transform.transform_point (x1, y1); double x2 = next_segment[SEGMENT_POINT_ON_CURVE_X]; double y2 = next_segment[SEGMENT_POINT_ON_CURVE_Y]; + transform.transform_point (x1, y1); transform.transform_point (x2, y2); draw_session.quadratic_to ((float) x1, (float) y1, (float) x2, (float) y2); } diff --git a/src/hb-geometry.hh b/src/hb-geometry.hh index 1b32d131a..cc774bab1 100644 --- a/src/hb-geometry.hh +++ b/src/hb-geometry.hh @@ -134,6 +134,7 @@ struct hb_transform_t }; } + HB_ALWAYS_INLINE void transform_distance (Float &dx, Float &dy) const { Float new_x = xx * dx + xy * dy; @@ -142,11 +143,13 @@ struct hb_transform_t dy = new_y; } + HB_ALWAYS_INLINE void transform_point (Float &x, Float &y) const { - transform_distance (x, y); - x += x0; - y += y0; + Float new_x = x0 + xx * x + xy * y; + Float new_y = y0 + yx * x + yy * y; + x = new_x; + y = new_y; } void transform_extents (hb_extents_t &extents) const