From c86d1892ad32a6ef07ae0e67fe6e5deaaababc00 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 31 Dec 2022 10:46:46 -0700 Subject: [PATCH] [paint-extents] Move code around --- src/hb-paint-extents.cc | 32 +++++++------------------------- src/hb-paint-extents.hh | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/hb-paint-extents.cc b/src/hb-paint-extents.cc index f39ef3063..6db37b692 100644 --- a/src/hb-paint-extents.cc +++ b/src/hb-paint-extents.cc @@ -60,24 +60,6 @@ hb_paint_extents_pop_transform (hb_paint_funcs_t *funcs HB_UNUSED, c->pop_transform (); } -static void -add_point (hb_extents_t *extents, - float x, float y) -{ - if (unlikely (extents->xmax < extents->xmin)) - { - extents->xmin = extents->xmax = x; - extents->ymin = extents->ymax = y; - } - else - { - extents->xmin = hb_min (extents->xmin, x); - extents->ymin = hb_min (extents->ymin, y); - extents->xmax = hb_max (extents->xmax, x); - extents->ymax = hb_max (extents->ymax, y); - } -} - static void hb_draw_extents_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED, void *data, @@ -87,7 +69,7 @@ hb_draw_extents_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED, { hb_extents_t *extents = (hb_extents_t *) data; - add_point (extents, to_x, to_y); + extents->add_point (to_x, to_y); } static void @@ -99,7 +81,7 @@ hb_draw_extents_line_to (hb_draw_funcs_t *dfuncs HB_UNUSED, { hb_extents_t *extents = (hb_extents_t *) data; - add_point (extents, to_x, to_y); + extents->add_point (to_x, to_y); } static void @@ -112,8 +94,8 @@ hb_draw_extents_quadratic_to (hb_draw_funcs_t *dfuncs HB_UNUSED, { hb_extents_t *extents = (hb_extents_t *) data; - add_point (extents, control_x, control_y); - add_point (extents, to_x, to_y); + extents->add_point (control_x, control_y); + extents->add_point (to_x, to_y); } static void @@ -127,9 +109,9 @@ hb_draw_extents_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED, { hb_extents_t *extents = (hb_extents_t *) data; - add_point (extents, control1_x, control1_y); - add_point (extents, control2_x, control2_y); - add_point (extents, to_x, to_y); + extents->add_point (control1_x, control1_y); + extents->add_point (control2_x, control2_y); + extents->add_point (to_x, to_y); } static inline void free_static_draw_extents_funcs (); diff --git a/src/hb-paint-extents.hh b/src/hb-paint-extents.hh index 2751a10da..1f1d7c385 100644 --- a/src/hb-paint-extents.hh +++ b/src/hb-paint-extents.hh @@ -36,6 +36,7 @@ typedef struct hb_extents_t xmin (xmin), ymin (ymin), xmax (xmax), ymax (ymax) {} bool is_empty () const { return xmin >= xmax || ymin >= ymax; } + bool is_void () const { return xmin > xmax; } void union_ (const hb_extents_t &o) { @@ -53,6 +54,23 @@ typedef struct hb_extents_t ymax = hb_min (ymax, o.ymax); } + void + add_point (float x, float y) + { + if (unlikely (is_void ())) + { + xmin = xmax = x; + ymin = ymax = y; + } + else + { + xmin = hb_min (xmin, x); + ymin = hb_min (ymin, y); + xmax = hb_max (xmax, x); + ymax = hb_max (ymax, y); + } + } + float xmin = 0.f; float ymin = 0.f; float xmax = -1.f;