summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2020-03-10 09:27:30 -0400
committerMike Blumenkrantz <zmike@samsung.com>2020-03-10 09:28:01 -0400
commit78b9b23a62668fe9f0479b1ff4d25adc932e3040 (patch)
treef934a22494c7156f8c08f7d6f7e454f6fd406f88
parent2747c84ec159dff12c0854c34f20dd662bcbe7b3 (diff)
evas.image: add evas_object_image_animated_frame_getdevs/zmike/wip
this adds an api for getting the current frame of an animation Differential Revision: https://phab.enlightenment.org/D11455
-rw-r--r--src/lib/evas/Evas_Legacy.h19
-rw-r--r--src/lib/evas/canvas/efl_canvas_image.c8
-rw-r--r--src/lib/evas/canvas/evas_image_legacy.c7
-rw-r--r--src/lib/evas/include/evas_private.h1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c16
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c13
6 files changed, 64 insertions, 0 deletions
diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h
index 78ca7df9ec..eb8850d3fc 100644
--- a/src/lib/evas/Evas_Legacy.h
+++ b/src/lib/evas/Evas_Legacy.h
@@ -4930,6 +4930,7 @@ EAPI Eina_Bool evas_object_image_animated_get(const Eo *obj);
4930 * @ref evas_object_image_animated_loop_type_get, 4930 * @ref evas_object_image_animated_loop_type_get,
4931 * @ref evas_object_image_animated_loop_count_get, 4931 * @ref evas_object_image_animated_loop_count_get,
4932 * @ref evas_object_image_animated_frame_duration_get. 4932 * @ref evas_object_image_animated_frame_duration_get.
4933 * @ref evas_object_image_animated_frame_get.
4933 * 4934 *
4934 * @param[in] frame_index The index of current frame. 4935 * @param[in] frame_index The index of current frame.
4935 * 4936 *
@@ -4938,6 +4939,24 @@ EAPI Eina_Bool evas_object_image_animated_get(const Eo *obj);
4938EAPI void evas_object_image_animated_frame_set(Evas_Object *obj, int frame_index); 4939EAPI void evas_object_image_animated_frame_set(Evas_Object *obj, int frame_index);
4939 4940
4940/** 4941/**
4942 * @brief Get the frame to current frame of an image object.
4943 *
4944 * This returns image object's current frame.
4945 *
4946 * See also @ref evas_object_image_animated_get,
4947 * @ref evas_object_image_animated_frame_count_get,
4948 * @ref evas_object_image_animated_loop_type_get,
4949 * @ref evas_object_image_animated_loop_count_get,
4950 * @ref evas_object_image_animated_frame_duration_get.
4951 * @ref evas_object_image_animated_frame_set.
4952 *
4953 * @param[in] frame_index The index of current frame.
4954 *
4955 * @since 1.24
4956 */
4957EAPI int evas_object_image_animated_frame_get(Evas_Object *obj);
4958
4959/**
4941 * @brief Get the total number of frames of the image object. 4960 * @brief Get the total number of frames of the image object.
4942 * 4961 *
4943 * This returns total number of frames the image object supports (if animated). 4962 * This returns total number of frames the image object supports (if animated).
diff --git a/src/lib/evas/canvas/efl_canvas_image.c b/src/lib/evas/canvas/efl_canvas_image.c
index d45efcbf73..822c94600e 100644
--- a/src/lib/evas/canvas/efl_canvas_image.c
+++ b/src/lib/evas/canvas/efl_canvas_image.c
@@ -40,6 +40,7 @@ _evas_image_file_load(Eo *eo_obj, Evas_Image_Data *o)
40 const Eina_File *f = efl_file_mmap_get(eo_obj); 40 const Eina_File *f = efl_file_mmap_get(eo_obj);
41 const char *key = efl_file_key_get(eo_obj); 41 const char *key = efl_file_key_get(eo_obj);
42 int load_error; 42 int load_error;
43 int frame_index;
43 44
44 if (!o->skip_head) 45 if (!o->skip_head)
45 EINA_SAFETY_ON_NULL_RETURN_VAL(f, EINA_FALSE); 46 EINA_SAFETY_ON_NULL_RETURN_VAL(f, EINA_FALSE);
@@ -59,6 +60,13 @@ _evas_image_file_load(Eo *eo_obj, Evas_Image_Data *o)
59 o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &load_error, &lo); 60 o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &load_error, &lo);
60 else 61 else
61 o->engine_data = ENFN->image_load(ENC, efl_file_get(eo_obj), o->cur->key, &load_error, &lo); 62 o->engine_data = ENFN->image_load(ENC, efl_file_get(eo_obj), o->cur->key, &load_error, &lo);
63
64 if (_evas_image_animated_get(eo_obj))
65 {
66 frame_index = ENFN->image_animated_frame_get(ENC, o->engine_data);
67 _evas_image_animated_frame_set(eo_obj, frame_index);
68 }
69
62 o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error); 70 o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error);
63 o->buffer_data_set = EINA_FALSE; 71 o->buffer_data_set = EINA_FALSE;
64 _evas_image_done_set(eo_obj, obj, o); 72 _evas_image_done_set(eo_obj, obj, o);
diff --git a/src/lib/evas/canvas/evas_image_legacy.c b/src/lib/evas/canvas/evas_image_legacy.c
index 2702b31f5e..12d53a4a10 100644
--- a/src/lib/evas/canvas/evas_image_legacy.c
+++ b/src/lib/evas/canvas/evas_image_legacy.c
@@ -271,6 +271,13 @@ evas_object_image_animated_frame_set(Evas_Object *obj, int frame_index)
271} 271}
272 272
273EAPI int 273EAPI int
274evas_object_image_animated_frame_get(Evas_Object *obj)
275{
276 EVAS_IMAGE_API(obj, 0);
277 return _evas_image_animated_frame_get(obj);
278}
279
280EAPI int
274evas_object_image_animated_frame_count_get(const Evas_Object *obj) 281evas_object_image_animated_frame_count_get(const Evas_Object *obj)
275{ 282{
276 EVAS_IMAGE_API(obj, 0); 283 EVAS_IMAGE_API(obj, 0);
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index f0f209d3e3..3aa70bf3f8 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1478,6 +1478,7 @@ struct _Evas_Func
1478 int (*image_animated_loop_count_get) (void *engine, void *image); 1478 int (*image_animated_loop_count_get) (void *engine, void *image);
1479 double (*image_animated_frame_duration_get) (void *engine, void *image, int start_frame, int frame_num); 1479 double (*image_animated_frame_duration_get) (void *engine, void *image, int start_frame, int frame_num);
1480 Eina_Bool (*image_animated_frame_set) (void *engine, void *image, int frame_index); 1480 Eina_Bool (*image_animated_frame_set) (void *engine, void *image, int frame_index);
1481 int (*image_animated_frame_get) (void *engine, void *image);
1481 1482
1482 /* max size query */ 1483 /* max size query */
1483 void (*image_max_size_get) (void *engine, int *maxw, int *maxh); 1484 void (*image_max_size_get) (void *engine, int *maxw, int *maxh);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 3f4c36c73b..e73c486073 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -2158,6 +2158,21 @@ eng_image_animated_frame_set(void *engine EINA_UNUSED, void *image, int frame_in
2158 return EINA_TRUE; 2158 return EINA_TRUE;
2159} 2159}
2160 2160
2161static int
2162eng_image_animated_frame_get(void *engine EINA_UNUSED, void *image)
2163{
2164 Evas_GL_Image *gim = image;
2165 Image_Entry *im;
2166
2167 if (!gim) return EINA_FALSE;
2168 im = (Image_Entry *)gim->im;
2169 if (!im) return EINA_FALSE;
2170
2171 if (!im->animated.animated) return EINA_FALSE;
2172
2173 return im->animated.cur_frame;
2174}
2175
2161static Eina_Bool 2176static Eina_Bool
2162eng_image_can_region_get(void *engine EINA_UNUSED, void *image) 2177eng_image_can_region_get(void *engine EINA_UNUSED, void *image)
2163{ 2178{
@@ -3308,6 +3323,7 @@ module_open(Evas_Module *em)
3308 ORD(image_animated_loop_count_get); 3323 ORD(image_animated_loop_count_get);
3309 ORD(image_animated_frame_duration_get); 3324 ORD(image_animated_frame_duration_get);
3310 ORD(image_animated_frame_set); 3325 ORD(image_animated_frame_set);
3326 ORD(image_animated_frame_get);
3311 3327
3312 ORD(image_max_size_get); 3328 ORD(image_max_size_get);
3313 3329
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 674e698bc2..a56708fc98 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -2915,6 +2915,18 @@ eng_image_animated_frame_set(void *data EINA_UNUSED, void *image, int frame_inde
2915 return EINA_TRUE; 2915 return EINA_TRUE;
2916} 2916}
2917 2917
2918static int
2919eng_image_animated_frame_get(void *data EINA_UNUSED, void *image)
2920{
2921 Image_Entry *im;
2922
2923 if (!image) return EINA_FALSE;
2924 im = image;
2925 if (!im->animated.animated) return EINA_FALSE;
2926
2927 return im->animated.cur_frame;
2928}
2929
2918static void 2930static void
2919_draw_thread_multi_font_draw(void *data) 2931_draw_thread_multi_font_draw(void *data)
2920{ 2932{
@@ -4777,6 +4789,7 @@ static Evas_Func func =
4777 eng_image_animated_loop_count_get, 4789 eng_image_animated_loop_count_get,
4778 eng_image_animated_frame_duration_get, 4790 eng_image_animated_frame_duration_get,
4779 eng_image_animated_frame_set, 4791 eng_image_animated_frame_set,
4792 eng_image_animated_frame_get,
4780 NULL, // image_max_size_get 4793 NULL, // image_max_size_get
4781 eng_multi_font_draw, 4794 eng_multi_font_draw,
4782 eng_pixel_alpha_get, 4795 eng_pixel_alpha_get,