Set the image type of encoded image buffer
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / encoded-image-buffer.h
1 #ifndef DALI_ENCODED_IMAGE_BUFFER_H
2 #define DALI_ENCODED_IMAGE_BUFFER_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/common/dali-vector.h>
22 #include <dali/public-api/object/base-handle.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29 namespace Internal DALI_INTERNAL
30 {
31 class EncodedImageBuffer;
32 }
33
34 /**
35  * @brief EncodedImageBuffer contains the large encoded raw buffer informations.
36  *
37  * @SINCE_2_0.34
38  * @note Object will copy raw buffer data.
39  */
40 class DALI_ADAPTOR_API EncodedImageBuffer : public BaseHandle
41 {
42 public:
43   using RawBufferType = Dali::Vector<uint8_t>;
44
45   /**
46    * @brief The list of type of encoded image buffer.
47    *
48    * @SINCE_2_2.51
49    */
50   enum class ImageType
51   {
52     REGULAR_IMAGE,
53     VECTOR_IMAGE, ///< svg format.
54     ANIMATED_VECTOR_IMAGE, ///< lottie format.
55
56     DEFAULT = REGULAR_IMAGE,
57   };
58
59 public:
60   /**
61    * @brief Create a new EncodedImageBuffer. ImageType will be setted as DEFAULT.
62    *
63    * @SINCE_2_0.34
64    * @param [in] buffer The encoded raw buffer
65    * @return A handle to a new EncodedImageBuffer.
66    */
67   static EncodedImageBuffer New(const RawBufferType& buffer);
68
69   /**
70    * @brief Create a new EncodedImageBuffer with ImageType.
71    *
72    * @SINCE_2_2.51
73    * @param [in] buffer The encoded raw buffer
74    * @param [in] type The type hint of encoded raw buffer
75    * @return A handle to a new EncodedImageBuffer.
76    */
77   static EncodedImageBuffer New(const RawBufferType& buffer, ImageType type);
78
79   /**
80    * @brief Create an empty handle.
81    *
82    * @SINCE_2_0.34
83    * Calling member functions of an empty handle is not allowed.
84    */
85   EncodedImageBuffer();
86
87   /**
88    * @brief Destructor.
89    *
90    * This is non-virtual since derived Handle types must not contain data or virtual methods.
91    * @SINCE_2_0.34
92    */
93   ~EncodedImageBuffer();
94
95   /**
96    * @brief This copy constructor is required for (smart) pointer semantics.
97    *
98    * @SINCE_2_0.34
99    * @param [in] handle A reference to the copied handle
100    */
101   EncodedImageBuffer(const EncodedImageBuffer& handle);
102
103   /**
104    * @brief This assignment operator is required for (smart) pointer semantics.
105    *
106    * @SINCE_2_0.34
107    * @param [in] handle  A reference to the copied handle
108    * @return A reference to this
109    */
110   EncodedImageBuffer& operator=(const EncodedImageBuffer& handle);
111
112   /**
113    * @brief This move constructor is required for (smart) pointer semantics.
114    *
115    * @SINCE_2_0.34
116    * @param [in] handle A reference to the moved handle
117    */
118   EncodedImageBuffer(EncodedImageBuffer&& handle) noexcept;
119
120   /**
121    * @brief This move assignment operator is required for (smart) pointer semantics.
122    *
123    * @SINCE_2_0.34
124    * @param [in] handle  A reference to the moved handle
125    * @return A reference to this
126    */
127   EncodedImageBuffer& operator=(EncodedImageBuffer&& handle) noexcept;
128
129   /**
130    * @brief Get raw buffer data
131    *
132    * @SINCE_2_0.34
133    * @note this method return const value. Mean, you cannot change raw buffer
134    * @return A RawBufferType this buffer have
135    */
136   const RawBufferType& GetRawBuffer() const;
137
138   /**
139    * @brief Get the hash value of raw buffer
140    *
141    * @SINCE_2_1.20
142    * @return A hash value of raw buffer.
143    */
144   std::size_t GetHash() const;
145
146   /**
147    * @brief Set type of raw buffer.
148    *
149    * @SINCE_2_2.51
150    * @param[in] type A ImageType for this buffer
151    */
152   void SetImageType(ImageType type);
153
154   /**
155    * @brief Get type of raw buffer.
156    *
157    * @SINCE_2_2.51
158    * @return A ImageType this buffer have
159    */
160   ImageType GetImageType() const;
161
162 public: // Not intended for developer use
163   explicit DALI_INTERNAL EncodedImageBuffer(Internal::EncodedImageBuffer* impl);
164 };
165
166 } // namespace Dali
167
168 #endif // DALI_ENCODED_IMAGE_BUFFER_H