Add Vector animation renderer 27/191427/8
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 17 Oct 2018 05:30:48 +0000 (14:30 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Thu, 22 Nov 2018 02:52:50 +0000 (11:52 +0900)
Change-Id: I6390df6ea8dd703ac479198c57d5b166ac15ab54

build/tizen/adaptor/Makefile.am
build/tizen/adaptor/module.list
dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h [new file with mode: 0644]
dali/devel-api/adaptor-framework/vector-animation-renderer.cpp [new file with mode: 0755]
dali/devel-api/adaptor-framework/vector-animation-renderer.h [new file with mode: 0755]
dali/devel-api/file.list
dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp [new file with mode: 0644]
dali/internal/vector-animation/common/vector-animation-renderer-impl.h [new file with mode: 0755]
dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp [new file with mode: 0644]
dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h [new file with mode: 0644]
dali/internal/vector-animation/file.list [new file with mode: 0644]

index 82c8783..2996179 100644 (file)
@@ -61,6 +61,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_text_ubuntu_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
@@ -114,6 +115,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_system_tizen_wayland_src_files) \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
@@ -177,6 +179,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_system_tizen_wayland_src_files) \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
@@ -239,6 +242,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_system_tizen_wayland_src_files) \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
@@ -300,6 +304,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_system_tizen_wayland_src_files) \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
@@ -364,6 +369,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_system_tizen_wearable_src_files) \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
+                  $(adaptor_vector_animation_common_src_files) \
                   $(adaptor_video_common_src_files) \
                   $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
index 30e4128..97727a4 100644 (file)
@@ -71,6 +71,10 @@ include ../../../dali/internal/trace/file.list
 adaptor_thread_dir = ../../../dali/internal/thread
 include ../../../dali/internal/thread/file.list
 
+# Module: vector-animation
+adaptor_vector_animation_dir = ../../../dali/internal/vector-animation
+include ../../../dali/internal/vector-animation/file.list
+
 # Module: public-api
 adaptor_public_api_dir = ../../../dali/public-api
 include ../../../dali/public-api/file.list
diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h b/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h
new file mode 100644 (file)
index 0000000..316d007
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef DALI_VECTOR_ANIMATION_RENDERER_PLUGIN_H
+#define DALI_VECTOR_ANIMATION_RENDERER_PLUGIN_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/rendering/renderer.h>
+#include <string>
+
+namespace Dali
+{
+
+/**
+ * VectorAnimationRendererPlugin is an abstract interface, used by dali-adaptor to render a vector animation.
+ * A concrete implementation must be created for each platform and provided as a dynamic library which
+ * will be loaded at run time by the adaptor.
+ */
+class VectorAnimationRendererPlugin
+{
+public:
+
+  /**
+   * @brief Constructor
+   */
+  VectorAnimationRendererPlugin() {}
+
+  /**
+   * @brief Destructor
+   */
+  virtual ~VectorAnimationRendererPlugin() {}
+
+  /**
+   * @brief Creates a renderer to render an vector animation file.
+   *
+   * @param[in] url The url of an animation file
+   * @param[in] renderer The renderer used to render the image
+   * @param[in] width The target image width
+   * @param[in] height The target image height
+   * @return True if the renderer is successfully created, false otherwise
+   */
+  virtual bool CreateRenderer( const std::string& url, Renderer renderer, uint32_t width, uint32_t height ) = 0;
+
+  /**
+   * @brief Starts the rendering.
+   *
+   * @return True if the renderer is successfully started, false otherwise
+   */
+  virtual bool StartRender() = 0;
+
+  /**
+   * @brief Stops the rendering.
+   */
+  virtual void StopRender() = 0;
+
+  /**
+   * @brief Renders the content to the target buffer synchronously.
+   *
+   * @param[in] frameNumber The frame number to be rendered
+   */
+  virtual void Render( uint32_t frameNumber ) = 0;
+
+  /**
+   * @brief Gets the total number of frames of the file
+   *
+   * @return The total number of frames
+   */
+  virtual uint32_t GetTotalFrameNumber() = 0;
+
+  /**
+   * @brief Function pointer called in adaptor to create a plugin instance.
+   */
+  using CreateVectorAnimationRendererFunction = VectorAnimationRendererPlugin* (*)();
+};
+
+} // namespace Dali
+
+#endif // DALI_VECTOR_ANIMATION_RENDERER_PLUGIN_H
diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp b/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp
new file mode 100755 (executable)
index 0000000..3349741
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/vector-animation/common/vector-animation-renderer-impl.h>
+
+namespace Dali
+{
+
+VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url, Renderer renderer, uint32_t width, uint32_t height )
+{
+  Internal::Adaptor::VectorAnimationRendererPtr animationRenderer = Internal::Adaptor::VectorAnimationRenderer::New();
+  if( animationRenderer )
+  {
+    animationRenderer->Initialize( url, renderer, width, height );
+  }
+
+  return VectorAnimationRenderer( animationRenderer.Get() );
+}
+
+VectorAnimationRenderer::VectorAnimationRenderer()
+{
+}
+
+VectorAnimationRenderer::~VectorAnimationRenderer()
+{
+}
+
+VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
+: BaseHandle( internal )
+{
+}
+
+VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
+: BaseHandle( handle )
+{
+}
+
+VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
+{
+  BaseHandle::operator=( rhs );
+  return *this;
+}
+
+bool VectorAnimationRenderer::StartRender()
+{
+  return GetImplementation( *this ).StartRender();
+}
+
+void VectorAnimationRenderer::StopRender()
+{
+  GetImplementation( *this ).StopRender();
+}
+
+void VectorAnimationRenderer::Render( uint32_t frameNumber )
+{
+  GetImplementation( *this ).Render( frameNumber );
+}
+
+uint32_t VectorAnimationRenderer::GetTotalFrameNumber()
+{
+  return GetImplementation( *this ).GetTotalFrameNumber();
+}
+
+} // namespace Dali
diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer.h b/dali/devel-api/adaptor-framework/vector-animation-renderer.h
new file mode 100755 (executable)
index 0000000..644cf22
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef DALI_VECTOR_ANIMATION_RENDERER_H
+#define DALI_VECTOR_ANIMATION_RENDERER_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/rendering/renderer.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class VectorAnimationRenderer;
+}
+}
+
+/**
+ * @brief Used for rendering a vector animation file
+ */
+class DALI_ADAPTOR_API VectorAnimationRenderer : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Creates an initialized handle to a new VectorAnimationRenderer.
+   *
+   * @param[in] url The url of the vector animation file
+   * @param[in] renderer The renderer used to render the image
+   * @param[in] width The width of the content
+   * @param[in] height The height of the content
+   * @return A handle to a newly allocated VectorAnimationRenderer
+   */
+  static VectorAnimationRenderer New( const std::string& url, Renderer renderer, uint32_t width, uint32_t height );
+
+  /**
+   * @brief Creates an empty handle.
+   * Use VectorAnimationRenderer::New() to create an initialized object.
+   */
+  VectorAnimationRenderer();
+
+  /**
+   * @brief Destructor.
+   */
+  ~VectorAnimationRenderer();
+
+  /**
+   * @brief This copy constructor is required for (smart) pointer semantics.
+   *
+   * @param[in] handle A reference to the copied handle
+   */
+  VectorAnimationRenderer( const VectorAnimationRenderer& handle );
+
+  /**
+   * @brief This assignment operator is required for (smart) pointer semantics.
+   *
+   * @param[in] rhs A reference to the copied handle
+   * @return A reference to this
+   */
+  VectorAnimationRenderer& operator=( const VectorAnimationRenderer& rhs );
+
+  /**
+   * @brief Starts the rendering.
+   *
+   * @return True if the renderer is successfully started, false otherwise.
+   */
+  bool StartRender();
+
+  /**
+   * @brief Stops the rendering.
+   */
+  void StopRender();
+
+  /**
+   * @brief Renders the content to the target buffer synchronously.
+   *
+   * @param[in] frameNumber The frame number to be rendered
+   */
+  void Render( uint32_t frameNumber );
+
+  /**
+   * @brief Gets the total number of frames of the file
+   *
+   * @return The total number of frames
+   */
+  uint32_t GetTotalFrameNumber();
+
+public: // Signals
+
+public: // Not intended for application developers
+
+  /// @cond internal
+  /**
+   * @brief The constructor.
+   * @note  Not intended for application developers.
+   *
+   * @param[in] pointer A pointer to a newly allocated VectorAnimationRenderer
+   */
+  explicit DALI_INTERNAL VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal );
+  /// @endcond
+
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_VECTOR_ANIMATION_RENDERER_H
index 735f7b9..5a29f71 100755 (executable)
@@ -26,6 +26,7 @@ devel_api_src_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/style-monitor.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/tilt-sensor.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/lifecycle-controller.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/vector-animation-renderer.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.cpp \
@@ -67,6 +68,8 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/sound-player.h \
   $(adaptor_devel_api_dir)/adaptor-framework/style-monitor.h \
   $(adaptor_devel_api_dir)/adaptor-framework/tilt-sensor.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/vector-animation-renderer.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/vector-animation-renderer-plugin.h \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player.h \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player-plugin.h \
   $(adaptor_devel_api_dir)/adaptor-framework/web-engine.h \
diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp b/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp
new file mode 100644 (file)
index 0000000..d037ab6
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/vector-animation/common/vector-animation-renderer-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace // unnamed namespace
+{
+
+// Type Registration
+Dali::BaseHandle Create()
+{
+  return Dali::BaseHandle();
+}
+
+Dali::TypeRegistration type( typeid( Dali::VectorAnimationRenderer ), typeid( Dali::BaseHandle ), Create );
+
+} // unnamed namespace
+
+VectorAnimationRendererPtr VectorAnimationRenderer::New()
+{
+  VectorAnimationRendererPtr renderer = new VectorAnimationRenderer();
+  return renderer;
+}
+
+VectorAnimationRenderer::VectorAnimationRenderer()
+: mPlugin( std::string() )
+{
+}
+
+VectorAnimationRenderer::~VectorAnimationRenderer()
+{
+}
+
+void VectorAnimationRenderer::Initialize( const std::string& url, Dali::Renderer renderer, uint32_t width, uint32_t height )
+{
+  mPlugin.CreateRenderer( url, renderer, width, height );
+}
+
+bool VectorAnimationRenderer::StartRender()
+{
+  return mPlugin.StartRender();
+}
+
+void VectorAnimationRenderer::StopRender()
+{
+  mPlugin.StopRender();
+}
+
+void VectorAnimationRenderer::Render( uint32_t frameNumber )
+{
+  mPlugin.Render( frameNumber );
+}
+
+uint32_t VectorAnimationRenderer::GetTotalFrameNumber()
+{
+  return mPlugin.GetTotalFrameNumber();
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-impl.h b/dali/internal/vector-animation/common/vector-animation-renderer-impl.h
new file mode 100755 (executable)
index 0000000..0c54961
--- /dev/null
@@ -0,0 +1,125 @@
+#ifndef DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
+#define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
+#include <dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class VectorAnimationRenderer;
+using VectorAnimationRendererPtr = IntrusivePtr< VectorAnimationRenderer >;
+
+/**
+ * Dali internal VectorAnimationRenderer.
+ */
+class VectorAnimationRenderer : public BaseObject
+{
+public:
+
+  /**
+   * @brief Creates a VectorAnimationRenderer object.
+   *
+   * @param[in] url The url of the vector animation file
+   */
+  static VectorAnimationRendererPtr New();
+
+  /**
+   * @brief Initializes member data.
+   */
+  void Initialize( const std::string& url, Dali::Renderer renderer, uint32_t width, uint32_t height );
+
+  /**
+   * @copydoc Dali::VectorAnimationRenderer::StartRender()
+   */
+  bool StartRender();
+
+  /**
+   * @copydoc Dali::VectorAnimationRenderer::StopRender()
+   */
+  void StopRender();
+
+  /**
+   * @copydoc Dali::VectorAnimationRenderer::Render()
+   */
+  void Render( uint32_t frameNumber );
+
+  /**
+   * @copydoc Dali::VectorAnimationRenderer::GetTotalFrameNumber()
+   */
+  uint32_t GetTotalFrameNumber();
+
+private:
+
+  /**
+   * @brief Constructor
+   */
+  VectorAnimationRenderer();
+
+  /**
+   * @brief Destructor.
+   */
+  ~VectorAnimationRenderer();
+
+private:
+
+  VectorAnimationRenderer( const VectorAnimationRenderer& ) = delete;
+  VectorAnimationRenderer& operator=( VectorAnimationRenderer& )  = delete;
+
+private:
+
+  VectorAnimationRendererPluginProxy mPlugin;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
+{
+  DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
+
+  BaseObject& handle = renderer.GetBaseObject();
+
+  return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
+}
+
+inline static const Internal::Adaptor::VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
+{
+  DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
+
+  const BaseObject& handle = renderer.GetBaseObject();
+
+  return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
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
new file mode 100644 (file)
index 0000000..8e7e1d2
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h>
+
+// EXTERNAL INCLUDES
+#include <dlfcn.h>
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+// The default plugin name
+const char* DEFAULT_OBJECT_NAME( "libdali-vector-animation-renderer-plugin.so" );
+
+}
+
+VectorAnimationRendererPluginProxy::VectorAnimationRendererPluginProxy( const std::string& sharedObjectName )
+: mSharedObjectName(),
+  mLibHandle( NULL ),
+  mPlugin( NULL ),
+  mCreateVectorAnimationRendererPtr( NULL )
+{
+  if( !sharedObjectName.empty() )
+  {
+    mSharedObjectName = sharedObjectName;
+  }
+  else
+  {
+    mSharedObjectName = DEFAULT_OBJECT_NAME;
+  }
+
+  Initialize();
+}
+
+VectorAnimationRendererPluginProxy::~VectorAnimationRendererPluginProxy()
+{
+  if( mPlugin )
+  {
+    delete mPlugin;
+    mPlugin = NULL;
+
+    if( mLibHandle && dlclose( mLibHandle ) )
+    {
+      DALI_LOG_ERROR( "Error closing vector animation renderer plugin library: %s\n", dlerror() );
+    }
+  }
+}
+
+void VectorAnimationRendererPluginProxy::Initialize()
+{
+  mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_LAZY );
+
+  char* error = dlerror();
+  if( mLibHandle == NULL || error != NULL )
+  {
+    DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: dlopen error [%s]\n", error );
+    return;
+  }
+
+  // load plugin
+  mCreateVectorAnimationRendererPtr = reinterpret_cast< CreateVectorAnimationRendererFunction >( dlsym( mLibHandle, "CreateVectorAnimationRendererPlugin" ) );
+
+  error = dlerror();
+  if( mCreateVectorAnimationRendererPtr == NULL || error != NULL )
+  {
+    DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error );
+    return;
+  }
+
+  mPlugin = mCreateVectorAnimationRendererPtr();
+  if( !mPlugin )
+  {
+    DALI_LOG_ERROR("VectorAnimationRendererPluginProxy::Initialize: Plugin creation failed\n");
+    return;
+  }
+}
+
+bool VectorAnimationRendererPluginProxy::CreateRenderer( const std::string& url, Dali::Renderer renderer, uint32_t width, uint32_t height )
+{
+  if( mPlugin )
+  {
+    return mPlugin->CreateRenderer( url, renderer, width, height );
+  }
+  return false;
+}
+
+bool VectorAnimationRendererPluginProxy::StartRender()
+{
+  if( mPlugin )
+  {
+    return mPlugin->StartRender();
+  }
+  return false;
+}
+
+void VectorAnimationRendererPluginProxy::StopRender()
+{
+  if( mPlugin )
+  {
+    mPlugin->StopRender();
+  }
+}
+
+void VectorAnimationRendererPluginProxy::Render( uint32_t frameNumber )
+{
+  if( mPlugin )
+  {
+    mPlugin->Render( frameNumber );
+  }
+}
+
+uint32_t VectorAnimationRendererPluginProxy::GetTotalFrameNumber()
+{
+  if( mPlugin )
+  {
+    return mPlugin->GetTotalFrameNumber();
+  }
+  return 0;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
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
new file mode 100644 (file)
index 0000000..55409ea
--- /dev/null
@@ -0,0 +1,100 @@
+#ifndef DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
+#define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Proxy class to dynamically load, use and unload vector animation renderer plugin.
+ */
+class VectorAnimationRendererPluginProxy
+{
+public:
+
+  /**
+   * @brief Constructor
+   */
+  VectorAnimationRendererPluginProxy( const std::string& sharedObjectName );
+
+  /**
+   * @brief Destructor
+   */
+  ~VectorAnimationRendererPluginProxy();
+
+  /**
+   * @copydoc Dali::VectorAnimationRendererPlugin::CreateRenderer()
+   */
+  bool CreateRenderer( const std::string& url, Dali::Renderer renderer, uint32_t width, uint32_t height );
+
+  /**
+   * @copydoc Dali::VectorAnimationRendererPlugin::StartRender()
+   */
+  bool StartRender();
+
+  /**
+   * @copydoc Dali::VectorAnimationRendererPlugin::StopRender()
+   */
+  void StopRender();
+
+  /**
+   * @copydoc Dali::VectorAnimationRendererPlugin::Render()
+   */
+  void Render( uint32_t frameNumber );
+
+  /**
+   * @copydoc Dali::VectorAnimationRendererPlugin::GetTotalFrameNumber()
+   */
+  uint32_t GetTotalFrameNumber();
+
+private:
+
+  /**
+   * Dynamically loads the plugin.
+   */
+  void Initialize();
+
+private:
+
+  using CreateVectorAnimationRendererFunction = Dali::VectorAnimationRendererPlugin* (*)();
+
+  std::string                            mSharedObjectName;   ///< Shared object name
+  void*                                  mLibHandle;          ///< Handle for the loaded library
+  Dali::VectorAnimationRendererPlugin*   mPlugin;             ///< Plugin handle
+
+  CreateVectorAnimationRendererFunction  mCreateVectorAnimationRendererPtr;   ///< Function pointer called in adaptor to create a plugin instance
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
diff --git a/dali/internal/vector-animation/file.list b/dali/internal/vector-animation/file.list
new file mode 100644 (file)
index 0000000..8edeeb0
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+# module: vector-animation, backend: common
+adaptor_vector_animation_common_src_files=\
+    ${adaptor_vector_animation_dir}/common/vector-animation-renderer-impl.cpp \
+    ${adaptor_vector_animation_dir}/common/vector-animation-renderer-plugin-proxy.cpp
+