summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_table_layout.c
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 /src/lib/elementary/efl_ui_table_layout.c
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
Diffstat (limited to 'src/lib/elementary/efl_ui_table_layout.c')
-rw-r--r--src/lib/elementary/efl_ui_table_layout.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/lib/elementary/efl_ui_table_layout.c b/src/lib/elementary/efl_ui_table_layout.c
index 013a35a..a0307f5 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]));