Add API for setting resource destruction callback
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / windows / native-image-source-impl-win.h
old mode 100755 (executable)
new mode 100644 (file)
index bc2a257..81e2ab2
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace Adaptor
 {
 class EglImageExtensions;
@@ -39,7 +37,6 @@ class EglImageExtensions;
 class NativeImageSourceWin : public Internal::Adaptor::NativeImageSource
 {
 public:
-
   /**
    * Create a new NativeImageSource internally.
    * Depending on hardware the width and height may have to be a power of two.
@@ -49,10 +46,10 @@ public:
    * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
    * @return A smart-pointer to a newly allocated image.
    */
-  static NativeImageSourceWin* New(unsigned int width,
-                          unsigned int height,
-                          Dali::NativeImageSource::ColorDepth depth,
-                          Any nativeImageSource);
+  static NativeImageSourceWin* New(unsigned int                        width,
+                                   unsigned int                        height,
+                                   Dali::NativeImageSource::ColorDepth depth,
+                                   Any                                 nativeImageSource);
   /**
    * @copydoc Dali::NativeImageSource::GetNativeImageSource()
    */
@@ -61,17 +58,17 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetPixels()
    */
-  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
+  bool GetPixels(std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat) const override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetSource( Any source )
    */
-  void SetSource( Any source ) override;
+  void SetSource(Any source) override;
 
   /**
    * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
    */
-  bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+  bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
 
   /**
    * destructor
@@ -79,14 +76,14 @@ public:
   ~NativeImageSourceWin() override;
 
   /**
-   * @copydoc Dali::NativeImageSource::GlExtensionCreate()
+   * @copydoc Dali::NativeImageSource::CreateResource()
    */
-  bool GlExtensionCreate() override;
+  bool CreateResource() override;
 
   /**
-   * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
+   * @copydoc Dali::NativeImageSource::DestroyResource()
    */
-  void GlExtensionDestroy() override;
+  void DestroyResource() override;
 
   /**
    * @copydoc Dali::NativeImageSource::TargetTexture()
@@ -123,6 +120,31 @@ public:
   }
 
   /**
+   * @copydoc Dali::NativeImageInterface::ApplyNativeFragmentShader()
+   */
+  bool ApplyNativeFragmentShader(std::string& shader) override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
+   */
+  const char* GetCustomSamplerTypename() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetTextureTarget()
+   */
+  int GetTextureTarget() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
+   */
+  Any GetNativeImageHandle() const override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::SourceChanged()
+   */
+  bool SourceChanged() const override;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -133,15 +155,19 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
+  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
   bool ReleaseBuffer() override;
 
-private:
+  /**
+   * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+   */
+  void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+private:
   /**
    * Private constructor; @see NativeImageSource::New()
    * @param[in] width The width of the image.
@@ -149,10 +175,10 @@ private:
    * @param[in] colour depth of the image.
    * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
    */
-  NativeImageSourceWin(unsigned int width,
-              unsigned  int height,
-              Dali::NativeImageSource::ColorDepth depth,
-              Any nativeImageSource);
+  NativeImageSourceWin(unsigned int                        width,
+                       unsigned int                        height,
+                       Dali::NativeImageSource::ColorDepth depth,
+                       Any                                 nativeImageSource);
 
   /**
    * 2nd phase construction.
@@ -180,15 +206,15 @@ private:
   void GetPixmapDetails();
 
 private:
-
-  unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image heights
-  bool mOwnPixmap;                            ///< Whether we created pixmap or not
-  unsigned int mPixmap;                       ///< From Windows
-  bool mBlendingRequired;                      ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
-  void* mEglImageKHR;                         ///< From EGL extension
-  EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
+  unsigned int                        mWidth;                         ///< image width
+  unsigned int                        mHeight;                        ///< image heights
+  bool                                mOwnPixmap;                     ///< Whether we created pixmap or not
+  unsigned int                        mPixmap;                        ///< From Windows
+  bool                                mBlendingRequired;              ///< Whether blending is required
+  Dali::NativeImageSource::ColorDepth mColorDepth;                    ///< color depth of image
+  void*                               mEglImageKHR;                   ///< From EGL extension
+  EglImageExtensions*                 mEglImageExtensions;            ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
 };
 
 } // namespace Adaptor