From cc49c8ac64a358e8aa0bf8897abc6a5e4cf2c692 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 23 Aug 2019 12:48:16 -0700 Subject: [PATCH] elementary: leverage sizing information from model if available to avoid unecessary calc. With the new Efl unified infrastructure, we do delay a lot of the computation to finalize, by filling the object information before finalize we reduce unecessary computation. Reviewed-by: Mike Blumenkrantz Differential Revision: https://phab.enlightenment.org/D9948 --- src/lib/elementary/efl_ui_widget_factory.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c index c9d5759744..c65bda5847 100644 --- a/src/lib/elementary/efl_ui_widget_factory.c +++ b/src/lib/elementary/efl_ui_widget_factory.c @@ -72,12 +72,29 @@ static void _efl_ui_widget_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui_Widget_Factory_Data *pd EINA_UNUSED, Efl_Gfx_Entity *ui_view) { const Efl_Model *model; - Eina_Value *property; + Eina_Value *property, *width, *height; char *style; if (!pd->style) return ; model = efl_ui_view_model_get(ui_view); + + // Fetch min size from model if available to avoid recalculcating it + width = efl_model_property_get(model, "self.width"); + height = efl_model_property_get(model, "self.height"); + if (eina_value_type_get(width) != EINA_VALUE_TYPE_ERROR && + eina_value_type_get(height) != EINA_VALUE_TYPE_ERROR) + { + Eina_Size2D s; + + if (!eina_value_int_convert(width, &s.w)) s.w = 0; + if (!eina_value_int_convert(height, &s.h)) s.h = 0; + + efl_gfx_hint_size_min_set(ui_view, s); + } + eina_value_free(width); + eina_value_free(height); + // As we have already waited for the property to be ready, we should get the right style now property = efl_model_property_get(model, pd->style); if (!property) return ;