This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 382be7c9f802e5ccbef0e9b79979dd4cec3d655d
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 20:42:45 2026 -0600
elementary: position_manager_grid: look for max min size in known sizes
An item that went made the grid ask for the size of every item with the
caching request, which on an Exact_Model or an Average_Model queues the
fetch of every row nobody built. The size call has a new flag to say
that only what is known is wanted (no_fetch, a field added to the @beta
Size_Call_Config): the view then answers from what the rows were told,
the rows it has and the size a Homogeneous_Model gives, and says 0x0 for
the others, which the grid leaves out. When nothing is known the size it
had stays.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_collection_view.c | 38 +++++
.../elementary/efl_ui_position_manager_common.h | 18 ++-
.../efl_ui_position_manager_data_access_v1.eo | 4 +
src/lib/elementary/efl_ui_position_manager_grid.c | 12 +-
src/tests/elementary/efl_ui_test_collection_view.c | 161 +++++++++++++++++++++
5 files changed, 229 insertions(+), 4 deletions(-)
diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index 00089523c9..50d8621f1f 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -959,6 +959,29 @@ _cache_size_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
return requests;
}
+/* The size of a row if it is known without fetching or building anything: told
+ to an Exact_Model, or in a row that the view has, or the one a Homogeneous_Model
+ says all of them have. */
+static Eina_Bool
+_known_size_get(Efl_Ui_Collection_View_Data *pd, Efl_Model *exact,
+ unsigned int search_index, Eina_Size2D *size)
+{
+ Efl_Ui_Collection_Item_Lookup *lookup;
+
+ if (exact && _efl_ui_exact_model_row_size_get(exact, search_index, size))
+ return EINA_TRUE;
+ if (pd->cache)
+ {
+ lookup = (void*) eina_rbtree_inline_lookup(pd->cache, &search_index,
+ sizeof (search_index), _cache_tree_lookup,
+ NULL);
+ if (lookup && lookup->item.model && ITEM_SIZE_FROM_MODEL(lookup->item.model, *size))
+ return EINA_TRUE;
+ }
+ return efl_isa(pd->model, EFL_UI_HOMOGENEOUS_MODEL_CLASS) &&
+ ITEM_BASE_SIZE_FROM_MODEL(pd->model, *size);
+}
+
static Eina_List *
_cache_entity_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
Efl_Ui_Collection_View_Data *pd,
@@ -1167,6 +1190,21 @@ _batch_size_cb(void *data, Efl_Ui_Position_Manager_Size_Call_Config conf, Eina_R
sizes = memory.mem;
//count = efl_model_children_count_get(parent);
limit = conf.range.end_id - conf.range.start_id;
+
+ /* Only what is known is wanted: the rest is not fetched, and said to be nothing */
+ if (conf.no_fetch)
+ {
+ for (idx = 0; idx < limit; idx++)
+ {
+ if (!_known_size_get(pd, exact, conf.range.start_id + idx, &sizes[idx].size))
+ sizes[idx].size = EINA_SIZE2D(0, 0);
+ sizes[idx].element_depth = 0;
+ sizes[idx].depth_leader = EINA_FALSE;
+ }
+ result.filled_items = limit;
+ return result;
+ }
+
ITEM_BASE_SIZE_FROM_MODEL(parent, item_base);
/* Before anything has been measured, an item is said to fill the view.
diff --git a/src/lib/elementary/efl_ui_position_manager_common.h b/src/lib/elementary/efl_ui_position_manager_common.h
index 69915945cd..6481d62ff6 100644
--- a/src/lib/elementary/efl_ui_position_manager_common.h
+++ b/src/lib/elementary/efl_ui_position_manager_common.h
@@ -23,7 +23,8 @@ typedef struct {
} Vis_Segment;
static Efl_Ui_Position_Manager_Size_Batch_Result
-_batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_Bool cache, void *data)
+_batch_request_size_config(Api_Callbacks cb , int start_id, int end_id, int len,
+ Eina_Bool cache, Eina_Bool no_fetch, void *data)
{
Efl_Ui_Position_Manager_Size_Batch_Result res;
@@ -33,6 +34,7 @@ _batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_B
Efl_Ui_Position_Manager_Size_Call_Config conf;
conf.cache_request = cache;
+ conf.no_fetch = no_fetch;
conf.range.start_id = start_id;
conf.range.end_id = MIN(start_id + len, end_id);
@@ -41,6 +43,20 @@ _batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_B
return res;
}
+static Efl_Ui_Position_Manager_Size_Batch_Result
+_batch_request_size(Api_Callbacks cb , int start_id, int end_id, int len, Eina_Bool cache, void *data)
+{
+ return _batch_request_size_config(cb, start_id, end_id, len, cache, EINA_FALSE, data);
+}
+
+// What is already known of the sizes only: nothing is fetched to answer, and an
+// item that is not known is 0x0
+static Efl_Ui_Position_Manager_Size_Batch_Result
+_batch_request_size_known(Api_Callbacks cb , int start_id, int end_id, int len, void *data)
+{
+ return _batch_request_size_config(cb, start_id, end_id, len, EINA_TRUE, EINA_TRUE, data);
+}
+
#define BATCH_ACCESS_SIZE(cb, start_id, end_id, len, cache, data) \
do { \
size_result = _batch_request_size((cb), (start_id), (end_id), (len), (cache), (data)); \
diff --git a/src/lib/elementary/efl_ui_position_manager_data_access_v1.eo b/src/lib/elementary/efl_ui_position_manager_data_access_v1.eo
index ff4e8ec737..4e2b216c67 100644
--- a/src/lib/elementary/efl_ui_position_manager_data_access_v1.eo
+++ b/src/lib/elementary/efl_ui_position_manager_data_access_v1.eo
@@ -50,6 +50,10 @@ struct @beta Efl.Ui.Position_Manager.Size_Call_Config {
If it's for caching, the data-provider will fill in approximations, instead of doing heavy
lifting from some back-end. If this is not a caching call, the exact size should be
requested and delivered at some later point.]]
+ no_fetch : bool; [[Indicate that the sizes are wanted only as far as they are already known:
+ nothing is to be fetched, built or measured to answer. An item whose size
+ is not known is given as 0x0, and what is asked is then not an estimate
+ either.]]
}
struct @beta Efl.Ui.Position_Manager.Object_Batch_Result {
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c b/src/lib/elementary/efl_ui_position_manager_grid.c
index 94dc67900d..6f3726e34b 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.c
+++ b/src/lib/elementary/efl_ui_position_manager_grid.c
@@ -182,7 +182,9 @@ _group_cache_remove(Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int idx)
}
// The biggest minimum size of the items, asked for again: an item that goes may
-// have been the one that gave it, and the sizes are not kept to tell.
+// have been the one that gave it, and the sizes are not kept to tell. Only the
+// sizes that are known are asked for: nothing is fetched or built for the items
+// that nobody has seen to find out what they would give.
static void
_min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
{
@@ -195,18 +197,22 @@ _min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
{
unsigned int j, filled;
- size_result = _batch_request_size(pd->callbacks, i, pd->size, MIN(100, pd->size - i),
- EINA_TRUE, size_buffer);
+ size_result = _batch_request_size_known(pd->callbacks, i, pd->size,
+ MIN(100, pd->size - i), size_buffer);
filled = MIN(size_result.filled_items, 100);
// (what is not told is not known: the biggest is then the one that was)
if (!filled) return;
for (j = 0; j < filled; j++)
{
+ // (an item that is not known is 0x0)
+ if (!size_buffer[j].size.w && !size_buffer[j].size.h) continue;
max.w = MAX(max.w, size_buffer[j].size.w);
max.h = MAX(max.h, size_buffer[j].size.h);
}
i += filled;
}
+ // (nothing known, nothing to go on: what it was stays)
+ if (!max.w && !max.h) return;
if ((max.w != pd->max_min_size.w) || (max.h != pd->max_min_size.h))
{
pd->max_min_size = max;
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index a191a4cbda..c826f87a69 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -1890,6 +1890,165 @@ EFL_START_TEST(test_efl_ui_position_manager_grid_min_size_goes_down)
}
EFL_END_TEST
+/* What the grid asks again when an item goes is only what is known: a provider
+ that does not know a size says so (0x0) when it is told not to fetch, and
+ is asked nothing else. */
+static unsigned int _known_calls = 0;
+static unsigned int _full_calls = 0;
+
+static Efl_Ui_Position_Manager_Size_Batch_Result
+_known_size_cb(void *data EINA_UNUSED, Efl_Ui_Position_Manager_Size_Call_Config conf,
+ Eina_Rw_Slice memory)
+{
+ Efl_Ui_Position_Manager_Size_Batch_Entity *sizes = memory.mem;
+ Efl_Ui_Position_Manager_Size_Batch_Result result = { 0 };
+ unsigned int i, limit = conf.range.end_id - conf.range.start_id;
+
+ if (conf.no_fetch)
+ {
+ _known_calls++;
+ }
+ else if (conf.cache_request)
+ {
+ _full_calls++;
+ }
+ for (i = 0; (i < limit) && conf.range.start_id + i < _cache_count; i++)
+ {
+ unsigned int id = conf.range.start_id + i;
+
+ // (only the first two items are known, when that is all that is wanted)
+ sizes[i].size = (conf.no_fetch && id >= 2) ? EINA_SIZE2D(0, 0) :
+ EINA_SIZE2D(_cache_sizes[id], 30);
+ sizes[i].element_depth = 0;
+ sizes[i].depth_leader = EINA_FALSE;
+ }
+ result.filled_items = i;
+ return result;
+}
+
+EFL_START_TEST(test_efl_ui_position_manager_grid_min_size_known_only)
+{
+ Efl_Ui_Win *win;
+ Efl_Ui_Position_Manager_Entity *manager;
+ static const int widths[] = { 40, 90, 60, 50, 95 };
+ unsigned int i;
+
+ win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+ _cache_dummy = efl_add(EFL_UI_BUTTON_CLASS, win);
+ _cache_count = EINA_C_ARRAY_LENGTH(widths);
+ for (i = 0; i < _cache_count; i++)
+ {
+ _cache_sizes[i] = widths[i];
+ }
+ manager = efl_add(EFL_UI_POSITION_MANAGER_GRID_CLASS, win,
+ efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
+ efl_ui_position_manager_data_access_v1_data_access_set(manager, win, NULL, _cache_object_cb, NULL,
+ NULL, _known_size_cb, NULL, _cache_count);
+ efl_ui_position_manager_entity_viewport_set(manager, EINA_RECT(0, 0, 200, 300));
+ ecore_main_loop_iterate();
+ ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 95);
+
+ // The item that gave the biggest one goes: the others that are known give theirs
+ _known_calls = _full_calls = 0;
+ _cache_count--;
+ efl_ui_position_manager_entity_item_removed(manager, _cache_count, _cache_dummy);
+ ecore_main_loop_iterate();
+ ck_assert_uint_gt(_known_calls, 0);
+ ck_assert_uint_eq(_full_calls, 0);
+ ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 90);
+
+ efl_del(manager);
+}
+EFL_END_TEST
+
+/* An Exact_Model that counts the rows that are fetched from it. */
+static unsigned int _fetched_rows = 0;
+
+static Eina_Future *
+_fetch_counting_slice_get(Eo *obj, void *pd EINA_UNUSED, unsigned int start, unsigned int count)
+{
+ _fetched_rows += count;
+ return efl_model_children_slice_get(efl_super(obj, efl_class_get(obj)), start, count);
+}
+
+static Eina_Bool
+_fetch_counting_initializer(Efl_Class *klass)
+{
+ EFL_OPS_DEFINE(ops,
+ EFL_OBJECT_OP_FUNC(efl_model_children_slice_get, _fetch_counting_slice_get));
+
+ return efl_class_functions_set(klass, &ops, NULL);
+}
+
+static const Efl_Class *
+_fetch_counting_class_get(const Efl_Class *parent)
+{
+ static const Efl_Class_Description desc = {
+ EO_VERSION,
+ "Test_Fetch_Counting_Model",
+ EFL_CLASS_TYPE_REGULAR,
+ 0,
+ _fetch_counting_initializer,
+ NULL,
+ NULL
+ };
+ static const Efl_Class *klass = NULL;
+
+ if (!klass) klass = efl_class_new(&desc, parent, NULL);
+ return klass;
+}
+
+/* The biggest minimum size of a grid is asked again when an item goes, and is
+ made of what the model already knows: the rows nobody built are not fetched
+ to be asked about (that would be every row of a list of a hundred thousand
+ when one is removed). */
+EFL_START_TEST(test_efl_ui_collection_view_grid_remove_fetches_nothing)
+{
+ Efl_Ui_Win *win;
+ Efl_Model *model, *sizes, *last = NULL;
+ Efl_Ui_Factory *fl;
+ Efl_Ui_Grid_View *gv;
+ Efl_Ui_Position_Manager_Entity *manager;
+ int i;
+
+ win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 300));
+
+ model = _make_model(win);
+ for (i = 0; i < 700; i++)
+ {
+ last = efl_model_child_add(model);
+ }
+ sizes = efl_add(_fetch_counting_class_get(EFL_UI_EXACT_MODEL_CLASS), win,
+ efl_ui_view_model_set(efl_added, model));
+ manager = efl_add(EFL_UI_POSITION_MANAGER_GRID_CLASS, win);
+ fl = efl_add(EFL_UI_WIDGET_FACTORY_CLASS, win,
+ efl_ui_widget_factory_item_class_set(efl_added, EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS),
+ efl_event_callback_add(efl_added, EFL_UI_FACTORY_EVENT_ITEM_BUILDING,
+ _row_height_on_build, NULL));
+ gv = efl_add(EFL_UI_GRID_VIEW_CLASS, win,
+ efl_ui_collection_view_position_manager_set(efl_added, manager),
+ efl_ui_collection_view_factory_set(efl_added, fl),
+ efl_ui_view_model_set(efl_added, sizes));
+ efl_content_set(win, gv);
+ get_me_to_those_events(gv);
+ for (i = 0; i < 50; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+
+ // The last one, which nobody built
+ _fetched_rows = 0;
+ efl_model_child_del(efl_ui_view_model_get(model), last);
+ for (i = 0; i < 50; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_uint_eq(efl_model_children_count_get(sizes), 749);
+ ck_assert_uint_lt(_fetched_rows, 100);
+}
+EFL_END_TEST
+
void efl_ui_test_collection_view(TCase *tc)
{
tcase_add_test(tc, test_efl_ui_collection_view_basic);
@@ -1920,4 +2079,6 @@ void efl_ui_test_collection_view(TCase *tc)
tcase_add_test(tc, test_efl_ui_collection_view_many_single_adds_grid);
tcase_add_test(tc, test_efl_ui_collection_view_exact_model_renumbered);
tcase_add_test(tc, test_efl_ui_position_manager_grid_min_size_goes_down);
+ tcase_add_test(tc, test_efl_ui_position_manager_grid_min_size_known_only);
+ tcase_add_test(tc, test_efl_ui_collection_view_grid_remove_fetches_nothing);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.