From 6e23dfba625cc126f10fa7b40a901dd99bf1b5b4 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Tue, 27 Aug 2019 19:00:43 +0200 Subject: [PATCH] efl_ui_position_manager: only fill as many items as we need prior to this commit, we just passed the start_id and the end_id the end_id was the start_id plus the size of the memory buffer. However, making this depending on the size of the memory buffer is a bad idea, as changing it based on our needs is rather painfull. With this commit we have explicit passing of the start_id, end_id and memory len. This is kind of redundant, however, its very convenient, and easy to write. The buffer will be filled with the maximum size that is possible with length of the buffer, however, the end_id will not be filled anymore. Differential Revision: https://phab.enlightenment.org/D9756 --- .../efl_ui_position_manager_common.h | 26 +++++++++---------- .../elementary/efl_ui_position_manager_grid.c | 16 ++++++------ .../elementary/efl_ui_position_manager_list.c | 8 +++--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lib/elementary/efl_ui_position_manager_common.h b/src/lib/elementary/efl_ui_position_manager_common.h index b50ea06312..69915945cd 100644 --- a/src/lib/elementary/efl_ui_position_manager_common.h +++ b/src/lib/elementary/efl_ui_position_manager_common.h @@ -23,7 +23,7 @@ typedef struct { } Vis_Segment; static Efl_Ui_Position_Manager_Size_Batch_Result -_batch_request_size(Api_Callbacks cb , int start_id, int len, Eina_Bool cache, void *data) +_batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_Bool cache, void *data) { Efl_Ui_Position_Manager_Size_Batch_Result res; @@ -34,28 +34,28 @@ _batch_request_size(Api_Callbacks cb , int start_id, int len, Eina_Bool cache, v Efl_Ui_Position_Manager_Size_Call_Config conf; conf.cache_request = cache; conf.range.start_id = start_id; - conf.range.end_id = start_id + len; + conf.range.end_id = MIN(start_id + len, end_id); res = cb.size.access(cb.size.data, conf, slice); return res; } -#define BATCH_ACCESS_SIZE(cb, start_id, len, cache, data) \ +#define BATCH_ACCESS_SIZE(cb, start_id, end_id, len, cache, data) \ do { \ - size_result = _batch_request_size((cb), (start_id), (len), (cache), (data)); \ + size_result = _batch_request_size((cb), (start_id), (end_id), (len), (cache), (data)); \ EINA_SAFETY_ON_FALSE_RETURN(size_result.filled_items > 0); \ } while(0); -#define BATCH_ACCESS_SIZE_VAL(cb, start_id, len, cache, data, V) \ +#define BATCH_ACCESS_SIZE_VAL(cb, start_id, end_id, len, cache, data, V) \ do { \ - size_result = _batch_request_size((cb), (start_id), (len), (cache), (data)); \ + size_result = _batch_request_size((cb), (start_id), (end_id), (len), (cache), (data)); \ EINA_SAFETY_ON_FALSE_RETURN_VAL(size_result.filled_items > 0, V); \ } while(0); static Efl_Ui_Position_Manager_Object_Batch_Result -_batch_request_objects(Api_Callbacks cb , int start_id, int len, void *data) +_batch_request_objects(Api_Callbacks cb , int start_id, int end_id, int len, void *data) { Efl_Ui_Position_Manager_Object_Batch_Result res; @@ -65,22 +65,22 @@ _batch_request_objects(Api_Callbacks cb , int start_id, int len, void *data) Efl_Ui_Position_Manager_Request_Range range; range.start_id = start_id; - range.end_id = start_id + len; + range.end_id = MIN(start_id + len, end_id); res = cb.object.access(cb.object.data, range, slice); return res; } -#define BATCH_ACCESS_OBJECT(cb, start_id, len, data) \ +#define BATCH_ACCESS_OBJECT(cb, start_id, end_id, len, data) \ do { \ - object_result = _batch_request_objects((cb), (start_id), (len), (data)); \ + object_result = _batch_request_objects((cb), (start_id), (end_id), (len), (data)); \ EINA_SAFETY_ON_FALSE_RETURN(object_result.filled_items > 0); \ } while(0); -#define BATCH_ACCESS_OBJECT_VAL(cb, start_id, len, data, v) \ +#define BATCH_ACCESS_OBJECT_VAL(cb, start_id, end_id, len, data, v) \ do { \ - object_result = _batch_request_objects((cb), (start_id), (len), (data)); \ + object_result = _batch_request_objects((cb), (start_id), (end_id), (len), (data)); \ EINA_SAFETY_ON_FALSE_RETURN_VAL(object_result.filled_items > 0, v); \ } while(0); @@ -100,7 +100,7 @@ vis_change_segment(Api_Callbacks cb, int a, int b, Eina_Bool flag) if (buffer_id == 0) { - BATCH_ACCESS_OBJECT(cb, i, len, data); + BATCH_ACCESS_OBJECT(cb, i, MAX(a,b), len, data); } ent = data[buffer_id].entity; if (ent && !flag && (efl_ui_focus_object_focus_get(ent) || efl_ui_focus_object_child_focus_get(ent))) diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c b/src/lib/elementary/efl_ui_position_manager_grid.c index ba48f376cc..dc863d0d5f 100644 --- a/src/lib/elementary/efl_ui_position_manager_grid.c +++ b/src/lib/elementary/efl_ui_position_manager_grid.c @@ -70,7 +70,7 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd) if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, MIN(len, pd->size - i), EINA_TRUE, size_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, pd->size, MIN(len, pd->size - i), EINA_TRUE, size_buffer); } if (size_buffer[buffer_id].depth_leader) @@ -266,8 +266,8 @@ _position_items_vertical(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data int buffer_id = (i-ctx->new.start_id) % len; if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); - BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, ctx->new.end_id, len, EINA_FALSE, size_buffer); + BATCH_ACCESS_OBJECT(pd->callbacks, i, ctx->new.end_id, len, obj_buffer); if (i == ctx->new.start_id) { @@ -333,8 +333,8 @@ _position_items_horizontal(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Dat int buffer_id = (i-ctx->new.start_id) % len; if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); - BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, ctx->new.end_id, len, EINA_FALSE, size_buffer); + BATCH_ACCESS_OBJECT(pd->callbacks, i, ctx->new.end_id, len, obj_buffer); if (i == ctx->new.start_id) { @@ -593,7 +593,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_added(Eo *obj, efl_gfx_entity_visible_set(subobj, EINA_FALSE); _group_cache_invalidate(obj, pd); - BATCH_ACCESS_SIZE(pd->callbacks, added_index, 1, EINA_TRUE, size_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, added_index, added_index + 1, 1, EINA_TRUE, size_buffer); _update_min_size(obj, pd, added_index, size_buffer[0].size); _flush_min_size(obj, pd); _schedule_recalc_abs_size(obj, pd); @@ -624,7 +624,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_size_changed(E int buffer_id = (i-start_id) % len; if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_TRUE, size_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, end_id + 1, len, EINA_TRUE, size_buffer); } _update_min_size(obj, pd, i, size_buffer[buffer_id].size); } @@ -662,7 +662,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_position_single_ite if (!pd->size) return EINA_RECT(0, 0, 0, 0); if (pd->max_min_size.w <= 0 || pd->max_min_size.h <= 0) return EINA_RECT(0, 0, 0, 0); - BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, 1, EINA_TRUE, size_buffer, EINA_RECT_EMPTY()); + BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, idx + 1, 1, EINA_TRUE, size_buffer, EINA_RECT_EMPTY()); _size_cache_require(obj, pd); _flush_abs_size(obj, pd); diff --git a/src/lib/elementary/efl_ui_position_manager_list.c b/src/lib/elementary/efl_ui_position_manager_list.c index df7c7c9a8d..5a159f308c 100644 --- a/src/lib/elementary/efl_ui_position_manager_list.c +++ b/src/lib/elementary/efl_ui_position_manager_list.c @@ -66,7 +66,7 @@ cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd) if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, MIN(len, pd->size - i), EINA_TRUE, size_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, pd->size, MIN(len, pd->size - i), EINA_TRUE, size_buffer); } size = size_buffer[buffer_id].size; @@ -192,8 +192,8 @@ _position_items(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, Vis_ if (buffer_id == 0) { - BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); - BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); + BATCH_ACCESS_SIZE(pd->callbacks, i, new.end_id, len, EINA_FALSE, size_buffer); + BATCH_ACCESS_OBJECT(pd->callbacks, i, new.end_id, len, obj_buffer); if (i == new.start_id) { @@ -433,7 +433,7 @@ _efl_ui_position_manager_list_efl_ui_position_manager_entity_position_single_ite geom = pd->viewport; - BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, 1, EINA_FALSE, size_buffer, EINA_RECT_EMPTY()); + BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, idx + 1, 1, EINA_FALSE, size_buffer, EINA_RECT_EMPTY()); size = size_buffer[0].size;