summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2021-01-29 11:53:15 +0200
committerali-alzyod <ali198724@gmail.com>2021-01-29 11:53:16 +0200
commit39c305cf866ca65658f270a11d7fc76cabcc613f (patch)
tree04dd3a9f59dfaa758f2e9f92eb0909f8370e72fc /src
parente138962dd75ca15ce4599edbb5d7b2a0946b2c1c (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/efl_ui_textpath.c10
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
264_text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map *map, Efl_Ui_Textpath_Line line) 264_text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map *map, Efl_Ui_Textpath_Line line)
265{ 265{
266 double x1, x2, y1, y2; 266 double x1, x2, y1, y2;
267 double line_len, len, sina, cosa; 267 double line_len_2, line_len, len, sina, cosa;
268 Eina_Rect r; 268 Eina_Rect r;
269 269
270 x1 = line.start.x; 270 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 *
272 x2 = line.end.x; 272 x2 = line.end.x;
273 y2 = line.end.y; 273 y2 = line.end.y;
274 274
275 line_len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); 275 line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
276 len = w2 - w1; 276 len = w2 - w1;
277 if (line_len > len) 277 if (line_len_2 > (len * len))
278 { 278 {
279 line_len = sqrt(line_len_2);
279 x2 = x1 + len * (x2 - x1) / line_len; 280 x2 = x1 + len * (x2 - x1) / line_len;
280 y2 = y1 + len * (y2 - y1) / line_len; 281 y2 = y1 + len * (y2 - y1) / line_len;
282 line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
281 } 283 }
282 284
283 len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); 285 len = sqrt(line_len_2);
284 sina = (y2 - y1) / len; 286 sina = (y2 - y1) / len;
285 cosa = (x2 - x1) / len; 287 cosa = (x2 - x1) / len;
286 288