summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-27 19:00:43 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-10 09:10:11 +0200
commit6e23dfba625cc126f10fa7b40a901dd99bf1b5b4 (patch)
tree9e06a293e0df93f55aec1ec742a4cb3988bc1918
parent7024e6f03f89f44057c4513a947be728b064d453 (diff)
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
-rw-r--r--src/lib/elementary/efl_ui_position_manager_common.h26
-rw-r--r--src/lib/elementary/efl_ui_position_manager_grid.c16
-rw-r--r--src/lib/elementary/efl_ui_position_manager_list.c8
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 {
23} Vis_Segment; 23} Vis_Segment;
24 24
25static Efl_Ui_Position_Manager_Size_Batch_Result 25static Efl_Ui_Position_Manager_Size_Batch_Result
26_batch_request_size(Api_Callbacks cb , int start_id, int len, Eina_Bool cache, void *data) 26_batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_Bool cache, void *data)
27{ 27{
28 Efl_Ui_Position_Manager_Size_Batch_Result res; 28 Efl_Ui_Position_Manager_Size_Batch_Result res;
29 29
@@ -34,28 +34,28 @@ _batch_request_size(Api_Callbacks cb , int start_id, int len, Eina_Bool cache, v
34 Efl_Ui_Position_Manager_Size_Call_Config conf; 34 Efl_Ui_Position_Manager_Size_Call_Config conf;
35 conf.cache_request = cache; 35 conf.cache_request = cache;
36 conf.range.start_id = start_id; 36 conf.range.start_id = start_id;
37 conf.range.end_id = start_id + len; 37 conf.range.end_id = MIN(start_id + len, end_id);
38 38
39 res = cb.size.access(cb.size.data, conf, slice); 39 res = cb.size.access(cb.size.data, conf, slice);
40 40
41 return res; 41 return res;
42} 42}
43 43
44#define BATCH_ACCESS_SIZE(cb, start_id, len, cache, data) \ 44#define BATCH_ACCESS_SIZE(cb, start_id, end_id, len, cache, data) \
45 do { \ 45 do { \
46 size_result = _batch_request_size((cb), (start_id), (len), (cache), (data)); \ 46 size_result = _batch_request_size((cb), (start_id), (end_id), (len), (cache), (data)); \
47 EINA_SAFETY_ON_FALSE_RETURN(size_result.filled_items > 0); \ 47 EINA_SAFETY_ON_FALSE_RETURN(size_result.filled_items > 0); \
48 } while(0); 48 } while(0);
49 49
50#define BATCH_ACCESS_SIZE_VAL(cb, start_id, len, cache, data, V) \ 50#define BATCH_ACCESS_SIZE_VAL(cb, start_id, end_id, len, cache, data, V) \
51 do { \ 51 do { \
52 size_result = _batch_request_size((cb), (start_id), (len), (cache), (data)); \ 52 size_result = _batch_request_size((cb), (start_id), (end_id), (len), (cache), (data)); \
53 EINA_SAFETY_ON_FALSE_RETURN_VAL(size_result.filled_items > 0, V); \ 53 EINA_SAFETY_ON_FALSE_RETURN_VAL(size_result.filled_items > 0, V); \
54 } while(0); 54 } while(0);
55 55
56 56
57static Efl_Ui_Position_Manager_Object_Batch_Result 57static Efl_Ui_Position_Manager_Object_Batch_Result
58_batch_request_objects(Api_Callbacks cb , int start_id, int len, void *data) 58_batch_request_objects(Api_Callbacks cb , int start_id, int end_id, int len, void *data)
59{ 59{
60 Efl_Ui_Position_Manager_Object_Batch_Result res; 60 Efl_Ui_Position_Manager_Object_Batch_Result res;
61 61
@@ -65,22 +65,22 @@ _batch_request_objects(Api_Callbacks cb , int start_id, int len, void *data)
65 65
66 Efl_Ui_Position_Manager_Request_Range range; 66 Efl_Ui_Position_Manager_Request_Range range;
67 range.start_id = start_id; 67 range.start_id = start_id;
68 range.end_id = start_id + len; 68 range.end_id = MIN(start_id + len, end_id);
69 69
70 res = cb.object.access(cb.object.data, range, slice); 70 res = cb.object.access(cb.object.data, range, slice);
71 71
72 return res; 72 return res;
73} 73}
74 74
75#define BATCH_ACCESS_OBJECT(cb, start_id, len, data) \ 75#define BATCH_ACCESS_OBJECT(cb, start_id, end_id, len, data) \
76 do { \ 76 do { \
77 object_result = _batch_request_objects((cb), (start_id), (len), (data)); \ 77 object_result = _batch_request_objects((cb), (start_id), (end_id), (len), (data)); \
78 EINA_SAFETY_ON_FALSE_RETURN(object_result.filled_items > 0); \ 78 EINA_SAFETY_ON_FALSE_RETURN(object_result.filled_items > 0); \
79 } while(0); 79 } while(0);
80 80
81#define BATCH_ACCESS_OBJECT_VAL(cb, start_id, len, data, v) \ 81#define BATCH_ACCESS_OBJECT_VAL(cb, start_id, end_id, len, data, v) \
82 do { \ 82 do { \
83 object_result = _batch_request_objects((cb), (start_id), (len), (data)); \ 83 object_result = _batch_request_objects((cb), (start_id), (end_id), (len), (data)); \
84 EINA_SAFETY_ON_FALSE_RETURN_VAL(object_result.filled_items > 0, v); \ 84 EINA_SAFETY_ON_FALSE_RETURN_VAL(object_result.filled_items > 0, v); \
85 } while(0); 85 } while(0);
86 86
@@ -100,7 +100,7 @@ vis_change_segment(Api_Callbacks cb, int a, int b, Eina_Bool flag)
100 100
101 if (buffer_id == 0) 101 if (buffer_id == 0)
102 { 102 {
103 BATCH_ACCESS_OBJECT(cb, i, len, data); 103 BATCH_ACCESS_OBJECT(cb, i, MAX(a,b), len, data);
104 } 104 }
105 ent = data[buffer_id].entity; 105 ent = data[buffer_id].entity;
106 if (ent && !flag && (efl_ui_focus_object_focus_get(ent) || efl_ui_focus_object_child_focus_get(ent))) 106 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)
70 70
71 if (buffer_id == 0) 71 if (buffer_id == 0)
72 { 72 {
73 BATCH_ACCESS_SIZE(pd->callbacks, i, MIN(len, pd->size - i), EINA_TRUE, size_buffer); 73 BATCH_ACCESS_SIZE(pd->callbacks, i, pd->size, MIN(len, pd->size - i), EINA_TRUE, size_buffer);
74 } 74 }
75 75
76 if (size_buffer[buffer_id].depth_leader) 76 if (size_buffer[buffer_id].depth_leader)
@@ -266,8 +266,8 @@ _position_items_vertical(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data
266 int buffer_id = (i-ctx->new.start_id) % len; 266 int buffer_id = (i-ctx->new.start_id) % len;
267 if (buffer_id == 0) 267 if (buffer_id == 0)
268 { 268 {
269 BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); 269 BATCH_ACCESS_SIZE(pd->callbacks, i, ctx->new.end_id, len, EINA_FALSE, size_buffer);
270 BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); 270 BATCH_ACCESS_OBJECT(pd->callbacks, i, ctx->new.end_id, len, obj_buffer);
271 271
272 if (i == ctx->new.start_id) 272 if (i == ctx->new.start_id)
273 { 273 {
@@ -333,8 +333,8 @@ _position_items_horizontal(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Dat
333 int buffer_id = (i-ctx->new.start_id) % len; 333 int buffer_id = (i-ctx->new.start_id) % len;
334 if (buffer_id == 0) 334 if (buffer_id == 0)
335 { 335 {
336 BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); 336 BATCH_ACCESS_SIZE(pd->callbacks, i, ctx->new.end_id, len, EINA_FALSE, size_buffer);
337 BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); 337 BATCH_ACCESS_OBJECT(pd->callbacks, i, ctx->new.end_id, len, obj_buffer);
338 338
339 if (i == ctx->new.start_id) 339 if (i == ctx->new.start_id)
340 { 340 {
@@ -593,7 +593,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_added(Eo *obj,
593 593
594 efl_gfx_entity_visible_set(subobj, EINA_FALSE); 594 efl_gfx_entity_visible_set(subobj, EINA_FALSE);
595 _group_cache_invalidate(obj, pd); 595 _group_cache_invalidate(obj, pd);
596 BATCH_ACCESS_SIZE(pd->callbacks, added_index, 1, EINA_TRUE, size_buffer); 596 BATCH_ACCESS_SIZE(pd->callbacks, added_index, added_index + 1, 1, EINA_TRUE, size_buffer);
597 _update_min_size(obj, pd, added_index, size_buffer[0].size); 597 _update_min_size(obj, pd, added_index, size_buffer[0].size);
598 _flush_min_size(obj, pd); 598 _flush_min_size(obj, pd);
599 _schedule_recalc_abs_size(obj, pd); 599 _schedule_recalc_abs_size(obj, pd);
@@ -624,7 +624,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_size_changed(E
624 int buffer_id = (i-start_id) % len; 624 int buffer_id = (i-start_id) % len;
625 if (buffer_id == 0) 625 if (buffer_id == 0)
626 { 626 {
627 BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_TRUE, size_buffer); 627 BATCH_ACCESS_SIZE(pd->callbacks, i, end_id + 1, len, EINA_TRUE, size_buffer);
628 } 628 }
629 _update_min_size(obj, pd, i, size_buffer[buffer_id].size); 629 _update_min_size(obj, pd, i, size_buffer[buffer_id].size);
630 } 630 }
@@ -662,7 +662,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_position_single_ite
662 662
663 if (!pd->size) return EINA_RECT(0, 0, 0, 0); 663 if (!pd->size) return EINA_RECT(0, 0, 0, 0);
664 if (pd->max_min_size.w <= 0 || pd->max_min_size.h <= 0) return EINA_RECT(0, 0, 0, 0); 664 if (pd->max_min_size.w <= 0 || pd->max_min_size.h <= 0) return EINA_RECT(0, 0, 0, 0);
665 BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, 1, EINA_TRUE, size_buffer, EINA_RECT_EMPTY()); 665 BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, idx + 1, 1, EINA_TRUE, size_buffer, EINA_RECT_EMPTY());
666 666
667 _size_cache_require(obj, pd); 667 _size_cache_require(obj, pd);
668 _flush_abs_size(obj, pd); 668 _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)
66 66
67 if (buffer_id == 0) 67 if (buffer_id == 0)
68 { 68 {
69 BATCH_ACCESS_SIZE(pd->callbacks, i, MIN(len, pd->size - i), EINA_TRUE, size_buffer); 69 BATCH_ACCESS_SIZE(pd->callbacks, i, pd->size, MIN(len, pd->size - i), EINA_TRUE, size_buffer);
70 } 70 }
71 size = size_buffer[buffer_id].size; 71 size = size_buffer[buffer_id].size;
72 72
@@ -192,8 +192,8 @@ _position_items(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, Vis_
192 192
193 if (buffer_id == 0) 193 if (buffer_id == 0)
194 { 194 {
195 BATCH_ACCESS_SIZE(pd->callbacks, i, len, EINA_FALSE, size_buffer); 195 BATCH_ACCESS_SIZE(pd->callbacks, i, new.end_id, len, EINA_FALSE, size_buffer);
196 BATCH_ACCESS_OBJECT(pd->callbacks, i, len, obj_buffer); 196 BATCH_ACCESS_OBJECT(pd->callbacks, i, new.end_id, len, obj_buffer);
197 197
198 if (i == new.start_id) 198 if (i == new.start_id)
199 { 199 {
@@ -433,7 +433,7 @@ _efl_ui_position_manager_list_efl_ui_position_manager_entity_position_single_ite
433 433
434 geom = pd->viewport; 434 geom = pd->viewport;
435 435
436 BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, 1, EINA_FALSE, size_buffer, EINA_RECT_EMPTY()); 436 BATCH_ACCESS_SIZE_VAL(pd->callbacks, idx, idx + 1, 1, EINA_FALSE, size_buffer, EINA_RECT_EMPTY());
437 437
438 size = size_buffer[0].size; 438 size = size_buffer[0].size;
439 439