From 939b0f1a9cc149e0b5090d3733e473f5edf5214f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 5 Dec 2019 18:54:10 -0800 Subject: [PATCH] evas: avoid unecessary Eina_Cow GC during image destruction. If the stretch zone are NULL to start with, there is no reason to modify them and this should avoid us a trip to the GC. Reviewed-by: Marcel Hollerbach Differential Revision: https://phab.enlightenment.org/D10816 --- src/lib/evas/canvas/evas_object_image.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index 192c4285d5..fa3a4a8462 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -753,18 +753,22 @@ _efl_canvas_image_internal_efl_gfx_image_stretch_region_set(Eo *eo_obj, Evas_Ima // we do change it, we have to make sure nobody is accessing them anymore by // blocking rendering. evas_object_async_block(obj); - EINA_COW_IMAGE_STATE_WRITE_BEGIN(pd, state_write) - { - if (state_write->free_stretch) free(state_write->stretch.horizontal.region); - state_write->stretch.horizontal.region = NULL; + if (pd->cur->stretch.horizontal.region || + pd->cur->stretch.vertical.region) + { + EINA_COW_IMAGE_STATE_WRITE_BEGIN(pd, state_write) + { + if (state_write->free_stretch) free(state_write->stretch.horizontal.region); + state_write->stretch.horizontal.region = NULL; - if (state_write->free_stretch) free(state_write->stretch.vertical.region); - state_write->stretch.vertical.region = NULL; + if (state_write->free_stretch) free(state_write->stretch.vertical.region); + state_write->stretch.vertical.region = NULL; - state_write->free_stretch = EINA_FALSE; - state_write->stretch_loaded = EINA_FALSE; - } - EINA_COW_IMAGE_STATE_WRITE_END(pd, state_write); + state_write->free_stretch = EINA_FALSE; + state_write->stretch_loaded = EINA_FALSE; + } + EINA_COW_IMAGE_STATE_WRITE_END(pd, state_write); + } if (!horizontal && !vertical) return 0; if (!horizontal || !vertical) goto on_error;