diff options
author | Ali Alzyod <ali198724@gmail.com> | 2021-01-29 11:53:15 +0200 |
---|---|---|
committer | ali-alzyod <ali198724@gmail.com> | 2021-01-29 11:53:16 +0200 |
commit | 39c305cf866ca65658f270a11d7fc76cabcc613f (patch) | |
tree | 04dd3a9f59dfaa758f2e9f92eb0909f8370e72fc | |
parent | e138962dd75ca15ce4599edbb5d7b2a0946b2c1c (diff) | |
download | efl-39c305cf866ca65658f270a11d7fc76cabcc613f.tar.gz |
efl_ui_textpath: mathmatical calculations
Summary: Reduce number of sqrt calls.
Reviewers: cedric, raster, bu5hm4n, vtorri, woohyun, Hermet
Subscribers: vtorri, bu5hm4n, raster, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T8747
Differential Revision: https://phab.enlightenment.org/D11949
-rw-r--r-- | src/lib/elementary/efl_ui_textpath.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/elementary/efl_ui_textpath.c b/src/lib/elementary/efl_ui_textpath.c index 321cd20568..6638de5456 100644 --- a/src/lib/elementary/efl_ui_textpath.c +++ b/src/lib/elementary/efl_ui_textpath.c @@ -264,7 +264,7 @@ static void _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map *map, Efl_Ui_Textpath_Line line) { double x1, x2, y1, y2; - double line_len, len, sina, cosa; + double line_len_2, line_len, len, sina, cosa; Eina_Rect r; x1 = line.start.x; @@ -272,15 +272,17 @@ _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map * x2 = line.end.x; y2 = line.end.y; - line_len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); + line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1); len = w2 - w1; - if (line_len > len) + if (line_len_2 > (len * len)) { + line_len = sqrt(line_len_2); x2 = x1 + len * (x2 - x1) / line_len; y2 = y1 + len * (y2 - y1) / line_len; + line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1); } - len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); + len = sqrt(line_len_2); sina = (y2 - y1) / len; cosa = (x2 - x1) / len; |