summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-11-06 20:56:09 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commit5fa241fc4d07914c84a156be592c9bbd5b4f3fe4 (patch)
treef12fb2d44fc3ca88cf36d0eef09f454c32374509
parentf43819247110b3a56ca4a26d94eb45724c7862d6 (diff)
elm: size cache by node WIP
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c123
1 files changed, 105 insertions, 18 deletions
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 5ae1e1731a..c9d3d4118b 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -41,6 +41,14 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Size
41 double weight_x, weight_y; 41 double weight_x, weight_y;
42} Efl_Ui_List_Precise_Layouter_Size; 42} Efl_Ui_List_Precise_Layouter_Size;
43 43
44typedef struct _Efl_Ui_List_Precise_Layouter_Node_Data
45{
46 Eina_Size2D min;
47 Eina_Bool realized;
48} Efl_Ui_List_Precise_Layouter_Node_Data;
49
50
51
44typedef struct _Efl_Ui_List_Precise_Layouter_Callback_Data 52typedef struct _Efl_Ui_List_Precise_Layouter_Callback_Data
45{ 53{
46 Efl_Ui_List_Precise_Layouter_Data* pd; 54 Efl_Ui_List_Precise_Layouter_Data* pd;
@@ -56,9 +64,12 @@ static void _initilize(Eo *, Efl_Ui_List_Precise_Layouter_Data*, Efl_Ui_List_Mod
56static void _finalize(Eo *, Efl_Ui_List_Precise_Layouter_Data*); 64static void _finalize(Eo *, Efl_Ui_List_Precise_Layouter_Data*);
57 65
58static void 66static void
59_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_Ui_List_Precise_Layouter_Size *size, Eina_Size2D min) 67_item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_Ui_List_Precise_Layouter_Size *size, Eina_Size2D min
68 , Efl_Ui_List_SegArray_Node *node)
60{ 69{
61 int pad[4]; 70 int pad[4];
71 Efl_Ui_List_Precise_Layouter_Node_Data *nodedata = node->layout_data;
72
62 efl_gfx_size_hint_margin_get(layout, &pad[0], &pad[1], &pad[2], &pad[3]); 73 efl_gfx_size_hint_margin_get(layout, &pad[0], &pad[1], &pad[2], &pad[3]);
63 efl_gfx_size_hint_weight_get(layout, &size->weight_x, &size->weight_y); 74 efl_gfx_size_hint_weight_get(layout, &size->weight_x, &size->weight_y);
64 75
@@ -90,8 +101,19 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
90// { 101// {
91 102
92 pd->min.h += min.h - size->min.h; 103 pd->min.h += min.h - size->min.h;
104 nodedata->min.h += min.h - size->min.h;
105
106 if (nodedata->min.w <= min.w)
107 nodedata->min.w = min.w;
108 else if (nodedata->min.w == size->min.w)
109 {
110 int i;
111 for (i = 0; i != node->length; ++i)
112 {
113 }
114 }
93 115
94 if(pd->min.w <= min.w) 116 if (pd->min.w <= min.w)
95 pd->min.w = min.w; 117 pd->min.w = min.w;
96 else if (pd->min.w == size->min.w) 118 else if (pd->min.w == size->min.w)
97 { 119 {
@@ -110,6 +132,7 @@ _item_min_calc(Efl_Ui_List_Precise_Layouter_Data *pd, Evas_Object *layout, Efl_U
110 } 132 }
111 eina_iterator_free(size_iterator); 133 eina_iterator_free(size_iterator);
112 } 134 }
135
113// } 136// }
114 137
115 size->min.w = min.w; 138 size->min.w = min.w;
@@ -133,13 +156,35 @@ _count_error(void * data, Efl_Event const* event EINA_UNUSED)
133 EINA_SAFETY_ON_NULL_RETURN(pd); 156 EINA_SAFETY_ON_NULL_RETURN(pd);
134 pd->count_future = NULL; 157 pd->count_future = NULL;
135} 158}
159/*
160static void
161_slice_then(void * data, Efl_Event const* event)
162{
163 Efl_Ui_List_Precise_Layouter_Data *pd = data;
164
165 if (pd->slice_acc)
166 eina_accessor_free(pd->slice_acc);
167
168 pd->slice_acc = (Eina_Accessor*)((Efl_Future_Event_Success*)event->info)->value;
169
170 pd->slice_future = NULL;
171}
172
173static void
174_slice_error(void * data, Efl_Event const* event EINA_UNUSED)
175{
176 Efl_Ui_List_Precise_Layouter_Data *pd = data;
177 EINA_SAFETY_ON_NULL_RETURN(pd);
178 pd->slice_future = NULL;
179}
180*/
136static void 181static void
137_on_item_size_hint_change(void *data, Evas *e EINA_UNUSED, 182_on_item_size_hint_change(void *data, Evas *e EINA_UNUSED,
138 Evas_Object *obj, void *event_info EINA_UNUSED) 183 Evas_Object *obj, void *event_info EINA_UNUSED)
139{ 184{
140 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = data; 185 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = data;
141 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(obj); 186 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(obj);
142 _item_min_calc(cb_data->pd, obj, cb_data->size, min); 187 _item_min_calc(cb_data->pd, obj, cb_data->size, min, NULL);
143} 188}
144 189
145static void 190static void
@@ -147,7 +192,7 @@ _on_modeler_resize(void *data, Evas *e EINA_UNUSED,
147 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 192 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
148{ 193{
149 Efl_Ui_List_Precise_Layouter_Data *pd = data; 194 Efl_Ui_List_Precise_Layouter_Data *pd = data;
150 pd->recalc = EINA_TRUE; 195// pd->recalc = EINA_TRUE;
151} 196}
152 197
153static void 198static void
@@ -156,9 +201,18 @@ _initilize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd, Efl_Ui_Li
156 if(pd->initialized) 201 if(pd->initialized)
157 return; 202 return;
158 203
204 pd->recalc = EINA_TRUE;
159 pd->initialized = EINA_TRUE; 205 pd->initialized = EINA_TRUE;
160 evas_object_event_callback_add(modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd); 206 evas_object_event_callback_add(modeler, EVAS_CALLBACK_RESIZE, _on_modeler_resize, pd);
161 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all 207 efl_ui_list_model_load_range_set(modeler, 0, 0); // load all
208/*
209 if (pd->slice_future)
210 efl_future_cancel(pd->slice_future);
211
212
213 pd->slice_future = efl_model_children_slice_get(pd->model, 0, 0);
214 efl_future_then(pd->slice_future, &_slice_then, &_slice_error, NULL, pd);
215*/
162 pd->min.w = 0; 216 pd->min.w = 0;
163 pd->min.h = 0; 217 pd->min.h = 0;
164} 218}
@@ -191,36 +245,64 @@ _finalize(Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd)
191 pd->initialized = EINA_FALSE; 245 pd->initialized = EINA_FALSE;
192} 246}
193 247
248/*
194static void 249static void
195_calc_size_job(void *data) 250_calc_range(, Efl_Ui_List_Precise_Layouter_Data *pd, )
196{ 251{
197 Efl_Ui_List_Precise_Layouter_Size* size; 252 Efl_Ui_List_Precise_Layouter_Size* size;
198 Efl_Ui_List_Precise_Layouter_Data *pd; 253 Efl_Ui_List_Precise_Layouter_Data *pd;
254 Efl_Ui_List_LayoutItem* layout_item;
255 Eo *obj = data;
256 Evas_Coord ow, oh, scr_x, scr_y;
257
258 double start_time = ecore_time_get();
259
260 elm_interface_scrollable_content_viewport_geometry_get
261 (pd->modeler, NULL, NULL, &ow, &oh);
262
263 elm_interface_scrollable_content_pos_get(pd->modeler, &scr_x, &scr_y);
264
265
266
267}
268*/
269static void
270_calc_size_job(void *data)
271{
272 Efl_Ui_List_Precise_Layouter_Size *size, *nodesize;
273 Efl_Ui_List_Precise_Layouter_Data *pd;
199 Efl_Ui_List_SegArray_Node *items_node; 274 Efl_Ui_List_SegArray_Node *items_node;
200 Efl_Ui_List_LayoutItem *layout_item; 275 Efl_Ui_List_LayoutItem *layout_item;
201 Eo *obj = data; 276 Eo *obj = data;
202 int i; 277 int i;
203 double start_time = ecore_time_get(); 278 double start_time = ecore_time_get();
204 279
205 DBG(" >>>>> RECALC JOB <<<<<<< \n"); 280 DBG(" >>>>> CALC JOB <<<<<<< \n");
206 EINA_SAFETY_ON_NULL_RETURN(data); 281 EINA_SAFETY_ON_NULL_RETURN(data);
207 pd = efl_data_scope_get(obj, MY_CLASS); 282 pd = efl_data_scope_get(obj, MY_CLASS);
208 if (EINA_UNLIKELY(!pd)) return; 283 if (EINA_UNLIKELY(!pd)) return;
209 284
285 pd->recalc = EINA_FALSE;
286
210 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&items_node)) 287 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&items_node))
211 { 288 {
212 pd->calc_progress++; 289 pd->calc_progress++;
213 DBG("node first %d", items_node->first); 290 DBG("node first %d", items_node->first);
291 nodesize = (Efl_Ui_List_Precise_Layouter_Node_Data *)items_node->layout_data;
292 if (!nodesize)
293 nodesize = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size));
294
214 for(i = 0; i != items_node->length; ++i) 295 for(i = 0; i != items_node->length; ++i)
215 { 296 {
216 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[i]; 297 layout_item = (Efl_Ui_List_LayoutItem *)items_node->pointers[i];
217 DBG("layout_do first %d count %d", pd->first, pd->count); 298 DBG("layout_do first %d count %d", pd->first, pd->count);
218 /* EINA_SAFETY_ON_NULL_RETURN(items); */ 299 EINA_SAFETY_ON_NULL_RETURN(layout_item);
219 300
220 // cache size of new items 301 // cache size of new items
221 size = eina_hash_find(pd->size_information, &layout_item); 302 size = eina_hash_find(pd->size_information, &layout_item);
222 if(!size) 303 if(!size)
223 { 304 {
305 Eina_Bool realized = EINA_FALSE;
224 if(!layout_item->layout) 306 if(!layout_item->layout)
225 { 307 {
226 DBG("no layout, realizing"); 308 DBG("no layout, realizing");
@@ -228,6 +310,7 @@ _calc_size_job(void *data)
228 } 310 }
229 else 311 else
230 { 312 {
313 realized = EINA_TRUE;
231 DBG("already realized"); 314 DBG("already realized");
232 /* if(!layout_item->layout) */ 315 /* if(!layout_item->layout) */
233 /* { */ 316 /* { */
@@ -242,12 +325,18 @@ _calc_size_job(void *data)
242 if(min.w && min.h) 325 if(min.w && min.h)
243 { 326 {
244 //DBG("size was calculated"); 327 //DBG("size was calculated");
245 _item_min_calc(pd, layout_item->layout, size, min); 328 _item_min_calc(pd, layout_item->layout, size, min, nodesize);
329 }
330
331 if (realized)
332 {
333// Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data));
334// cb_data->pd = pd;
335// cb_data->size = size;
336// evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
246 } 337 }
247 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data)); 338 else
248 cb_data->pd = pd; 339 efl_ui_list_model_unrealize(pd->modeler, layout_item);
249 cb_data->size = size;
250 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
251 } 340 }
252 } 341 }
253 if ( (ecore_time_get() - start_time ) > 0.01 ) 342 if ( (ecore_time_get() - start_time ) > 0.01 )
@@ -260,7 +349,6 @@ _calc_size_job(void *data)
260 } 349 }
261 } 350 }
262 pd->calc_progress = 0; 351 pd->calc_progress = 0;
263 pd->recalc = EINA_FALSE;
264 pd->calc_job = NULL; 352 pd->calc_job = NULL;
265 353
266 _efl_ui_list_relayout_layout_do(pd); 354 _efl_ui_list_relayout_layout_do(pd);
@@ -284,7 +372,6 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED
284 return; 372 return;
285 373
286 pd->count_total = 0; 374 pd->count_total = 0;
287
288 if (pd->count_future) 375 if (pd->count_future)
289 { 376 {
290 efl_future_cancel(pd->count_future); 377 efl_future_cancel(pd->count_future);
@@ -304,10 +391,10 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_model_set(Eo *obj EINA_UNUSED
304 efl_ref(pd->model); 391 efl_ref(pd->model);
305 pd->count_future = efl_model_children_count_get(pd->model); 392 pd->count_future = efl_model_children_count_get(pd->model);
306 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd); 393 efl_future_then(pd->count_future, &_count_then, &_count_error, NULL, pd);
394 //_initilize(obj, pd, pd->modeler);
307 } 395 }
308} 396}
309 397
310
311static void 398static void
312_efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd) 399_efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
313{ 400{
@@ -513,10 +600,10 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
513 600
514 /* layout_item->x = x; */ 601 /* layout_item->x = x; */
515 /* layout_item->y = y; */ 602 /* layout_item->y = y; */
516 } /* if (size) end */ 603 } /* if (size) end */
517 if (pd->calc_progress && i > pd->calc_progress) 604 if (pd->calc_progress && i > pd->calc_progress)
518 return; 605 return;
519 } 606 }
520 } /* EINA ACCESSOR FOREACH END */ 607 } /* EINA ACCESSOR FOREACH END */
521 608
522 if (!pd->calc_progress) 609 if (!pd->calc_progress)
@@ -545,7 +632,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
545 pd->nodes = nodes; 632 pd->nodes = nodes;
546 633
547 pop = eina_hash_population(pd->size_information); 634 pop = eina_hash_population(pd->size_information);
548 if (pd->recalc || (pd->first + pd->count) > pop || pd->count_total > pop) 635 if (pd->recalc || (pd->first + pd->count) > pop) // || pd->count_total > pop)
549 { 636 {
550 // cache size of new items 637 // cache size of new items
551 pd->calc_progress = 0; 638 pd->calc_progress = 0;