1 #ifndef __DALI_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_ENCODED_BUFFER_IMAGE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/images/image.h>
26 #include <dali/public-api/images/image-attributes.h>
31 namespace Internal DALI_INTERNAL
33 class EncodedBufferImage;
38 * @brief EncodedBufferImage represents an image resource that can be added to
41 * A memory buffer of encoded image data is provided by the application and
42 * decoded asynchronously on a background thread to fill the image's
45 * The buffer of data provided to an EncodedBufferImage factory function
46 * (New) should be filled with encoded image data in one of %Dali's
47 * supported image file formats, with the sequence of bytes in the buffer
48 * exactly matching the sequence of bytes that a file in the file system
49 * holding the encoded image data would have.
51 * The application may free the encoded image buffer passed to one of the
52 * New() static factory member functions as soon as they return.
56 * Image::LoadingFinishedSignal is emitted when the decoding of the
57 * image data is completed, either successfully or not.
59 * Image::UploadedSignal is emitted when the decoded image data gets
60 * uploaded to the OpenGL ES implementation.
62 class DALI_IMPORT_API EncodedBufferImage : public Image
66 * @brief Constructor which creates an uninitialized EncodedBufferImage object.
68 * Use Image::New(...) to create an initialised object.
73 * @brief Create an initialised image object from an encoded image buffer in memory.
75 * The image will be created eagerly using LoadPolicy::Immediate.
76 * The function is non-blocking and returns immediately while the image
77 * decoding happens on a background thread.
78 * @param [in] encodedImage The encoded bytes of an image, in a supported
79 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
80 * exactly as it would be as a file in the filesystem.
81 * The caller retains ownership of this buffer and is free to modify or
82 * discard it as soon as the function returns.
83 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
85 * @param [in] attributes Requested parameters for loading (size, scaling etc.).
86 * @param [in] releasePol The ReleasePolicy to apply to Image. If the Unused
87 * policy is set, a reload will not be possible, so the Image should never be
88 * used once all actors using it have gone off-stage.
89 * @return A handle to a newly allocated object.
91 static EncodedBufferImage New(const uint8_t * const encodedImage, std::size_t encodedImageByteCount, const ImageAttributes& attributes, ReleasePolicy releasePol = Image::NEVER);
94 * @brief Create an initialised image object from an encoded image buffer in memory.
96 * The image will be created eagerly using LoadPolicy::Immediate.
97 * The function is non-blocking and returns immediately while the image
98 * decoding happens on a background thread.
99 * @param [in] encodedImage The encoded bytes of an image, in a supported
100 * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
101 * exactly as it would be as a file in the filesystem.
102 * The caller retains ownership of this buffer and is free to modify or
103 * discard it as soon as the function returns.
104 * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
106 * @return A handle to a newly allocated object.
108 static EncodedBufferImage New(const uint8_t * const encodedImage, std::size_t encodedImageByteCount);
111 * @brief Downcast an Object handle to EncodedBufferImage.
113 * If handle points to a EncodedBufferImage the
114 * downcast produces valid handle. If not the returned handle is left uninitialized.
115 * @param[in] handle to An object
116 * @return handle to a EncodedBufferImage or an uninitialized handle
118 static EncodedBufferImage DownCast( BaseHandle handle );
123 * This is non-virtual since derived Handle types must not contain data or virtual methods.
125 ~EncodedBufferImage();
128 * @brief This copy constructor is required for (smart) pointer semantics.
130 * @param [in] handle A reference to the copied handle
132 EncodedBufferImage(const EncodedBufferImage& handle);
135 * @brief This assignment operator is required for (smart) pointer semantics.
137 * @param [in] rhs A reference to the copied handle
138 * @return A reference to this
140 EncodedBufferImage& operator=(const EncodedBufferImage& rhs);
142 public: // Not intended for application developers
144 explicit DALI_INTERNAL EncodedBufferImage(Internal::EncodedBufferImage*);
149 #endif // __DALI_ENCODED_BUFFER_IMAGE_H__