#define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public:
/**
* @brief Enumeration for the instance when creating a native image, the color depth has to be specified.
+ * @note This ColorFormat follows pixel byte order.
*/
- enum ColorDepth
+ enum class ColorFormat
{
- COLOR_DEPTH_DEFAULT, ///< Uses the current screen default depth (recommended)
- COLOR_DEPTH_24, ///< 24 bits per pixel
- COLOR_DEPTH_32 ///< 32 bits per pixel
+ BGR888 = 0, /// 8 blue bits, 8 green bits, 8 red bits
+ BGRA8888 = 1, /// 8 blue bits, 8 green bits, 8 red bits, alpha 8 bits
+ BGRX8888 = 2, /// 8 blue bits, 8 green bits, 8 red bits, and 8 ignored bits
+ RGB888 = 3, /// 8 red bits, 8 green bits, 8 blue bits
+ RGBA8888 = 4, /// 8 red bits, 8 green bits, 8 blue bits, alpha 8 bits
+ RGBX8888 = 5, /// 8 red bits, 8 green bits, 8 blue bits, and 8 ignored bits
};
/**
* Depending on hardware, the width and height may have to be a power of two.
* @param[in] width The width of the image
* @param[in] height The height of the image
- * @param[in] depth color depth of the image
+ * @param[in] colorFormat The color format of the image
* @return A smart-pointer to a newly allocated image
*/
- static NativeImageSourceQueuePtr New(uint32_t width, uint32_t height, ColorDepth depth);
+ static NativeImageSourceQueuePtr New(uint32_t width, uint32_t height, ColorFormat colorFormat);
/**
* @brief Creates a new NativeImageSourceQueue from an existing native image source.
void IgnoreSourceImage();
/**
- * @copydoc Dali::NativeImageInterface::GetTextureTarget()
+ * @brief Checks if the buffer can be got from the queue.
+ *
+ * Check the available buffer using this API before call DequeueBuffer()
+ * @return True if the buffer can be got from the queue.
*/
- int GetTextureTarget() const override;
+ bool CanDequeueBuffer();
+
+ /**
+ * @brief Dequeue buffer from the queue.
+ *
+ * Acquire buffer and information of the queue.
+ * it returns the information of the buffer.
+ * @param[out] width The width of buffer
+ * @param[out] height The height of buffer
+ * @param[out] stride The stride of buffer
+ * @return A pointer of buffer
+ */
+ uint8_t* DequeueBuffer(uint32_t& width, uint32_t& height, uint32_t& stride);
+
+ /**
+ * @brief Enqueue buffer to the queue.
+ *
+ * Enqueue buffer to the queue
+ * this requests the release of the buffer internally.
+ * @param[in] buffer A pointer of buffer
+ * @return True if success
+ */
+ bool EnqueueBuffer(uint8_t* buffer);
+
+ /**
+ * @brief Free all released buffers.
+ */
+ void FreeReleasedBuffers();
/**
- * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
+ * @copydoc Dali::NativeImageInterface::GetTextureTarget()
*/
- const char* GetCustomFragmentPrefix() const override;
+ int GetTextureTarget() const override;
/**
* @copydoc Dali::NativeImageInterface::ApplyNativeFragmentShader()
* @brief Private constructor.
* @param[in] width The width of the image
* @param[in] height The height of the image
- * @param[in] depth color depth of the image
+ * @param[in] colorFormat The color format of the image
* @param[in] nativeImageSourceQueue contains either: native image source or is empty
*/
- DALI_INTERNAL NativeImageSourceQueue(uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue);
+ DALI_INTERNAL NativeImageSourceQueue(uint32_t width, uint32_t height, ColorFormat colorFormat, Any nativeImageSourceQueue);
/**
* @brief A reference counted object may only be deleted by calling Unreference().