[dali_1.0.1] Merge branch 'tizen'
[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) 2014 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 <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/image.h>
26
27 namespace Dali DALI_IMPORT_API
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class EncodedBufferImage;
33 }
34
35
36 /**
37  * @brief EncodedBufferImage represents an image resource that can be added to
38  * ImageActors.
39  *
40  * A memory buffer of encoded image data is provided by the application and
41  * decoded asynchronously on a background thread to fill the image's
42  * pixel data.
43  *
44  * The buffer of data provided to an EncodedBufferImage factory function
45  * (New) should be filled with encoded image data in one of %Dali's
46  * supported image file formats, with the sequence of bytes in the buffer
47  * exactly matching the sequence of bytes that a file in the file system
48  * holding the encoded image data would have.
49  *
50  * The application may free the encoded image buffer passed to one of the
51  * New() static factory member functions as soon as they return.
52  *
53  * <h3> Signals </h3>
54  *
55  * Image::LoadingFinishedSignal is emitted when the decoding of the
56  * image data is completed, either successfully or not.
57  *
58  * Image::UploadedSignal is emitted when the decoded image data gets
59  * uploaded to the OpenGL ES implementation.
60  */
61 class EncodedBufferImage : public Image
62 {
63 public:
64   /**
65    * @brief Constructor which creates an uninitialized EncodedBufferImage object.
66    *
67    * Use Image::New(...) to create an initialised object.
68    */
69   EncodedBufferImage();
70
71   /**
72    * @brief Create an initialised image object from an encoded image buffer in memory.
73    *
74    * The image will be created eagerly using LoadPolicy::Immediate.
75    * The function is non-blocking and returns immediately while the image
76    * decoding happens on a background thread.
77    * @param [in] encodedImage The encoded bytes of an image, in a supported
78    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
79    * exactly as it would be as a file in the filesystem.
80    * The caller retains ownership of this buffer and is free to modify or
81    * discard it as soon as the function returns.
82    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
83    * by encodedImage.
84    * @param [in] attributes Requested parameters for loading (size, scaling etc.).
85    * @param [in] releasePol The ReleasePolicy to apply to Image. If the Unused
86    * policy is set, a reload will not be possible, so the Image should never be
87    * used once all actors using it have gone off-stage.
88    * @return A handle to a newly allocated object.
89    */
90   static EncodedBufferImage New(const uint8_t * const encodedImage, std::size_t encodedImageByteCount, const ImageAttributes& attributes, ReleasePolicy releasePol = Image::Never);
91
92   /**
93    * @brief Create an initialised image object from an encoded image buffer in memory.
94    *
95    * The image will be created eagerly using LoadPolicy::Immediate.
96    * The function is non-blocking and returns immediately while the image
97    * decoding happens on a background thread.
98    * @param [in] encodedImage The encoded bytes of an image, in a supported
99    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
100    * exactly as it would be as a file in the filesystem.
101    * The caller retains ownership of this buffer and is free to modify or
102    * discard it as soon as the function returns.
103    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
104    * by encodedImage.
105    * @return A handle to a newly allocated object.
106    */
107   static EncodedBufferImage New(const uint8_t * const encodedImage, std::size_t encodedImageByteCount);
108
109   /**
110    * @brief Downcast an Object handle to EncodedBufferImage.
111    *
112    * If handle points to a EncodedBufferImage the
113    * downcast produces valid handle. If not the returned handle is left uninitialized.
114    * @param[in] handle to An object
115    * @return handle to a EncodedBufferImage or an uninitialized handle
116    */
117   static EncodedBufferImage DownCast( BaseHandle handle );
118
119   /**
120    * @brief Destructor
121    *
122    * This is non-virtual since derived Handle types must not contain data or virtual methods.
123    */
124   ~EncodedBufferImage();
125
126   /**
127    * @copydoc Dali::BaseHandle::operator=
128    */
129   using BaseHandle::operator=;
130
131
132 public: // Not intended for application developers
133
134   explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
135 };
136
137 } // namespace Dali
138
139 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__