DALi Version 2.1.32
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / vector-animation-renderer.h
1 #ifndef DALI_VECTOR_ANIMATION_RENDERER_H
2 #define DALI_VECTOR_ANIMATION_RENDERER_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/rendering/renderer.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_adaptor_framework
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 namespace Adaptor
38 {
39 class VectorAnimationRenderer;
40 }
41 } // namespace DALI_INTERNAL
42
43 /**
44  * @brief Used for rendering a vector animation file
45  */
46 class DALI_ADAPTOR_API VectorAnimationRenderer : public BaseHandle
47 {
48 public:
49   /// @brief UploadCompleted signal type.
50   using UploadCompletedSignalType = Signal<void()>;
51
52   /**
53    * @brief Creates an initialized handle to a new VectorAnimationRenderer.
54    *
55    * @return A handle to a newly allocated VectorAnimationRenderer
56    */
57   static VectorAnimationRenderer New();
58
59   /**
60    * @brief Creates an empty handle.
61    * Use VectorAnimationRenderer::New() to create an initialized object.
62    */
63   VectorAnimationRenderer();
64
65   /**
66    * @brief Destructor.
67    */
68   ~VectorAnimationRenderer();
69
70   /**
71    * @brief This copy constructor is required for (smart) pointer semantics.
72    *
73    * @param[in] handle A reference to the copied handle
74    */
75   VectorAnimationRenderer(const VectorAnimationRenderer& handle);
76
77   /**
78    * @brief This assignment operator is required for (smart) pointer semantics.
79    *
80    * @param[in] rhs A reference to the copied handle
81    * @return A reference to this
82    */
83   VectorAnimationRenderer& operator=(const VectorAnimationRenderer& rhs);
84
85   /**
86    * @brief Finalizes the renderer.
87    */
88   void Finalize();
89
90   /**
91    * @brief Loads the animation file.
92    *
93    * @param[in] url The url of the vector animation file
94    * @return True if loading success, false otherwise.
95    */
96   bool Load(const std::string& url);
97
98   /**
99    * @brief Sets the renderer used to display the result image.
100    *
101    * @param[in] renderer The renderer used to display the result image
102    */
103   void SetRenderer(Renderer renderer);
104
105   /**
106    * @brief Sets the target image size.
107    *
108    * @param[in] width The target image width
109    * @param[in] height The target image height
110    */
111   void SetSize(uint32_t width, uint32_t height);
112
113   /**
114    * @brief Renders the content to the target buffer synchronously.
115    *
116    * @param[in] frameNumber The frame number to be rendered
117    * @return True if the rendering success, false otherwise.
118    */
119   bool Render(uint32_t frameNumber);
120
121   /**
122    * @brief Gets the total number of frames of the file
123    *
124    * @return The total number of frames
125    */
126   uint32_t GetTotalFrameNumber() const;
127
128   /**
129    * @brief Gets the frame rate of the file.
130    *
131    * @return The frame rate of the file
132    */
133   float GetFrameRate() const;
134
135   /**
136    * @brief Gets the default size of the file.
137    *
138    * @param[out] width The default width of the file
139    * @param[out] height The default height of the file
140    */
141   void GetDefaultSize(uint32_t& width, uint32_t& height) const;
142
143   /**
144    * @brief Gets the layer information of all the child layers.
145    *
146    * @param[out] map The layer information
147    */
148   void GetLayerInfo(Property::Map& map) const;
149
150   /**
151    * @brief Gets the start frame and the end frame number of the composition marker.
152    *
153    * @param[in] marker The composition marker of the file
154    * @param[out] startFrame The start frame number of the specified marker
155    * @param[out] endFrame The end frame number of the specified marker
156    * @return True if the marker is found in the file, false otherwise.
157    *
158    * @note https://helpx.adobe.com/after-effects/using/layer-markers-composition-markers.html
159    * Markers exported from AfterEffect are used to describe a segment of an animation {comment/tag , startFrame, endFrame}
160    * Marker can be use to devide a resource in to separate animations by tagging the segment with comment string,
161    * start frame and duration of that segment.
162    */
163   bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const;
164
165   /**
166    * @brief Invalidates the rendered buffer.
167    * @note The upload completed signal will be emitted again.
168    */
169   void InvalidateBuffer();
170
171 public: // Signals
172   /**
173    * @brief Connect to this signal to be notified when the texture upload is completed.
174    *
175    * @return The signal to connect to.
176    */
177   UploadCompletedSignalType& UploadCompletedSignal();
178
179 public: // Not intended for application developers
180   /// @cond internal
181   /**
182    * @brief The constructor.
183    * @note  Not intended for application developers.
184    *
185    * @param[in] pointer A pointer to a newly allocated VectorAnimationRenderer
186    */
187   explicit DALI_INTERNAL VectorAnimationRenderer(Internal::Adaptor::VectorAnimationRenderer* internal);
188   /// @endcond
189 };
190
191 /**
192  * @}
193  */
194 } // namespace Dali
195
196 #endif // DALI_VECTOR_ANIMATION_RENDERER_H