[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / vector-image-renderer.h
1 #ifndef DALI_VECTOR_IMAGE_RENDERER_H
2 #define DALI_VECTOR_IMAGE_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
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
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::Adaptor
36 {
37 class VectorImageRenderer;
38 } // namespace Internal::Adaptor
39
40 /**
41  * @brief Used for rendering a vector image file (SVG)
42  */
43 class DALI_ADAPTOR_API VectorImageRenderer : public BaseHandle
44 {
45 public:
46   /**
47    * @brief Creates an initialized handle to a new VectorImageRenderer.
48    *
49    * @return A handle to a newly allocated VectorImageRenderer
50    */
51   static VectorImageRenderer New();
52
53   /**
54    * @brief Creates an empty handle.
55    * Use VectorImageRenderer::New() to create an initialized object.
56    */
57   VectorImageRenderer();
58
59   /**
60    * @brief Destructor.
61    */
62   ~VectorImageRenderer();
63
64   /**
65    * @brief This copy constructor is required for (smart) pointer semantics.
66    *
67    * @param[in] handle A reference to the copied handle
68    */
69   VectorImageRenderer(const VectorImageRenderer& handle) = default;
70
71   /**
72    * @brief This assignment operator is required for (smart) pointer semantics.
73    *
74    * @param[in] rhs A reference to the copied handle
75    * @return A reference to this
76    */
77   VectorImageRenderer& operator=(const VectorImageRenderer& rhs) = default;
78
79   /**
80    * @brief Load vector image data directly.
81    *
82    * @param[in] data SVG image data to load.
83    * @param[in] dpi The DPI of the screen.
84    * @return True if the load success, false otherwise.
85    */
86   bool Load(const Vector<uint8_t>& data, float dpi);
87
88   /**
89    * @brief Query whether the vector image is loaded.
90    *
91    * @return True if the image is loaded, false other wise.
92    */
93   bool IsLoaded() const;
94
95   /**
96    * @brief Rasterizes the content to the pixel buffer synchronously.
97    *
98    * @param[in] width The pixel buffer width
99    * @param[in] height The pixel buffer height
100    * @return The handle to the rasterized PixelBuffer object or an empty handle in case failed.
101    */
102   Dali::Devel::PixelBuffer Rasterize(uint32_t width, uint32_t height);
103
104   /**
105    * @brief Gets the default size of the file.
106    *
107    * @param[out] width The default width of the file
108    * @param[out] height The default height of the file
109    */
110   void GetDefaultSize(uint32_t& width, uint32_t& height) const;
111
112 public: // Not intended for application developers
113   /// @cond internal
114   /**
115    * @brief The constructor.
116    * @note  Not intended for application developers.
117    *
118    * @param[in] pointer A pointer to a newly allocated VectorImageRenderer
119    */
120   explicit DALI_INTERNAL VectorImageRenderer(Internal::Adaptor::VectorImageRenderer* internal);
121   /// @endcond
122 };
123
124 /**
125  * @}
126  */
127 } // namespace Dali
128
129 #endif // DALI_VECTOR_IMAGE_RENDERER_H