From 4f95d2a1f41970d9a143afbd2ae2089144e4be96 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 2 Oct 2019 14:30:06 +0900 Subject: [PATCH] vg_common_json: Override value_provider list Summary: If value_provider is applied to Efl.Ui.Animation_View, it is passed as vector object. The passed value_provider list passes to Vg_File_Data. If there is a value_Provider list in Vg_File_Data, it apply the property to Lottie_Animation using lottie_animation_property_override api. Depends on D9874 Test Plan: ... Eo *vp = efl_add(EFL_GFX_VG_VALUE_PROVIDER_CLASS, p); efl_gfx_vg_value_provider_keypath_set(vp, "**"); efl_gfx_vg_value_provider_fill_color_set(vp, 100, 0 ,0 ,255); efl_ui_animation_view_value_provider_override(anim_view, vp); vp = efl_add(EFL_GFX_VG_VALUE_PROVIDER_CLASS, p); efl_gfx_vg_value_provider_keypath_set(vp, "**"); efl_gfx_vg_value_provider_stroke_width_set(vp, 50.0); efl_gfx_vg_value_provider_stroke_color_set(vp, 0, 255, 0, 100); efl_ui_animation_view_value_provider_override(anim_view, vp); ... Reviewers: Hermet, kimcinoo, smohanty Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9897 Change-Id: I1c9a257e86e54dc5fc5df5d0ced7a826e492cbaa --- src/lib/elementary/efl_ui_animation_view.c | 1 + src/lib/evas/canvas/efl_canvas_vg_object.c | 2 ++ src/lib/evas/include/evas_private.h | 1 + src/static_libs/vg_common/vg_common.h | 1 + src/static_libs/vg_common/vg_common_json.c | 55 ++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) diff --git a/src/lib/elementary/efl_ui_animation_view.c b/src/lib/elementary/efl_ui_animation_view.c index 4724733..5dbf819 100644 --- a/src/lib/elementary/efl_ui_animation_view.c +++ b/src/lib/elementary/efl_ui_animation_view.c @@ -741,6 +741,7 @@ _efl_ui_animation_view_value_provider_override(Eo *obj EINA_UNUSED, Efl_Ui_Anima efl_ref(value_provider); pd->vp_list = eina_list_append(pd->vp_list, value_provider); + efl_key_data_set(pd->vg, "_vg_value_providers", pd->vp_list); } EAPI Elm_Animation_View* diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.c b/src/lib/evas/canvas/efl_canvas_vg_object.c index 0c8e50b..660d1eb 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_object.c +++ b/src/lib/evas/canvas/efl_canvas_vg_object.c @@ -616,6 +616,8 @@ _cache_vg_entry_render(Evas_Object_Protected_Data *obj, h = size.h; } + if (pd->vg_entry->vfd) + pd->vg_entry->vfd->vp_list = efl_key_data_get(obj->object, "_vg_value_providers"); root = evas_cache_vg_tree_get(vg_entry, pd->frame_idx); if (!root) return; diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index adf8e8f..a801a20 100755 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1548,6 +1548,7 @@ struct _Vg_File_Data Vg_File_Anim_Data *anim_data; //only when animation supported. int ref; int w, h; //default size + Eina_List *vp_list; //Value providers. void *loader_data; //loader specific local data diff --git a/src/static_libs/vg_common/vg_common.h b/src/static_libs/vg_common/vg_common.h index 520fcdb..83f9224 100644 --- a/src/static_libs/vg_common/vg_common.h +++ b/src/static_libs/vg_common/vg_common.h @@ -7,6 +7,7 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" /****************************************************************************************** * SVG Compatible feature implementation diff --git a/src/static_libs/vg_common/vg_common_json.c b/src/static_libs/vg_common/vg_common_json.c index 3b3d114..5ad4150 100644 --- a/src/static_libs/vg_common/vg_common_json.c +++ b/src/static_libs/vg_common/vg_common_json.c @@ -443,6 +443,59 @@ _update_vg_tree(Efl_Canvas_Vg_Container *root, const LOTLayerNode *layer, int de } #endif +#ifdef BUILD_VG_LOADER_JSON +void +_value_provider_override(Vg_File_Data *vfd) +{ + Lottie_Animation *lot_anim = (Lottie_Animation *) vfd->loader_data; + + Eina_List *l; + Efl_Gfx_Vg_Value_Provider *vp; + EINA_LIST_FOREACH(vfd->vp_list, l, vp) + { + const char *keypath; + Efl_Gfx_Vg_Value_Provider_Change_Flag flag; + flag = efl_gfx_vg_value_provider_changed_flag_get(vp); + + if (flag & EFL_GFX_VG_VALUE_PROVIDER_CHANGE_FLAG_FILL_COLOR) + { + int r, g, b, a; + r = g = b = a = 0; + efl_gfx_vg_value_provider_fill_color_get(vp, &r, &g, &b, &a); + keypath = efl_gfx_vg_value_provider_keypath_get(vp); + + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, (char*)keypath, r / 255.0, g / 255.0, b / 255.0); + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_FILLOPACITY, (char*)keypath, (a / 255.0) * 100.0); + } + if (flag & EFL_GFX_VG_VALUE_PROVIDER_CHANGE_FLAG_STROKE_COLOR) + { + int r, g, b, a; + r = g = b = a = 0; + efl_gfx_vg_value_provider_stroke_color_get(vp, &r, &g, &b, &a); + keypath = efl_gfx_vg_value_provider_keypath_get(vp); + + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_STROKECOLOR, (char*)keypath, r / 255.0, g / 255.0, b / 255.0); + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_STROKEOPACITY, (char*)keypath, (a / 255.0) * 100.0); + } + if (flag & EFL_GFX_VG_VALUE_PROVIDER_CHANGE_FLAG_STROKE_WIDTH) + { + double w; + w = efl_gfx_vg_value_provider_stroke_width_get(vp); + keypath = efl_gfx_vg_value_provider_keypath_get(vp); + + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_STROKEWIDTH, (char*)keypath, w); + } + if (flag & EFL_GFX_VG_VALUE_PROVIDER_CHANGE_FLAG_TRANSFORM_MATRIX) + { + //TODO: When the lottie animation's transform property is implemented, + // the transform property override function have to added. + } + } +} + +#endif + + Eina_Bool vg_common_json_create_vg_node(Vg_File_Data *vfd) { @@ -450,6 +503,8 @@ vg_common_json_create_vg_node(Vg_File_Data *vfd) Lottie_Animation *lot_anim = (Lottie_Animation *) vfd->loader_data; if (!lot_anim) return EINA_FALSE; + if (vfd->vp_list) _value_provider_override(vfd); + unsigned int frame_num = (vfd->anim_data) ? vfd->anim_data->frame_num : 0; const LOTLayerNode *tree = lottie_animation_render_tree(lot_anim, frame_num, -- 2.7.4