summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-17 13:12:23 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-07-19 10:55:03 -0700
commit3ba31a1f5c4a5d63c66b7c9f553d1a09305d5eae (patch)
tree7c87218a738a11b243952ad73db680a33cc7ae72
parent1dd5feb22ff10ab955c5aedf02513f76412b4ce3 (diff)
efl_ui/table: optimize position_set operations with tables
if a table is moved and no other changes are made to the table or its children, e.g., if the table is scrolled, then there is no need to loop over the table's items repeatedly in order to accurately calculate all the item geometries and positions. instead, simply apply an offset from the last table calc position to each child item and handle the position changes more transparently this yields roughly a 12% perf improvement to the 'efl.ui.scroller simple2' test and brings rendering up to nearly 60fps Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9346
-rw-r--r--src/lib/elementary/efl_ui_table.c5
-rw-r--r--src/lib/elementary/efl_ui_table_layout.c31
-rw-r--r--src/lib/elementary/efl_ui_table_private.h2
3 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/elementary/efl_ui_table.c b/src/lib/elementary/efl_ui_table.c
index fd7ee11e4c..6655573231 100644
--- a/src/lib/elementary/efl_ui_table.c
+++ b/src/lib/elementary/efl_ui_table.c
@@ -174,7 +174,7 @@ EOLIAN static void
174_efl_ui_table_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Table_Data *_pd EINA_UNUSED, Eina_Size2D sz) 174_efl_ui_table_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Table_Data *_pd EINA_UNUSED, Eina_Size2D sz)
175{ 175{
176 efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz); 176 efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
177 efl_canvas_group_change(obj); 177 efl_pack_layout_request(obj);
178} 178}
179 179
180EOLIAN static void 180EOLIAN static void
@@ -508,8 +508,9 @@ _efl_ui_table_efl_pack_unpack_all(Eo *obj, Efl_Ui_Table_Data *pd)
508} 508}
509 509
510EOLIAN static void 510EOLIAN static void
511_efl_ui_table_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED) 511_efl_ui_table_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Table_Data *pd)
512{ 512{
513 pd->full_recalc = EINA_TRUE;
513 efl_canvas_group_need_recalculate_set(obj, EINA_TRUE); 514 efl_canvas_group_need_recalculate_set(obj, EINA_TRUE);
514} 515}
515 516
diff --git a/src/lib/elementary/efl_ui_table_layout.c b/src/lib/elementary/efl_ui_table_layout.c
index 013a35a6cd..a0307f52e0 100644
--- a/src/lib/elementary/efl_ui_table_layout.c
+++ b/src/lib/elementary/efl_ui_table_layout.c
@@ -218,6 +218,27 @@ _efl_ui_table_regular_item_size_get(Table_Calc *table_calc, Item_Calc *item, Ein
218 - item->hints[axis].margin[0] - item->hints[axis].margin[1]; 218 - item->hints[axis].margin[0] - item->hints[axis].margin[1];
219} 219}
220 220
221/* this function performs a simplified layout when the table has changed position
222 * but no other changes have occurred, e.g., when a table is being scrolled
223 */
224static void
225_efl_ui_table_layout_simple(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
226{
227 Table_Item *ti;
228 Eina_Position2D pos = efl_gfx_entity_position_get(ui_table);
229
230 EINA_INLIST_FOREACH(EINA_INLIST_GET(pd->items), ti)
231 {
232 Eina_Position2D child_pos = efl_gfx_entity_position_get(ti->object);
233
234 efl_gfx_entity_position_set(ti->object,
235 EINA_POSITION2D(pos.x - pd->last_pos.x + child_pos.x,
236 pos.y - pd->last_pos.y + child_pos.y));
237 }
238 pd->last_pos = pos;
239 efl_event_callback_call(ui_table, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
240}
241
221void 242void
222_efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd) 243_efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
223{ 244{
@@ -231,14 +252,19 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
231 Eina_Bool do_free; 252 Eina_Bool do_free;
232 253
233 count = pd->count; 254 count = pd->count;
234
235 if (!count) 255 if (!count)
236 { 256 {
237 efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0)); 257 efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0));
238 return; 258 return;
239 } 259 }
240 260 if (!pd->full_recalc)
261 {
262 _efl_ui_table_layout_simple(ui_table, pd);
263 return;
264 }
241 _efl_ui_container_layout_init(ui_table, table_calc.layout_calc); 265 _efl_ui_container_layout_init(ui_table, table_calc.layout_calc);
266 pd->last_pos.x = table_calc.layout_calc[0].pos - table_calc.layout_calc[0].margin[0];
267 pd->last_pos.y = table_calc.layout_calc[1].pos - table_calc.layout_calc[1].margin[0];
242 268
243 table_calc.want[0] = table_calc.want[1] = 0; 269 table_calc.want[0] = table_calc.want[1] = 0;
244 table_calc.weight_sum[0] = table_calc.weight_sum[1] = 0; 270 table_calc.weight_sum[0] = table_calc.weight_sum[1] = 0;
@@ -391,6 +417,7 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
391 + (table_calc.layout_calc[1].pad * 417 + (table_calc.layout_calc[1].pad *
392 table_calc.cell_calc[1][rows - 1].index); 418 table_calc.cell_calc[1][rows - 1].index);
393 419
420 pd->full_recalc = EINA_FALSE;
394 efl_gfx_hint_size_restricted_min_set(ui_table, 421 efl_gfx_hint_size_restricted_min_set(ui_table,
395 EINA_SIZE2D(table_calc.want[0], 422 EINA_SIZE2D(table_calc.want[0],
396 table_calc.want[1])); 423 table_calc.want[1]));
diff --git a/src/lib/elementary/efl_ui_table_private.h b/src/lib/elementary/efl_ui_table_private.h
index ff261f1fae..47d1cc4cb7 100644
--- a/src/lib/elementary/efl_ui_table_private.h
+++ b/src/lib/elementary/efl_ui_table_private.h
@@ -44,11 +44,13 @@ struct _Efl_Ui_Table_Data
44 struct { 44 struct {
45 double h, v; 45 double h, v;
46 } align; 46 } align;
47 Eina_Position2D last_pos;
47 Eina_Bool cols_recalc : 1; 48 Eina_Bool cols_recalc : 1;
48 Eina_Bool rows_recalc : 1; 49 Eina_Bool rows_recalc : 1;
49 Eina_Bool linear_recalc : 1; 50 Eina_Bool linear_recalc : 1;
50 Eina_Bool homogeneoush : 1; 51 Eina_Bool homogeneoush : 1;
51 Eina_Bool homogeneousv : 1; 52 Eina_Bool homogeneousv : 1;
53 Eina_Bool full_recalc : 1; //whether to force full recalc
52}; 54};
53 55
54struct _Table_Item_Iterator 56struct _Table_Item_Iterator