diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-02-20 17:59:50 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-02-21 10:52:39 +0900 |
commit | 9a83113b9f2864d3e9f4c133d6cb61330ba8c454 (patch) | |
tree | 4bec628c5bcc009bc0ebee1d5b6e1b1184b51de2 /src/lib | |
parent | e8acf4762ba133642b0053cb7ac15f17bc1766f0 (diff) |
evas: Optimize out more calls to efl_isa
In relative smart move, we only need to check once that the object
is indeed a valid smart object. This drops the call count from ~1.02M
to ~785k.
@optimization
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/evas/canvas/evas_object_smart.c | 46 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_smart_clipped.c | 8 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 2 |
3 files changed, 31 insertions, 25 deletions
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c index 0b3cb69fbc..527908930c 100644 --- a/src/lib/evas/canvas/evas_object_smart.c +++ b/src/lib/evas/canvas/evas_object_smart.c | |||
@@ -640,17 +640,12 @@ _efl_canvas_group_efl_object_destructor(Eo *eo_obj, Evas_Smart_Data *o) | |||
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | EAPI void | 643 | static inline void |
644 | evas_object_smart_move_children_relative(Eo *eo_obj, Evas_Coord dx, Evas_Coord dy) | 644 | _evas_object_smart_move_relative_internal(Evas_Smart_Data *o, Evas_Coord dx, Evas_Coord dy) |
645 | { | 645 | { |
646 | Evas_Object_Protected_Data *child; | 646 | Evas_Object_Protected_Data *child; |
647 | const Eina_Inlist *lst; | ||
648 | |||
649 | if ((dx == 0) && (dy == 0)) return; | ||
650 | if (!efl_isa(eo_obj, MY_CLASS)) return; | ||
651 | 647 | ||
652 | lst = evas_object_smart_members_get_direct(eo_obj); | 648 | EINA_INLIST_FOREACH(o->contained, child) |
653 | EINA_INLIST_FOREACH(lst, child) | ||
654 | { | 649 | { |
655 | Evas_Coord orig_x, orig_y; | 650 | Evas_Coord orig_x, orig_y; |
656 | 651 | ||
@@ -662,6 +657,30 @@ evas_object_smart_move_children_relative(Eo *eo_obj, Evas_Coord dx, Evas_Coord d | |||
662 | } | 657 | } |
663 | } | 658 | } |
664 | 659 | ||
660 | EAPI void | ||
661 | evas_object_smart_move_children_relative(Eo *eo_obj, Evas_Coord dx, Evas_Coord dy) | ||
662 | { | ||
663 | Evas_Smart_Data *o; | ||
664 | |||
665 | if ((dx == 0) && (dy == 0)) return; | ||
666 | if (!efl_isa(eo_obj, MY_CLASS)) return; | ||
667 | o = efl_data_scope_get(eo_obj, MY_CLASS); | ||
668 | _evas_object_smart_move_relative_internal(o, dx, dy); | ||
669 | } | ||
670 | |||
671 | void | ||
672 | _evas_object_smart_clipped_smart_move_internal(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y) | ||
673 | { | ||
674 | Evas_Smart_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_GROUP_CLASS); | ||
675 | Evas_Coord orig_x, orig_y; | ||
676 | |||
677 | orig_x = o->x; | ||
678 | orig_y = o->y; | ||
679 | o->x = x; | ||
680 | o->y = y; | ||
681 | _evas_object_smart_move_relative_internal(o, x - orig_x, y - orig_y); | ||
682 | } | ||
683 | |||
665 | EOLIAN static void | 684 | EOLIAN static void |
666 | _efl_canvas_group_group_add(Eo *eo_obj, Evas_Smart_Data *o EINA_UNUSED) | 685 | _efl_canvas_group_group_add(Eo *eo_obj, Evas_Smart_Data *o EINA_UNUSED) |
667 | { | 686 | { |
@@ -957,17 +976,6 @@ _evas_canvas_smart_objects_calculate_count_get(Eo *eo_e EINA_UNUSED, Evas_Public | |||
957 | return e->smart_calc_count; | 976 | return e->smart_calc_count; |
958 | } | 977 | } |
959 | 978 | ||
960 | void | ||
961 | _evas_object_smart_xy_update(Eo *eo_obj, Evas_Coord *px, Evas_Coord *py, | ||
962 | Evas_Coord x, Evas_Coord y) | ||
963 | { | ||
964 | EVAS_OBJECT_SMART_GET_OR_RETURN(eo_obj); | ||
965 | *px = o->x; | ||
966 | *py = o->y; | ||
967 | o->x = x; | ||
968 | o->y = y; | ||
969 | } | ||
970 | |||
971 | /** | 979 | /** |
972 | * Call calculate() on all smart objects that need_recalculate. | 980 | * Call calculate() on all smart objects that need_recalculate. |
973 | * | 981 | * |
diff --git a/src/lib/evas/canvas/evas_object_smart_clipped.c b/src/lib/evas/canvas/evas_object_smart_clipped.c index a4b96d335d..6275ef6299 100644 --- a/src/lib/evas/canvas/evas_object_smart_clipped.c +++ b/src/lib/evas/canvas/evas_object_smart_clipped.c | |||
@@ -85,10 +85,8 @@ _efl_canvas_group_clipped_efl_canvas_group_group_del(Eo *eo_obj, Evas_Object_Sma | |||
85 | static void | 85 | static void |
86 | evas_object_smart_clipped_smart_move(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y) | 86 | evas_object_smart_clipped_smart_move(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y) |
87 | { | 87 | { |
88 | Evas_Coord orig_x, orig_y; | 88 | if (!efl_isa(eo_obj, EFL_CANVAS_GROUP_CLASS)) return; |
89 | 89 | _evas_object_smart_clipped_smart_move_internal(eo_obj, x, y); | |
90 | _evas_object_smart_xy_update(eo_obj, &orig_x, &orig_y, x, y); | ||
91 | evas_object_smart_move_children_relative(eo_obj, x - orig_x, y - orig_y); | ||
92 | } | 90 | } |
93 | 91 | ||
94 | EOLIAN static void | 92 | EOLIAN static void |
@@ -97,7 +95,7 @@ _efl_canvas_group_clipped_efl_gfx_position_set(Eo *eo_obj, Evas_Object_Smart_Cli | |||
97 | if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, x, y)) | 95 | if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, x, y)) |
98 | return; | 96 | return; |
99 | 97 | ||
100 | evas_object_smart_clipped_smart_move(eo_obj, x, y); | 98 | _evas_object_smart_clipped_smart_move_internal(eo_obj, x, y); |
101 | efl_gfx_position_set(efl_super(eo_obj, MY_CLASS), x, y); | 99 | efl_gfx_position_set(efl_super(eo_obj, MY_CLASS), x, y); |
102 | } | 100 | } |
103 | 101 | ||
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 0aad234a68..8b448124b9 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h | |||
@@ -1679,7 +1679,7 @@ void evas_object_smart_render_cache_set(Evas_Object *eo_obj, void *data); | |||
1679 | 1679 | ||
1680 | const Eina_Inlist *evas_object_smart_members_get_direct(const Evas_Object *obj); | 1680 | const Eina_Inlist *evas_object_smart_members_get_direct(const Evas_Object *obj); |
1681 | void _efl_canvas_group_group_members_all_del(Evas_Object *eo_obj); | 1681 | void _efl_canvas_group_group_members_all_del(Evas_Object *eo_obj); |
1682 | void _evas_object_smart_xy_update(Eo *eo_obj, Evas_Coord *px, Evas_Coord *py, Evas_Coord x, Evas_Coord y); | 1682 | void _evas_object_smart_clipped_smart_move_internal(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y); |
1683 | void evas_call_smarts_calculate(Evas *e); | 1683 | void evas_call_smarts_calculate(Evas *e); |
1684 | void evas_object_smart_bounding_box_update(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj); | 1684 | void evas_object_smart_bounding_box_update(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj); |
1685 | void evas_object_smart_need_bounding_box_update(Evas_Object *eo_obj, Evas_Smart_Data *o, Evas_Object_Protected_Data *obj); | 1685 | void evas_object_smart_need_bounding_box_update(Evas_Object *eo_obj, Evas_Smart_Data *o, Evas_Object_Protected_Data *obj); |