[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / vector-animation / common / vector-animation-renderer-impl.h
1 #ifndef DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
2 #define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
3
4 /*
5  * Copyright (c) 2023 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
26 #include <dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class VectorAnimationRenderer;
35 using VectorAnimationRendererPtr = IntrusivePtr<VectorAnimationRenderer>;
36
37 /**
38  * Dali internal VectorAnimationRenderer.
39  */
40 class VectorAnimationRenderer : public BaseObject, public ConnectionTracker
41 {
42 public:
43   /**
44    * @brief Creates a VectorAnimationRenderer object.
45    *
46    * @param[in] url The url of the vector animation file
47    */
48   static VectorAnimationRendererPtr New();
49
50   /**
51    * @copydoc Dali::VectorAnimationRenderer::Finalize()
52    */
53   void Finalize();
54
55   /**
56    * @copydoc Dali::VectorAnimationRenderer::Load()
57    */
58   bool Load(const std::string& url);
59
60   /**
61    * @copydoc Dali::VectorAnimationRenderer::Load()
62    */
63   bool Load(const Vector<uint8_t>& data);
64
65   /**
66    * @copydoc Dali::VectorAnimationRenderer::SetRenderer()
67    */
68   void SetRenderer(Dali::Renderer renderer);
69
70   /**
71    * @copydoc Dali::VectorAnimationRenderer::SetSize()
72    */
73   void SetSize(uint32_t width, uint32_t height);
74
75   /**
76    * @copydoc Dali::VectorAnimationRenderer::Render()
77    */
78   bool Render(uint32_t frameNumber);
79
80   /**
81    * @copydoc Dali::VectorAnimationRenderer::RenderStopped()
82    */
83   void RenderStopped();
84
85   /**
86    * @copydoc Dali::VectorAnimationRenderer::GetTotalFrameNumber()
87    */
88   uint32_t GetTotalFrameNumber() const;
89
90   /**
91    * @copydoc Dali::VectorAnimationRenderer::GetFrameRate()
92    */
93   float GetFrameRate() const;
94
95   /**
96    * @copydoc Dali::VectorAnimationRenderer::GetDefaultSize()
97    */
98   void GetDefaultSize(uint32_t& width, uint32_t& height) const;
99
100   /**
101    * @copydoc Dali::VectorAnimationRenderer::GetLayerInfo()
102    */
103   void GetLayerInfo(Property::Map& map) const;
104
105   /**
106    * @copydoc Dali::VectorAnimationRenderer::GetMarkerInfo()
107    */
108   bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const;
109
110   /**
111    * @copydoc Dali::VectorAnimationRenderer::GetMarkerInfo()
112    */
113   void GetMarkerInfo(Property::Map& map) const;
114
115   /**
116    * @copydoc Dali::VectorAnimationRenderer::InvalidateBuffer()
117    */
118   void InvalidateBuffer();
119
120   /**
121    * @copydoc Dali::VectorAnimationRenderer::AddPropertyValueCallback()
122    */
123   void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id);
124
125   /**
126    * @copydoc Dali::VectorAnimationRenderer::KeepRasterizedBuffer()
127    */
128   void KeepRasterizedBuffer();
129
130   /**
131    * @copydoc Dali::VectorAnimationRenderer::UploadCompletedSignal()
132    */
133   Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal();
134
135 private:
136   /**
137    * @brief Constructor
138    */
139   VectorAnimationRenderer();
140
141   /**
142    * @brief Destructor.
143    */
144   ~VectorAnimationRenderer();
145
146 private:
147   VectorAnimationRenderer(const VectorAnimationRenderer&) = delete;
148   VectorAnimationRenderer& operator=(VectorAnimationRenderer&) = delete;
149
150 private:
151   VectorAnimationRendererPluginProxy mPlugin;
152 };
153
154 } // namespace Adaptor
155
156 } // namespace Internal
157
158 inline static Internal::Adaptor::VectorAnimationRenderer& GetImplementation(Dali::VectorAnimationRenderer& renderer)
159 {
160   DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty.");
161
162   BaseObject& handle = renderer.GetBaseObject();
163
164   return static_cast<Internal::Adaptor::VectorAnimationRenderer&>(handle);
165 }
166
167 inline static const Internal::Adaptor::VectorAnimationRenderer& GetImplementation(const Dali::VectorAnimationRenderer& renderer)
168 {
169   DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty.");
170
171   const BaseObject& handle = renderer.GetBaseObject();
172
173   return static_cast<const Internal::Adaptor::VectorAnimationRenderer&>(handle);
174 }
175
176 } // namespace Dali
177
178 #endif // DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H