vector-animation: Imeplements rive animation 49/256449/14
authorTaehyub Kim <taehyub.kim@samsung.com>
Fri, 2 Apr 2021 12:35:25 +0000 (21:35 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Thu, 29 Apr 2021 05:00:45 +0000 (14:00 +0900)
Change-Id: Ib361f8d06955d28669050fc5181c4e493f082d17

dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp
dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h

index 78b747a..bee8d9a 100644 (file)
@@ -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);
index ef4f016..c105e39 100644 (file)
@@ -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* (*)();