summaryrefslogtreecommitdiff
path: root/src/tests/evas
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-05-04 15:25:07 -0400
committerMike Blumenkrantz <zmike@samsung.com>2020-05-04 15:25:07 -0400
commit3dff471826e815429c2cdc9b22df848bfad26e6c (patch)
treebdaa18feba5cceba447255146cc3f4946be00601 /src/tests/evas
parent3c619b96fc8b9e68c0ba4c7f191465ea7f1a428e (diff)
evas_textblock: optimize calculate main format once in layout setup stage
Summary: This change based on discussion on D9533 , where @smohanty example shows that unnecessary calculation happened on textblock related to lay-outing Where now _layout_setup will not calculate main format using (_format_fill) unless style has been changed. expedite commit: https://git.enlightenment.org/tools/expedite.git/commit/?id=dc6c931dc2e6c240d3e240f24578980c689ab7fc src/bin/textblock_text_fill_format.c Test Plan: ``` #define EFL_EO_API_SUPPORT 1 #define EFL_BETA_API_SUPPORT 1 #include <Eina.h> #include <Efl.h> #include <Elementary.h> EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *textblock; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(win, EINA_TRUE); int l, r, t, b; textblock = evas_object_textblock_add(evas_object_evas_get(win)); Evas_Textblock_Style *st = evas_textblock_style_new(); evas_textblock_style_set (st, "DEFAULT='font=Sans font_size=10 color=#000000 wrap=word align=left outline_color=#000 shadow_color=#fff8 shadow_color=#0002 glow2_color=#fe87 glow_color=#f214 underline_color=#00f linesize=40'"); evas_object_textblock_style_set(textblock, st); int sizes[] = {600, 700}; evas_object_textblock_text_markup_set(textblock, "This test resize text block and keep style (style parsed only once)"); clock_t start, end; start = clock(); for (int i = 0; i < 10000; i++) { evas_object_resize(textblock, sizes[i % 2], sizes[i % 2]); evas_object_textblock_style_insets_get(textblock, &l, &r, &t, &b); } end = clock(); double total_Time1 = ((double)(end - start)) / CLOCKS_PER_SEC; printf("total time = %f\n", total_Time1); evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(textblock); evas_object_move(textblock, 0, 0); evas_object_resize(textblock, 640, 800); evas_object_resize(win, 640, 800); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` **Old Code output : total time = 0.096900 New Code output : total time = 0.045580** Reviewers: smohanty, woohyun, Hermet, bowonryu, cedric, bu5hm4n, zmike Reviewed By: zmike Subscribers: zmike, segfaultxavi, bu5hm4n, smohanty, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9536
Diffstat (limited to 'src/tests/evas')
-rw-r--r--src/tests/evas/evas_test_textblock.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index d26b8fc7b9..620ce70b7b 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -4925,6 +4925,7 @@ EFL_START_TEST(efl_canvas_textblock_style)
4925 START_EFL_CANVAS_TEXTBLOCK_TEST(); 4925 START_EFL_CANVAS_TEXTBLOCK_TEST();
4926 unsigned char r, g, b, a; 4926 unsigned char r, g, b, a;
4927 const char *style; 4927 const char *style;
4928 Eina_Size2D size1, size2;
4928 4929
4929 efl_text_password_set(txt, EINA_FALSE); 4930 efl_text_password_set(txt, EINA_FALSE);
4930 efl_text_underline_type_set(txt, EFL_TEXT_STYLE_UNDERLINE_TYPE_DOUBLE); 4931 efl_text_underline_type_set(txt, EFL_TEXT_STYLE_UNDERLINE_TYPE_DOUBLE);
@@ -4995,6 +4996,15 @@ EFL_START_TEST(efl_canvas_textblock_style)
4995 ck_assert_int_eq(b, 0x6C); 4996 ck_assert_int_eq(b, 0x6C);
4996 ck_assert_int_eq(a, 0xFF); 4997 ck_assert_int_eq(a, 0xFF);
4997 4998
4999 // Style Apply taking
5000 efl_text_set(txt,"A");
5001 efl_canvas_textblock_style_apply(txt,"font_size=2");
5002 size1 = efl_canvas_textblock_size_native_get(txt);
5003 efl_canvas_textblock_style_apply(txt,"font_size=20");
5004 size2 = efl_canvas_textblock_size_native_get(txt);
5005 ck_assert(size1.w < size2.w);
5006 ck_assert(size1.h < size2.h);
5007
4998 END_EFL_CANVAS_TEXTBLOCK_TEST(); 5008 END_EFL_CANVAS_TEXTBLOCK_TEST();
4999} 5009}
5000EFL_END_TEST 5010EFL_END_TEST