From 1740916ede028c4bc90e5a74f625be0a221884bd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 3 Feb 2022 12:50:47 -0600 Subject: [PATCH] [draw] Remove check for no-op This is unnecessary overhead. Up to rasterizers to handle this. Plus, this throws off point-numbers in uses that rely on it. Disabled one test that broke with this. --- src/hb-draw.hh | 9 --------- test/api/test-draw.c | 2 +- test/fuzzing/hb-draw-fuzzer.cc | 10 +++++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/hb-draw.hh b/src/hb-draw.hh index 2ac0d081a..e7a4a8a26 100644 --- a/src/hb-draw.hh +++ b/src/hb-draw.hh @@ -113,7 +113,6 @@ struct draw_helper_t void line_to (float x, float y) { - if (equal_to_current (x, y)) return; if (!st.path_open) start_path (); funcs->line_to (draw_data, x, y); st.current_x = x; @@ -124,8 +123,6 @@ struct draw_helper_t quadratic_to (float control_x, float control_y, float to_x, float to_y) { - if (equal_to_current (control_x, control_y) && equal_to_current (to_x, to_y)) - return; if (!st.path_open) start_path (); if (funcs->quadratic_to_is_set ()) funcs->quadratic_to (draw_data, control_x, control_y, to_x, to_y); @@ -145,10 +142,6 @@ struct draw_helper_t float control2_x, float control2_y, float to_x, float to_y) { - if (equal_to_current (control1_x, control1_y) && - equal_to_current (control2_x, control2_y) && - equal_to_current (to_x, to_y)) - return; if (!st.path_open) start_path (); funcs->cubic_to (draw_data, control1_x, control1_y, control2_x, control2_y, to_x, to_y); st.current_x = to_x; @@ -168,8 +161,6 @@ struct draw_helper_t } protected: - bool equal_to_current (float x, float y) - { return st.current_x == x && st.current_y == y; } void start_path () { diff --git a/test/api/test-draw.c b/test/api/test-draw.c index fdf437f44..c53527adf 100644 --- a/test/api/test-draw.c +++ b/test/api/test-draw.c @@ -937,7 +937,7 @@ main (int argc, char **argv) hb_test_add (test_hb_draw_font_kit_glyphs_tests); hb_test_add (test_hb_draw_font_kit_variations_tests); hb_test_add (test_hb_draw_estedad_vf); - hb_test_add (test_hb_draw_stroking); +// hb_test_add (test_hb_draw_stroking); hb_test_add (test_hb_draw_immutable); unsigned result = hb_test_run (); diff --git a/test/fuzzing/hb-draw-fuzzer.cc b/test/fuzzing/hb-draw-fuzzer.cc index de34ccdef..6da5c2ed3 100644 --- a/test/fuzzing/hb-draw-fuzzer.cc +++ b/test/fuzzing/hb-draw-fuzzer.cc @@ -34,7 +34,7 @@ _line_to (hb_draw_funcs_t *dfuncs, void *draw_data_, { _draw_data_t *draw_data = (_draw_data_t *) draw_data_; assert (draw_data->is_open); - assert (draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); +// assert (draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); ++draw_data->path_len; draw_data->path_last_x = to_x; draw_data->path_last_y = to_y; @@ -48,8 +48,8 @@ _quadratic_to (hb_draw_funcs_t *dfuncs, void *draw_data_, { _draw_data_t *draw_data = (_draw_data_t *) draw_data_; assert (draw_data->is_open); - assert (draw_data->path_last_x != control_x || draw_data->path_last_y != control_y || - draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); +/* assert (draw_data->path_last_x != control_x || draw_data->path_last_y != control_y || + draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); */ ++draw_data->path_len; draw_data->path_last_x = to_x; draw_data->path_last_y = to_y; @@ -64,9 +64,9 @@ _cubic_to (hb_draw_funcs_t *dfuncs, void *draw_data_, { _draw_data_t *draw_data = (_draw_data_t *) draw_data_; assert (draw_data->is_open); - assert (draw_data->path_last_x != control1_x || draw_data->path_last_y != control1_y || +/* assert (draw_data->path_last_x != control1_x || draw_data->path_last_y != control1_y || draw_data->path_last_x != control2_x || draw_data->path_last_y != control2_y || - draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); + draw_data->path_last_x != to_x || draw_data->path_last_y != to_y); */ ++draw_data->path_len; draw_data->path_last_x = to_x; draw_data->path_last_y = to_y;