[dali_2.3.42] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / native-image-source-queue.h
index cb62fc1..610dce6 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -61,17 +61,22 @@ class DALI_ADAPTOR_API NativeImageSourceQueue : public NativeImageInterface
 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 class ColorFormat
   {
-    RGB888,   /// 8 red bits, 8 green bits, 8 blue bits
-    RGBA8888, /// 8 red bits, 8 green bits, 8 blue bits, alpha 8 bits
-    RGBX8888  /// 8 red bits, 8 green bits, 8 blue bits, and 8 ignored bits
+    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
   };
 
   /**
    * @brief Creates a new NativeImageSourceQueue.
    *        Depending on hardware, the width and height may have to be a power of two.
+   *        It will use 3, or defined by DALI_TBM_SURFACE_QUEUE_SIZE as default.
    * @param[in] width The width of the image
    * @param[in] height The height of the image
    * @param[in] colorFormat The color format of the image
@@ -80,6 +85,18 @@ public:
   static NativeImageSourceQueuePtr New(uint32_t width, uint32_t height, ColorFormat colorFormat);
 
   /**
+   * @brief Creates a new NativeImageSourceQueue with the queue size.
+   *        Depending on hardware, the width and height may have to be a power of two.
+   * @note Since queueCount can increase the memory usage, we recommened queueCount value is less or equal than 3.
+   * @param[in] queueCount The number of queue of the image. If it is 0, will use default.
+   * @param[in] width The width of the image
+   * @param[in] height The height 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 queueCount, uint32_t width, uint32_t height, ColorFormat colorFormat);
+
+  /**
    * @brief Creates a new NativeImageSourceQueue from an existing native image source.
    *
    * @param[in] nativeImageSourceQueue NativeImageSourceQueue must be a any handle with native image source
@@ -141,6 +158,11 @@ public:
   bool EnqueueBuffer(uint8_t* buffer);
 
   /**
+   * @brief Free all released buffers.
+   */
+  void FreeReleasedBuffers();
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetTextureTarget()
    */
   int GetTextureTarget() const override;
@@ -155,6 +177,13 @@ public:
    */
   const char* GetCustomSamplerTypename() const override;
 
+  /**
+   * @brief Get the number of queue count for this image.
+   *
+   * @return The number of queue count.
+   */
+  uint32_t GetQueueCount() const;
+
 private: // native image
   /**
    * @copydoc Dali::NativeImageInterface::CreateResource()
@@ -202,6 +231,11 @@ private: // native image
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetExtension() override;
@@ -210,12 +244,13 @@ private:
   /// @cond internal
   /**
    * @brief Private constructor.
+   * @param[in] queueCount The number of queue of the image. If it is 0, will use default.
    * @param[in] width The width of the image
    * @param[in] height The height 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, ColorFormat colorFormat, Any nativeImageSourceQueue);
+  DALI_INTERNAL NativeImageSourceQueue(uint32_t queueCount, uint32_t width, uint32_t height, ColorFormat colorFormat, Any nativeImageSourceQueue);
 
   /**
    * @brief A reference counted object may only be deleted by calling Unreference().