e5deb25a03f8b4553f1f64555b560ed56924e593
[platform/core/uifw/dali-adaptor.git] / dali / internal / vector-animation / common / vector-animation-renderer-plugin-proxy.h
1 #ifndef DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
2 #define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 /**
31  * Proxy class to dynamically load, use and unload vector animation renderer plugin.
32  */
33 class VectorAnimationRendererPluginProxy
34 {
35 public:
36   /**
37    * @brief Constructor
38    */
39   VectorAnimationRendererPluginProxy(const std::string& sharedObjectName);
40
41   /**
42    * @brief Destructor
43    */
44   ~VectorAnimationRendererPluginProxy();
45
46   /**
47    * @copydoc Dali::VectorAnimationRendererPlugin::Finalize()
48    */
49   void Finalize();
50
51   /**
52    * @copydoc Dali::VectorAnimationRendererPlugin::Load()
53    */
54   bool Load(const std::string& url);
55
56   /**
57    * @copydoc Dali::VectorAnimationRendererPlugin::SetRenderer()
58    */
59   void SetRenderer(Dali::Renderer renderer);
60
61   /**
62    * @copydoc Dali::VectorAnimationRendererPlugin::SetSize()
63    */
64   void SetSize(uint32_t width, uint32_t height);
65
66   /**
67    * @copydoc Dali::VectorAnimationRendererPlugin::Render()
68    */
69   bool Render(uint32_t frameNumber);
70
71   /**
72    * @copydoc Dali::VectorAnimationRendererPlugin::Render()
73    */
74   void RenderStopped();
75
76   /**
77    * @copydoc Dali::VectorAnimationRendererPlugin::GetTotalFrameNumber()
78    */
79   uint32_t GetTotalFrameNumber() const;
80
81   /**
82    * @copydoc Dali::VectorAnimationRendererPlugin::GetFrameRate()
83    */
84   float GetFrameRate() const;
85
86   /**
87    * @copydoc Dali::VectorAnimationRendererPlugin::GetDefaultSize()
88    */
89   void GetDefaultSize(uint32_t& width, uint32_t& height) const;
90
91   /**
92    * @copydoc Dali::VectorAnimationRendererPlugin::GetLayerInfo()
93    */
94   void GetLayerInfo(Property::Map& map) const;
95
96   /**
97    * @copydoc Dali::VectorAnimationRendererPlugin::GetMarkerInfo()
98    */
99   bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const;
100
101   /**
102    * @copydoc Dali::VectorAnimationRendererPlugin::InvalidateBuffer()
103    */
104   void InvalidateBuffer();
105
106   /**
107    * @copydoc Dali::VectorAnimationRendererPlugin::AddPropertyValueCallback()
108    */
109   void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id);
110
111   /**
112    * @copydoc Dali::VectorAnimationRendererPlugin::UploadCompletedSignal()
113    */
114   VectorAnimationRendererPlugin::UploadCompletedSignalType& UploadCompletedSignal();
115
116   // Not copyable or movable
117   VectorAnimationRendererPluginProxy(const VectorAnimationRendererPluginProxy&) = delete;            ///< Deleted copy constructor
118   VectorAnimationRendererPluginProxy(VectorAnimationRendererPluginProxy&&)      = delete;            ///< Deleted move constructor
119   VectorAnimationRendererPluginProxy& operator=(const VectorAnimationRendererPluginProxy&) = delete; ///< Deleted copy assignment operator
120   VectorAnimationRendererPluginProxy& operator=(VectorAnimationRendererPluginProxy&&) = delete;      ///< Deleted move assignment operator
121
122 private:
123   /**
124    * Dynamically loads the plugin.
125    */
126   void Initialize();
127
128 private:
129   using CreateVectorAnimationRendererFunction = Dali::VectorAnimationRendererPlugin* (*)();
130
131   std::string                          mSharedObjectName; ///< Shared object name
132   void*                                mLibHandle;        ///< Handle for the loaded library
133   Dali::VectorAnimationRendererPlugin* mPlugin;           ///< Plugin handle
134
135   CreateVectorAnimationRendererFunction                    mCreateVectorAnimationRendererPtr; ///< Function pointer called in adaptor to create a plugin instance
136   VectorAnimationRendererPlugin::UploadCompletedSignalType mDefaultSignal;
137 };
138
139 } // namespace Adaptor
140
141 } // namespace Internal
142
143 } // namespace Dali
144
145 #endif // DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H