Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / images / encoded-buffer-image.h
1 #ifndef __DALI_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_ENCODED_BUFFER_IMAGE_H__
3
4 /*
5  * Copyright (c) 2018 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/public-api/images/image.h>
23 #include <dali/public-api/images/image-operations.h>
24 #include <dali/public-api/math/uint-16-pair.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_core_images
30  * @{
31  */
32
33 namespace Internal DALI_INTERNAL
34 {
35 class EncodedBufferImage;
36 }
37
38 typedef Uint16Pair ImageDimensions;
39
40
41 /**
42  * @DEPRECATED_1_2.41
43  *
44  * @brief EncodedBufferImage represents an image resource as a buffer of encoded pixel data.
45  *
46  * A memory buffer of encoded image data is provided by the application and
47  * decoded asynchronously on a background thread to fill the image's
48  * pixel data.
49  *
50  * The buffer of data provided to an EncodedBufferImage factory function
51  * (New) should be filled with encoded image data in one of %Dali's
52  * supported image file formats, with the sequence of bytes in the buffer
53  * exactly matching the sequence of bytes that a file in the file system
54  * holding the encoded image data would have.
55  *
56  * The application may free the encoded image buffer passed to one of the
57  * New() static factory member functions as soon as they return.
58  *
59  * <h3> Signals </h3>
60  *
61  * Image::LoadingFinishedSignal is emitted when the decoding of the
62  * image data is completed, either successfully or not.
63  *
64  * Image::UploadedSignal is emitted when the decoded image data gets
65  * uploaded to the OpenGL ES implementation.
66  * @SINCE_1_0.0
67  */
68 class DALI_CORE_API EncodedBufferImage : public Image
69 {
70 public:
71
72   /**
73    * @DEPRECATED_1_2.41
74    *
75    * @brief Constructor which creates an uninitialized EncodedBufferImage object.
76    *
77    * Use @ref EncodedBufferImage::New to create an initialised object.
78    * @SINCE_1_0.0
79    */
80   EncodedBufferImage() DALI_DEPRECATED_API;
81
82   /**
83    * @DEPRECATED_1_2.41
84    *
85    * @brief Creates an initialized image object from an encoded image buffer in memory.
86    *
87    * @SINCE_1_0.0
88    * @param[in] encodedImage The encoded bytes of an image, in a supported
89    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
90    * exactly as it would be as a file in the filesystem.
91    * The caller retains ownership of this buffer and is free to modify or
92    * discard it as soon as the function returns
93    * @param[in] encodedImageByteCount The size in bytes of the buffer pointed to
94    * by encodedImage.
95    * @return A handle to a newly allocated object
96    */
97   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount ) DALI_DEPRECATED_API;
98
99   /**
100    * @DEPRECATED_1_2.41
101    *
102    * @brief Creates an initialized image object from an encoded image buffer in memory.
103    *
104    * @SINCE_1_1.4
105    * @param[in] encodedImage The encoded bytes of an image, in a supported
106    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
107    * exactly as it would be as a file in the filesystem.
108    * The caller retains ownership of this buffer and is free to modify or
109    * discard it as soon as the function returns
110    * @param[in] encodedImageByteCount The size in bytes of the buffer pointed to
111    * by encodedImage
112    * @param[in] size The width and height to fit the loaded image to
113    * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
114    * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
115    * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
116    * policy is set, a reload will not be possible, so the Image should never be
117    * used once all actors using it have gone off-stage
118    * @return A handle to a newly allocated object
119    */
120   static EncodedBufferImage New( const uint8_t * const encodedImage, std::size_t encodedImageByteCount, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection = true ) DALI_DEPRECATED_API;
121
122   /**
123    * @DEPRECATED_1_2.41
124    *
125    * @brief Downcasts a handle to EncodedBufferImage handle.
126    *
127    * If handle points to a EncodedBufferImage, the
128    * downcast produces valid handle. If not, the returned handle is left uninitialized.
129    * @SINCE_1_0.0
130    * @param[in] handle Handle to an object
131    * @return Handle to a EncodedBufferImage or an uninitialized handle
132    */
133   static EncodedBufferImage DownCast( BaseHandle handle ) DALI_DEPRECATED_API;
134
135   /**
136    * @DEPRECATED_1_2.41
137    *
138    * @brief Destructor.
139    *
140    * This is non-virtual since derived Handle types must not contain data or virtual methods.
141    * @SINCE_1_0.0
142    */
143   ~EncodedBufferImage() DALI_DEPRECATED_API;
144
145   /**
146    * @DEPRECATED_1_2.41
147    *
148    * @brief This copy constructor is required for (smart) pointer semantics.
149    *
150    * @SINCE_1_0.0
151    * @param[in] handle A reference to the copied handle
152    */
153   EncodedBufferImage(const EncodedBufferImage& handle) DALI_DEPRECATED_API;
154
155   /**
156    * @DEPRECATED_1_2.41
157    *
158    * @brief This assignment operator is required for (smart) pointer semantics.
159    *
160    * @SINCE_1_0.0
161    * @param[in] rhs A reference to the copied handle
162    * @return A reference to this
163    */
164   EncodedBufferImage& operator=(const EncodedBufferImage& rhs) DALI_DEPRECATED_API;
165
166 public: // Not intended for application developers
167
168   explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
169 };
170
171 /**
172  * @}
173  */
174 } // namespace Dali
175
176 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__