summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-11-01 18:28:11 -0200
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-11-15 17:06:45 +0900
commitca742c144d16e62470b4ea5ae88655d64a3fc383 (patch)
tree2698510af43c767e85fc6d16b82b659bb5407679
parent898df348d94a2221373ded02e52fc90b824cda34 (diff)
elm: split size calculation in precise layouter
-rw-r--r--src/examples/elementary/efl_ui_list_example_1.c2
-rw-r--r--src/lib/elementary/efl_ui_list_precise_layouter.c96
2 files changed, 58 insertions, 40 deletions
diff --git a/src/examples/elementary/efl_ui_list_example_1.c b/src/examples/elementary/efl_ui_list_example_1.c
index 7ad3ac7c1b..7c181b8b3f 100644
--- a/src/examples/elementary/efl_ui_list_example_1.c
+++ b/src/examples/elementary/efl_ui_list_example_1.c
@@ -12,7 +12,7 @@
12#include <Eio.h> 12#include <Eio.h>
13#include <stdio.h> 13#include <stdio.h>
14 14
15#define NUM_ITEMS 200 15#define NUM_ITEMS 400
16 16
17const char *styles[] = { 17const char *styles[] = {
18 "odd", 18 "odd",
diff --git a/src/lib/elementary/efl_ui_list_precise_layouter.c b/src/lib/elementary/efl_ui_list_precise_layouter.c
index 63a43bffb4..67a21c874c 100644
--- a/src/lib/elementary/efl_ui_list_precise_layouter.c
+++ b/src/lib/elementary/efl_ui_list_precise_layouter.c
@@ -30,8 +30,9 @@ typedef struct _Efl_Ui_List_Precise_Layouter_Data
30 Ecore_Job *calc_job; 30 Ecore_Job *calc_job;
31 Eina_Accessor *nodes; 31 Eina_Accessor *nodes;
32 int first; 32 int first;
33 int count; 33 unsigned int count;
34 int count_total; 34 unsigned int count_total;
35 unsigned int calc_progress;
35} Efl_Ui_List_Precise_Layouter_Data; 36} Efl_Ui_List_Precise_Layouter_Data;
36 37
37typedef struct _Efl_Ui_List_Precise_Layouter_Size 38typedef struct _Efl_Ui_List_Precise_Layouter_Size
@@ -200,19 +201,21 @@ _calc_size_job(void *data)
200 Efl_Ui_List_SegArray_Node *items_node; 201 Efl_Ui_List_SegArray_Node *items_node;
201 Efl_Ui_List_LayoutItem *layout_item; 202 Efl_Ui_List_LayoutItem *layout_item;
202 Eo *obj = data; 203 Eo *obj = data;
203 int i, j; 204 int i;
205 double start_time = ecore_time_get();
204 206
205 DBG(" >>>>> RECALC JOB <<<<<<< \n"); 207 DBG(" >>>>> RECALC JOB <<<<<<< \n");
206 EINA_SAFETY_ON_NULL_RETURN(data); 208 EINA_SAFETY_ON_NULL_RETURN(data);
207 pd = efl_data_scope_get(obj, MY_CLASS); 209 pd = efl_data_scope_get(obj, MY_CLASS);
208 if (EINA_UNLIKELY(!pd)) return; 210 if (EINA_UNLIKELY(!pd)) return;
209 211
210 EINA_ACCESSOR_FOREACH(pd->nodes, i, items_node) 212 while (eina_accessor_data_get(pd->nodes, pd->calc_progress, (void **)&items_node))
211 { 213 {
214 pd->calc_progress++;
212 DBG("node first %d", items_node->first); 215 DBG("node first %d", items_node->first);
213 for(j = 0; j != items_node->length; ++j) 216 for(i = 0; i != items_node->length; ++i)
214 { 217 {
215 layout_item = items_node->pointers[j]; 218 layout_item = items_node->pointers[i];
216 DBG("layout_do first %d count %d", pd->first, pd->count); 219 DBG("layout_do first %d count %d", pd->first, pd->count);
217 /* EINA_SAFETY_ON_NULL_RETURN(items); */ 220 /* EINA_SAFETY_ON_NULL_RETURN(items); */
218 221
@@ -220,37 +223,45 @@ _calc_size_job(void *data)
220 size = eina_hash_find(pd->size_information, &layout_item); 223 size = eina_hash_find(pd->size_information, &layout_item);
221 if(!size) 224 if(!size)
222 { 225 {
223 if(!layout_item->layout) 226 if(!layout_item->layout)
224 { 227 {
225 DBG("no layout, realizing"); 228 DBG("no layout, realizing");
226 efl_ui_list_model_realize(pd->modeler, layout_item); 229 efl_ui_list_model_realize(pd->modeler, layout_item);
227 } 230 }
228 else 231 else
229 { 232 {
230 DBG("already realized"); 233 DBG("already realized");
231 /* if(!layout_item->layout) */ 234 /* if(!layout_item->layout) */
232 /* { */ 235 /* { */
233 /* // error */ 236 /* // error */
234 /* continue; */ 237 /* continue; */
235 /* } */ 238 /* } */
236 } 239 }
237 240
238 size = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size)); 241 size = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Size));
239 eina_hash_add(pd->size_information, &layout_item, size); 242 eina_hash_add(pd->size_information, &layout_item, size);
240 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(layout_item->layout); 243 Eina_Size2D min = efl_gfx_size_hint_combined_min_get(layout_item->layout);
241 if(min.w && min.h) 244 if(min.w && min.h)
242 { 245 {
243 // DBG("size was calculated"); 246 //DBG("size was calculated");
244 _item_min_calc(pd, layout_item->layout, size, min); 247 _item_min_calc(pd, layout_item->layout, size, min);
245 } 248 }
246 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data)); 249 Efl_Ui_List_Precise_Layouter_Callback_Data *cb_data = calloc(1, sizeof(Efl_Ui_List_Precise_Layouter_Callback_Data));
247 cb_data->pd = pd; 250 cb_data->pd = pd;
248 cb_data->size = size; 251 cb_data->size = size;
249 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data); 252 evas_object_event_callback_add(layout_item->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_item_size_hint_change, cb_data);
253 if ( (ecore_time_get() - start_time ) > 0.01 )
254 {
255 DBG(" <><><> RECALC JOB SPLIT <><><> ");
256 ecore_job_del(pd->calc_job);
257 pd->calc_job = ecore_job_add(_calc_size_job, obj);
258 _efl_ui_list_relayout_layout_do(pd);
259 return;
260 }
250 } 261 }
251 } 262 }
252 } 263 }
253 264 pd->calc_progress = 0;
254 pd->recalc = EINA_FALSE; 265 pd->recalc = EINA_FALSE;
255 pd->calc_job = NULL; 266 pd->calc_job = NULL;
256 267
@@ -306,12 +317,13 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
306 Evas_Coord ow, oh, want, scr_x, scr_y; 317 Evas_Coord ow, oh, want, scr_x, scr_y;
307 int boxx, boxy, boxw, boxh, length, pad, extra = 0, rounding = 0; 318 int boxx, boxy, boxw, boxh, length, pad, extra = 0, rounding = 0;
308 int boxl = 0, boxr = 0, boxt = 0, boxb = 0; 319 int boxl = 0, boxr = 0, boxt = 0, boxb = 0;
309 int i = 0, j = 0;
310 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 }; 320 double cur_pos = 0, scale, box_align[2], weight[2] = { 0, 0 };
311 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE }; 321 Eina_Bool box_fill[2] = { EINA_FALSE, EINA_FALSE };
312 Efl_Ui_List_Precise_Layouter_Size* size; 322 Efl_Ui_List_Precise_Layouter_Size* size;
313 Efl_Ui_List_LayoutItem* layout_item; 323 Efl_Ui_List_LayoutItem* layout_item;
314 Efl_Ui_List_SegArray_Node *items_node; 324 Efl_Ui_List_SegArray_Node *items_node;
325 unsigned int i;
326 int j = 0;
315 327
316 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh); 328 evas_object_geometry_get(pd->modeler, &boxx, &boxy, &boxw, &boxh);
317 efl_gfx_size_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb); 329 efl_gfx_size_hint_margin_get(pd->modeler, &boxl, &boxr, &boxt, &boxb);
@@ -504,11 +516,16 @@ _efl_ui_list_relayout_layout_do(Efl_Ui_List_Precise_Layouter_Data *pd)
504 /* layout_item->x = x; */ 516 /* layout_item->x = x; */
505 /* layout_item->y = y; */ 517 /* layout_item->y = y; */
506 } /* if (size) end */ 518 } /* if (size) end */
519 if (pd->calc_progress && i > pd->calc_progress)
520 return;
507 } 521 }
508 } /* EINA ACCESSOR FOREACH END */ 522 } /* EINA ACCESSOR FOREACH END */
509 523
510 eina_accessor_free(pd->nodes); 524 if (!pd->calc_progress)
511 pd->nodes = NULL; 525 {
526 eina_accessor_free(pd->nodes);
527 pd->nodes = NULL;
528 }
512} 529}
513 530
514EOLIAN static void 531EOLIAN static void
@@ -516,7 +533,7 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
516 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd 533 (Eo *obj EINA_UNUSED, Efl_Ui_List_Precise_Layouter_Data *pd
517 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes) 534 , Efl_Ui_List_Model *modeler, int first, int count, Eina_Accessor *nodes)
518{ 535{
519 int pop; 536 unsigned int pop;
520 EINA_SAFETY_ON_NULL_RETURN(nodes); 537 EINA_SAFETY_ON_NULL_RETURN(nodes);
521 538
522 _initilize(obj, pd, modeler); 539 _initilize(obj, pd, modeler);
@@ -530,9 +547,10 @@ _efl_ui_list_precise_layouter_efl_ui_list_relayout_layout_do
530 pd->nodes = nodes; 547 pd->nodes = nodes;
531 548
532 pop = eina_hash_population(pd->size_information); 549 pop = eina_hash_population(pd->size_information);
533 if (pd->recalc || (first + count) > pop || pd->count_total > pop) 550 if (pd->recalc || (pd->first + pd->count) > pop || pd->count_total > pop)
534 { 551 {
535 // cache size of new items 552 // cache size of new items
553 pd->calc_progress = 0;
536 ecore_job_del(pd->calc_job); 554 ecore_job_del(pd->calc_job);
537 pd->calc_job = ecore_job_add(_calc_size_job, obj); 555 pd->calc_job = ecore_job_add(_calc_size_job, obj);
538 return; 556 return;