From ca44c38c5298e9ffc9b0b843c3fd5df63c9747a7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Jun 2023 14:41:21 -0600 Subject: [PATCH] Add HB_ALWAYS_INLINE With MSVC implementation as well. --- src/OT/glyf/glyf.hh | 2 +- src/OT/glyf/path-builder.hh | 2 +- src/hb-draw.hh | 20 ++++++++++---------- src/hb.hh | 6 ++++++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index f1fa69b7f..1d546acd6 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -297,7 +297,7 @@ struct glyf_accelerator_t if (extents) bounds = contour_bounds_t (); } - __attribute__((always_inline)) + HB_ALWAYS_INLINE void consume_point (const contour_point_t &point) { bounds.add (point); } void points_end () { bounds.get_extents (font, extents, scaled); } diff --git a/src/OT/glyf/path-builder.hh b/src/OT/glyf/path-builder.hh index 65790f948..f50301702 100644 --- a/src/OT/glyf/path-builder.hh +++ b/src/OT/glyf/path-builder.hh @@ -37,7 +37,7 @@ struct path_builder_t * https://stackoverflow.com/a/20772557 * * Cubic support added. */ - __attribute__((always_inline)) + HB_ALWAYS_INLINE void consume_point (const contour_point_t &point) { bool is_on_curve = point.flag & glyf_impl::SimpleGlyph::FLAG_ON_CURVE; diff --git a/src/hb-draw.hh b/src/hb-draw.hh index 13bc2e977..25dee1261 100644 --- a/src/hb-draw.hh +++ b/src/hb-draw.hh @@ -94,7 +94,7 @@ struct hb_draw_funcs_t void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE move_to (void *draw_data, hb_draw_state_t &st, float to_x, float to_y) { @@ -104,7 +104,7 @@ struct hb_draw_funcs_t } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE line_to (void *draw_data, hb_draw_state_t &st, float to_x, float to_y) { @@ -115,7 +115,7 @@ struct hb_draw_funcs_t } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE quadratic_to (void *draw_data, hb_draw_state_t &st, float control_x, float control_y, float to_x, float to_y) @@ -127,7 +127,7 @@ struct hb_draw_funcs_t } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE cubic_to (void *draw_data, hb_draw_state_t &st, float control1_x, float control1_y, float control2_x, float control2_y, @@ -140,7 +140,7 @@ struct hb_draw_funcs_t } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE close_path (void *draw_data, hb_draw_state_t &st) { if (likely (st.path_open)) @@ -175,7 +175,7 @@ struct hb_draw_session_t ~hb_draw_session_t () { close_path (); } - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE void move_to (float to_x, float to_y) { if (likely (not_slanted)) @@ -185,7 +185,7 @@ struct hb_draw_session_t funcs->move_to (draw_data, st, to_x + to_y * slant, to_y); } - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE void line_to (float to_x, float to_y) { if (likely (not_slanted)) @@ -196,7 +196,7 @@ struct hb_draw_session_t to_x + to_y * slant, to_y); } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE quadratic_to (float control_x, float control_y, float to_x, float to_y) { @@ -210,7 +210,7 @@ struct hb_draw_session_t to_x + to_y * slant, to_y); } void - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE cubic_to (float control1_x, float control1_y, float control2_x, float control2_y, float to_x, float to_y) @@ -226,7 +226,7 @@ struct hb_draw_session_t control2_x + control2_y * slant, control2_y, to_x + to_y * slant, to_y); } - __attribute__((__always_inline__)) + HB_ALWAYS_INLINE void close_path () { funcs->close_path (draw_data, st); diff --git a/src/hb.hh b/src/hb.hh index 205f8cf19..d88e37c60 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -315,6 +315,12 @@ extern "C" void hb_free_impl(void *ptr); #define __restrict #endif +#if defined(_MSC_VER) +#define HB_ALWAYS_INLINE __forceinline +#else +#define HB_ALWAYS_INLINE __attribute__((always_inline)) inline +#endif + /* * Borrowed from https://bugzilla.mozilla.org/show_bug.cgi?id=1215411 * HB_FALLTHROUGH is an annotation to suppress compiler warnings about switch