From 6f0592414c5e7acdfadccfde0f9bcb594ff9cb2f Mon Sep 17 00:00:00 2001 From: Taehyub Kim Date: Fri, 2 Apr 2021 21:35:25 +0900 Subject: [PATCH] [Tizen] vector-animation: Imeplements rive animation Change-Id: Ib361f8d06955d28669050fc5181c4e493f082d17 --- .../vector-animation-renderer-plugin-proxy.cpp | 36 ++++++++++++++++++++-- .../vector-animation-renderer-plugin-proxy.h | 12 +++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp index 78b747a..bee8d9a 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp +++ b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp @@ -32,6 +32,8 @@ namespace { // The default plugin name const char* DEFAULT_OBJECT_NAME("libdali2-vector-animation-renderer-plugin.so"); +// The rive animation plugin name +const char* RIVE_OBJECT_NAME("libdali2-rive-animation-renderer-plugin.so"); } // namespace @@ -50,8 +52,6 @@ VectorAnimationRendererPluginProxy::VectorAnimationRendererPluginProxy(const std { mSharedObjectName = DEFAULT_OBJECT_NAME; } - - Initialize(); } VectorAnimationRendererPluginProxy::~VectorAnimationRendererPluginProxy() @@ -68,8 +68,25 @@ VectorAnimationRendererPluginProxy::~VectorAnimationRendererPluginProxy() } } -void VectorAnimationRendererPluginProxy::Initialize() +void VectorAnimationRendererPluginProxy::Initialize(AnimationFormat format) { + // initialization should be once + if(mPlugin) + { + return; + } + + if(format == AnimationFormat::RIVE) + { + // for Rive + mSharedObjectName = RIVE_OBJECT_NAME; + } + else + { + // for Json + mSharedObjectName = DEFAULT_OBJECT_NAME; + } + mLibHandle = dlopen(mSharedObjectName.c_str(), RTLD_LAZY); char* error = dlerror(); @@ -107,6 +124,19 @@ void VectorAnimationRendererPluginProxy::Finalize() bool VectorAnimationRendererPluginProxy::Load(const std::string& url) { + AnimationFormat format; + std::string extensionName = url.substr(url.find_last_of(".") + 1); + if(extensionName == "riv") + { + format = AnimationFormat::RIVE; + } + else + { + format = AnimationFormat::JSON; + } + + Initialize(format); + if(mPlugin) { return mPlugin->Load(url); diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h index ef4f016..c105e39 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h +++ b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h @@ -111,9 +111,19 @@ public: private: /** + * Vector Animation formats. + */ + enum class AnimationFormat + { + NONE = 0, + JSON, + RIVE + }; + + /** * Dynamically loads the plugin. */ - void Initialize(); + void Initialize(AnimationFormat format); private: using CreateVectorAnimationRendererFunction = Dali::VectorAnimationRendererPlugin* (*)(); -- 2.7.4