From: Enlightenment S. <no-...@en...> - 2012-10-25 07:28:35
|
Log: e: don't drop cache if icon is animated. We want to use the scale cache and drop the source icon for all static icon on screen. But for the few of them that do resize and animate, we need to keep that data or it will slow a us down a lot. So now we play nicely with our SCALE_HINT. Author: cedric Date: 2012-10-25 00:28:24 -0700 (Thu, 25 Oct 2012) New Revision: 78419 Trac: http://trac.enlightenment.org/e/changeset/78419 Modified: trunk/e/src/bin/e_icon.c Modified: trunk/e/src/bin/e_icon.c =================================================================== --- trunk/e/src/bin/e_icon.c 2012-10-25 07:17:10 UTC (rev 78418) +++ trunk/e/src/bin/e_icon.c 2012-10-25 07:28:24 UTC (rev 78419) @@ -12,6 +12,8 @@ Evas_Object *obj; Evas_Object *eventarea; Ecore_Timer *timer; + Ecore_Timer *guessing_animation; + double last_resize; int size; int frame, frame_count; const char *fdo; @@ -19,6 +21,7 @@ unsigned char scale_up : 1; unsigned char preload : 1; unsigned char loading : 1; + unsigned char animated : 1; Eina_Bool edje : 1; #ifdef USE_ICON_CACHE const char *file; @@ -171,7 +174,9 @@ eina_stringshare_replace(&sd->file, NULL); #endif sd->obj = evas_object_image_add(evas_object_evas_get(obj)); - evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC); + if (!sd->animated) + evas_object_image_scale_hint_set(sd->obj, + EVAS_IMAGE_SCALE_HINT_STATIC); evas_object_smart_member_add(sd->obj, obj); evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED, _e_icon_preloaded, obj); @@ -247,6 +252,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; @@ -317,6 +324,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; @@ -361,6 +370,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_TRUE; @@ -391,6 +402,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_TRUE; @@ -421,6 +434,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; @@ -469,6 +484,8 @@ if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); + sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; @@ -831,6 +848,7 @@ if (sd->file) eina_stringshare_del(sd->file); #endif if (sd->timer) ecore_timer_del(sd->timer); + if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); evas_object_smart_data_set(obj, NULL); memset(sd, 0, sizeof(*sd)); free(sd); @@ -848,6 +866,28 @@ _e_icon_smart_reconfigure(sd); } +static Eina_Bool +_e_icon_guess_anim(void *data) +{ + E_Smart_Data *sd = data; + double t = ecore_loop_time_get(); + + if (t - sd->last_resize < 0.2) + { + evas_object_image_scale_hint_set(sd->obj, + EVAS_IMAGE_SCALE_HINT_DYNAMIC); + sd->animated = EINA_TRUE; + } + else + { + evas_object_image_scale_hint_set(sd->obj, + EVAS_IMAGE_SCALE_HINT_STATIC); + } + + sd->guessing_animation = NULL; + return EINA_FALSE; +} + static void _e_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) { @@ -875,6 +915,19 @@ } } + if (((sd->loading && sd->preload) || + (!sd->loading && !sd->preload)) + && !sd->animated) + { + evas_object_image_scale_hint_set(sd->obj, + EVAS_IMAGE_SCALE_HINT_DYNAMIC); + if (!sd->guessing_animation) + sd->guessing_animation = ecore_timer_add(0.3, + _e_icon_guess_anim, + sd); + } + + sd->last_resize = ecore_loop_time_get(); _e_icon_smart_reconfigure(sd); } |