Add API for NativeImageQueue
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / native-image-source-queue.h
old mode 100755 (executable)
new mode 100644 (file)
index 0a6f4fe..45f8a16
@@ -2,7 +2,7 @@
 #define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -39,34 +39,35 @@ namespace Adaptor
 {
 class NativeImageSourceQueue;
 }
-}
+} // namespace DALI_INTERNAL
 
 class NativeImageSourceQueue;
 
 /**
  * @brief Pointer to Dali::NativeImageSourceQueue.
  */
-typedef Dali::IntrusivePtr< Dali::NativeImageSourceQueue > NativeImageSourceQueuePtr;
+typedef Dali::IntrusivePtr<Dali::NativeImageSourceQueue> NativeImageSourceQueuePtr;
 
 /**
  * @brief Used for displaying native images.
  *
- * NativeImageSource can be created internally or externally by native image source.
  * NativeImage is a platform specific way of providing pixel data to the GPU for rendering,for example via an EGL image.
+ * NativeImageSourceQueue can be created internally or externally by native image source.
+ * It has a queue which handles some image buffers.
+ * Someone should fill the buffers and enqueue them, then DALi will show them.
  */
 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.
     */
-   enum ColorDepth
-   {
-     COLOR_DEPTH_DEFAULT,     ///< Uses the current screen default depth (recommended)
-     COLOR_DEPTH_24,          ///< 24 bits per pixel
-     COLOR_DEPTH_32           ///< 32 bits per pixel
-   };
+  enum ColorDepth
+  {
+    COLOR_DEPTH_DEFAULT, ///< Uses the current screen default depth (recommended)
+    COLOR_DEPTH_24,      ///< 24 bits per pixel
+    COLOR_DEPTH_32       ///< 32 bits per pixel
+  };
 
   /**
    * @brief Creates a new NativeImageSourceQueue.
@@ -76,7 +77,7 @@ public:
    * @param[in] depth color depth of the image
    * @return A smart-pointer to a newly allocated image
    */
-  static NativeImageSourceQueuePtr New( unsigned int width, unsigned int height, ColorDepth depth );
+  static NativeImageSourceQueuePtr New(uint32_t width, uint32_t height, ColorDepth depth);
 
   /**
    * @brief Creates a new NativeImageSourceQueue from an existing native image source.
@@ -85,7 +86,7 @@ public:
    * @return A smart-pointer to a newly allocated image
    * @see NativeImageInterface
    */
-  static NativeImageSourceQueuePtr New( Any nativeImageSourceQueue );
+  static NativeImageSourceQueuePtr New(Any nativeImageSourceQueue);
 
   /**
    * @brief Retrieves the internal native image.
@@ -95,56 +96,122 @@ public:
   Any GetNativeImageSourceQueue();
 
   /**
-   * @brief Sets an existing source.
+   * @brief Sets the size of the image.
+   *
+   * @param[in] width The width of the image
+   * @param[in] height The height of the image
+   */
+  void SetSize(uint32_t width, uint32_t height);
+
+  /**
+   * @brief Ignores a source image which is inserted to the queue.
+   *
+   * @note This can be called from worker threads.
+   */
+  void IgnoreSourceImage();
+
+  /**
+   * @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.
+   */
+  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.
    *
-   * @param[in] source Any handle with the source
+   * 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);
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetTextureTarget()
+   */
+  int GetTextureTarget() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
+   */
+  const char* GetCustomFragmentPrefix() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::ApplyNativeFragmentShader()
    */
-  void SetSource( Any source );
+  bool ApplyNativeFragmentShader(std::string& shader) override;
 
-private:   // native image
+  /**
+   * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
+   */
+  const char* GetCustomSamplerTypename() const override;
 
+private: // native image
   /**
-   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
+   * @copydoc Dali::NativeImageInterface::CreateResource()
    */
-  virtual bool GlExtensionCreate();
+  bool CreateResource() override;
 
   /**
-   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
+   * @copydoc Dali::NativeImageInterface::DestroyResource()
    */
-  virtual void GlExtensionDestroy();
+  void DestroyResource() override;
 
   /**
    * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
-  virtual unsigned int TargetTexture();
+  uint32_t TargetTexture() override;
 
   /**
    * @copydoc Dali::NativeImageInterface::PrepareTexture()
    */
-  virtual void PrepareTexture();
+  void PrepareTexture() override;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetWidth()
    */
-  virtual unsigned int GetWidth() const;
+  uint32_t GetWidth() const override;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetHeight()
    */
-  virtual unsigned int GetHeight() const;
+  uint32_t GetHeight() const override;
 
   /**
    * @copydoc Dali::NativeImageInterface::RequiresBlending()
    */
-  virtual bool RequiresBlending() const;
+  bool RequiresBlending() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
+   */
+  Any GetNativeImageHandle() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::SourceChanged()
+   */
+  bool SourceChanged() const override;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
-  NativeImageInterface::Extension* GetExtension();
+  NativeImageInterface::Extension* GetExtension() override;
 
 private:
-
   /// @cond internal
   /**
    * @brief Private constructor.
@@ -153,14 +220,14 @@ private:
    * @param[in] depth color depth of the image
    * @param[in] nativeImageSourceQueue contains either: native image source or is empty
    */
-  DALI_INTERNAL NativeImageSourceQueue( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSourceQueue );
+  DALI_INTERNAL NativeImageSourceQueue(uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue);
 
   /**
    * @brief A reference counted object may only be deleted by calling Unreference().
    *
    * The implementation should destroy the NativeImage resources.
    */
-  DALI_INTERNAL virtual ~NativeImageSourceQueue();
+  DALI_INTERNAL ~NativeImageSourceQueue() override;
 
   /**
    * @brief Undefined copy constructor.
@@ -168,7 +235,7 @@ private:
    * This avoids accidental calls to a default copy constructor.
    * @param[in] nativeImageSourceQueue A reference to the object to copy
    */
-  DALI_INTERNAL NativeImageSourceQueue( const NativeImageSourceQueue& nativeImageSourceQueue );
+  DALI_INTERNAL NativeImageSourceQueue(const NativeImageSourceQueue& nativeImageSourceQueue);
 
   /**
    * @brief Undefined assignment operator.
@@ -180,9 +247,8 @@ private:
   /// @endcond
 
 private:
-
   /// @cond internal
-  std::unique_ptr< Internal::Adaptor::NativeImageSourceQueue > mImpl; ///< Implementation pointer
+  std::unique_ptr<Internal::Adaptor::NativeImageSourceQueue> mImpl; ///< Implementation pointer
   /// @endcond
 };