devilhorns pushed a commit to branch master.

http://git.enlightenment.org/apps/express.git/commit/?id=91a981dc00ecc8852dab6a4e286e170749b5125b

commit 91a981dc00ecc8852dab6a4e286e170749b5125b
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Mon Aug 3 13:07:34 2015 -0400

    express: Add support for animated gifs
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/bin/media.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/bin/media.c b/src/bin/media.c
index 619470e..dc38458 100644
--- a/src/bin/media.c
+++ b/src/bin/media.c
@@ -26,6 +26,8 @@ struct _Media
    int tmpfd;
    int w, h, iw, ih, sw, sh;
    int mode, resizes;
+   int frame, frame_num, loops;
+   Ecore_Timer *anim;
 
    Media_Type type;
 
@@ -54,6 +56,61 @@ _media_cb_img_preloaded(void *data, Evas *evas EINA_UNUSED, 
Evas_Object *obj EIN
    evas_object_show(sd->o_clip);
 }
 
+static Eina_Bool
+_img_cb_frame(void *data)
+{
+   Media *sd;
+   double t;
+   int frame;
+
+   if (!(sd = evas_object_smart_data_get(data))) return EINA_FALSE;
+   sd->frame++;
+   frame = ((sd->frame - 1) % sd->frame_num) + 1;
+   if ((sd->frame >= sd->frame_num) && (frame == 1))
+     {
+        int loops;
+
+        if (evas_object_image_animated_loop_type_get(sd->o_img) ==
+            EVAS_IMAGE_ANIMATED_HINT_NONE)
+          {
+             sd->anim = NULL;
+             return EINA_FALSE;
+          }
+
+        sd->loops++;
+        loops = evas_object_image_animated_loop_count_get(sd->o_img);
+        if (loops != 0)
+          {
+             if (loops < sd->loops)
+               {
+                  sd->anim = NULL;
+                  return EINA_FALSE;
+               }
+          }
+     }
+
+   evas_object_image_animated_frame_set(sd->o_img, frame);
+   t = evas_object_image_animated_frame_duration_get(sd->o_img, frame, 0);
+   ecore_timer_interval_set(sd->anim, t);
+
+   return EINA_TRUE;
+}
+
+static void
+_img_type_anim_handle(Evas_Object *obj)
+{
+   Media *sd;
+   double t;
+
+   if (!(sd = evas_object_smart_data_get(obj))) return;
+   if (!evas_object_image_animated_get(sd->o_img)) return;
+   sd->frame = 1;
+   sd->frame_num = evas_object_image_animated_frame_count_get(sd->o_img);
+   if (sd->frame_num < 2) return;
+   t = evas_object_image_animated_frame_duration_get(sd->o_img, sd->frame, 0);
+   sd->anim = ecore_timer_add(t, _img_cb_frame, obj);
+}
+
 static void 
 _img_type_init(Evas_Object *obj)
 {
@@ -71,7 +128,8 @@ _img_type_init(Evas_Object *obj)
    evas_object_image_file_set(sd->o_img, sd->realf, NULL);
    evas_object_image_size_get(sd->o_img, &sd->iw, &sd->ih);
    evas_object_image_preload(sd->o_img, EINA_FALSE);
-   /* TODO: anim handle */
+
+   _img_type_anim_handle(obj);
 }
 
 static void 

-- 


Reply via email to