1 #ifndef DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
2 #define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
5 * Copyright (c) 2020 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.
22 #include <dali/public-api/images/native-image-interface.h>
23 #include <dali/public-api/object/any.h>
27 #include <dali/public-api/dali-adaptor-common.h>
32 * @addtogroup dali_adaptor_framework
36 namespace Internal DALI_INTERNAL
40 class NativeImageSourceQueue;
42 } // namespace DALI_INTERNAL
44 class NativeImageSourceQueue;
47 * @brief Pointer to Dali::NativeImageSourceQueue.
49 typedef Dali::IntrusivePtr<Dali::NativeImageSourceQueue> NativeImageSourceQueuePtr;
52 * @brief Used for displaying native images.
54 * NativeImage is a platform specific way of providing pixel data to the GPU for rendering,for example via an EGL image.
55 * NativeImageSourceQueue can be created internally or externally by native image source.
56 * It has a queue which handles some image buffers.
57 * Someone should fill the buffers and enqueue them, then DALi will show them.
59 class DALI_ADAPTOR_API NativeImageSourceQueue : public NativeImageInterface
63 * @brief Enumeration for the instance when creating a native image, the color depth has to be specified.
67 COLOR_DEPTH_DEFAULT, ///< Uses the current screen default depth (recommended)
68 COLOR_DEPTH_24, ///< 24 bits per pixel
69 COLOR_DEPTH_32 ///< 32 bits per pixel
73 * @brief Creates a new NativeImageSourceQueue.
74 * Depending on hardware, the width and height may have to be a power of two.
75 * @param[in] width The width of the image
76 * @param[in] height The height of the image
77 * @param[in] depth color depth of the image
78 * @return A smart-pointer to a newly allocated image
80 static NativeImageSourceQueuePtr New(uint32_t width, uint32_t height, ColorDepth depth);
83 * @brief Creates a new NativeImageSourceQueue from an existing native image source.
85 * @param[in] nativeImageSourceQueue NativeImageSourceQueue must be a any handle with native image source
86 * @return A smart-pointer to a newly allocated image
87 * @see NativeImageInterface
89 static NativeImageSourceQueuePtr New(Any nativeImageSourceQueue);
92 * @brief Retrieves the internal native image.
94 * @return Any object containing the internal native image source queue
96 Any GetNativeImageSourceQueue();
99 * @brief Sets the size of the image.
101 * @param[in] width The width of the image
102 * @param[in] height The height of the image
104 void SetSize(uint32_t width, uint32_t height);
107 * @brief Ignores a source image which is inserted to the queue.
109 * @note This can be called from worker threads.
111 void IgnoreSourceImage();
114 * @copydoc Dali::NativeImageInterface::GetTextureTarget()
116 int GetTextureTarget() const override;
119 * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
121 const char* GetCustomFragmentPrefix() const override;
124 * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
126 const char* GetCustomSamplerTypename() const override;
128 private: // native image
130 * @copydoc Dali::NativeImageInterface::CreateResource()
132 bool CreateResource() override;
135 * @copydoc Dali::NativeImageInterface::DestroyResource()
137 void DestroyResource() override;
140 * @copydoc Dali::NativeImageInterface::TargetTexture()
142 uint32_t TargetTexture() override;
145 * @copydoc Dali::NativeImageInterface::PrepareTexture()
147 void PrepareTexture() override;
150 * @copydoc Dali::NativeImageInterface::GetWidth()
152 uint32_t GetWidth() const override;
155 * @copydoc Dali::NativeImageInterface::GetHeight()
157 uint32_t GetHeight() const override;
160 * @copydoc Dali::NativeImageInterface::RequiresBlending()
162 bool RequiresBlending() const override;
165 * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
167 Any GetNativeImageHandle() const override;
170 * @copydoc Dali::NativeImageInterface::SourceChanged()
172 bool SourceChanged() const override;
175 * @copydoc Dali::NativeImageInterface::GetExtension()
177 NativeImageInterface::Extension* GetExtension() override;
182 * @brief Private constructor.
183 * @param[in] width The width of the image
184 * @param[in] height The height of the image
185 * @param[in] depth color depth of the image
186 * @param[in] nativeImageSourceQueue contains either: native image source or is empty
188 DALI_INTERNAL NativeImageSourceQueue(uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue);
191 * @brief A reference counted object may only be deleted by calling Unreference().
193 * The implementation should destroy the NativeImage resources.
195 DALI_INTERNAL ~NativeImageSourceQueue() override;
198 * @brief Undefined copy constructor.
200 * This avoids accidental calls to a default copy constructor.
201 * @param[in] nativeImageSourceQueue A reference to the object to copy
203 DALI_INTERNAL NativeImageSourceQueue(const NativeImageSourceQueue& nativeImageSourceQueue);
206 * @brief Undefined assignment operator.
208 * This avoids accidental calls to a default assignment operator.
209 * @param[in] rhs A reference to the object to copy
211 DALI_INTERNAL NativeImageSourceQueue& operator=(const NativeImageSourceQueue& rhs);
216 std::unique_ptr<Internal::Adaptor::NativeImageSourceQueue> mImpl; ///< Implementation pointer
225 #endif // DALI_NATIVE_IMAGE_SOURCE_QUEUE_H