[Tizen] Add API for setting resource destruction callback 97/262897/5 accepted/tizen/6.0/unified/20210908.124509 submit/tizen_6.0/20210908.054804
authorsunghyun kim <scholb.kim@samsung.com>
Thu, 19 Aug 2021 13:33:55 +0000 (22:33 +0900)
committertscholb <scholb.kim@samsung.com>
Thu, 26 Aug 2021 06:11:08 +0000 (02:11 -0400)
Add api for setting resource destruction callback.
this callback will be called when NativeImageSource is desroyed its resource

Change-Id: Ib97573c648105b12bf38f601ace89a5b0fc54608

dali/devel-api/adaptor-framework/native-image-source-devel.cpp
dali/devel-api/adaptor-framework/native-image-source-devel.h
dali/internal/imaging/android/native-image-source-impl-android.cpp
dali/internal/imaging/android/native-image-source-impl-android.h
dali/internal/imaging/common/native-image-source-impl.h
dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-impl-tizen.h
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h
dali/internal/imaging/windows/native-image-source-impl-win.cpp
dali/internal/imaging/windows/native-image-source-impl-win.h

index 948e52b..6b2ea45 100644 (file)
@@ -40,6 +40,11 @@ bool ReleaseBuffer(NativeImageSource& image)
   return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).ReleaseBuffer();\r
 }\r
 \r
+void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback)\r
+{\r
+  return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).SetResourceDestructionCallback(callback);\r
+}\r
+\r
 } // namespace DevelNativeImageSource\r
 \r
 } // namespace Dali\r
index 605cca5..3ddc317 100644 (file)
@@ -19,6 +19,8 @@
 \r
 // EXTERNAL INCLUDES\r
 #include <dali/public-api/adaptor-framework/native-image-source.h>\r
+#include <dali/devel-api/adaptor-framework/event-thread-callback.h>\r
+\r
 \r
 namespace Dali\r
 {\r
@@ -60,6 +62,15 @@ DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint16_t& widt
  */\r
 DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image);\r
 \r
+/**\r
+ * @brief Set the Resource Destruction Callback object\r
+ *\r
+ * @param image The instance of NativeImageSource.\r
+ * @param callback The Resource Destruction callback\r
+ * @note Ownership of the callback is passed onto this class.\r
+ */\r
+DALI_ADAPTOR_API void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback);\r
+\r
 } // namespace DevelNativeImageSource\r
 \r
 } // namespace Dali\r
index 2a64bfb..280762c 100755 (executable)
@@ -74,7 +74,8 @@ NativeImageSourceAndroid::NativeImageSourceAndroid( uint32_t width, uint32_t hei
   mBlendingRequired( false ),
   mColorDepth( depth ),
   mEglImageKHR( NULL ),
-  mEglImageExtensions( NULL )
+  mEglImageExtensions( NULL ),
+  mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
 
@@ -381,6 +382,11 @@ bool NativeImageSourceAndroid::ReleaseBuffer()
   return false;
 }
 
+void NativeImageSourceAndroid::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
 } // namespace Adaptor
 
 } // namespace internal
index bd3e101..ba6d20b 100755 (executable)
@@ -176,6 +176,11 @@ public:
    */
   bool ReleaseBuffer() override;
 
+  /**
+   * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+   */
+  void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
 private:
 
   /**
@@ -218,6 +223,7 @@ private:
   Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
   void* mEglImageKHR;                         ///< From EGL extension
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;
 };
 
 } // namespace Adaptor
index d0a8010..ab2be5a 100755 (executable)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/devel-api/adaptor-framework/bitmap-saver.h>
+#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
 
 namespace Dali
 {
@@ -154,6 +155,11 @@ public:
   virtual bool ReleaseBuffer() = 0;
 
   /**
+   * @brief Dali::DevelNativeImageSource::SetResourceDestructionCallback()
+   */
+  virtual void SetResourceDestructionCallback(EventThreadCallback* callback) = 0;
+
+  /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
    */
   inline bool EncodeToFile( const std::string& filename ) const
index 4c8621d..3cd6831 100755 (executable)
@@ -88,7 +88,8 @@ NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height,
   mEglImageExtensions( NULL ),
   mSetSource( false ),
   mMutex(),
-  mIsBufferAcquired( false )
+  mIsBufferAcquired( false ),
+  mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
 
@@ -427,6 +428,11 @@ void NativeImageSourceTizen::DestroyResource()
 
     mEglImageKHR = NULL;
   }
+
+  if(mResourceDestructionCallback)
+  {
+    mResourceDestructionCallback->Trigger();
+  }
 }
 
 uint32_t NativeImageSourceTizen::TargetTexture()
@@ -543,6 +549,10 @@ bool NativeImageSourceTizen::ReleaseBuffer()
   return ret;
 }
 
+void NativeImageSourceTizen::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
 
 } // namespace Adaptor
 
index 502ad7f..77d3bd5 100755 (executable)
@@ -172,6 +172,11 @@ public:
    */
   bool ReleaseBuffer() override;
 
+  /**
+   * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+   */
+  void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
 private:
 
   /**
@@ -195,7 +200,6 @@ private:
   void DestroySurface();
 
 private:
-
   uint32_t mWidth;                        ///< image width
   uint32_t mHeight;                       ///< image height
   bool mOwnTbmSurface;                        ///< Whether we created pixmap or not
@@ -209,6 +213,7 @@ private:
   bool mSetSource;
   mutable Dali::Mutex mMutex;
   bool mIsBufferAcquired;                      ///< Whether AcquireBuffer is called
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;
 };
 
 } // namespace Adaptor
index 54ad246..72a90d0 100755 (executable)
@@ -93,7 +93,8 @@ NativeImageSourceX::NativeImageSourceX( uint32_t width, uint32_t height, Dali::N
   mBlendingRequired( false ),
   mColorDepth( depth ),
   mEglImageKHR( NULL ),
-  mEglImageExtensions( NULL )
+  mEglImageExtensions( NULL ),
+  mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
 
@@ -425,6 +426,11 @@ bool NativeImageSourceX::ReleaseBuffer()
   return false;
 }
 
+void NativeImageSourceX::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
 } // namespace Adaptor
 
 } // namespace internal
index c905912..7c52239 100755 (executable)
@@ -171,6 +171,11 @@ public:
    */
   bool ReleaseBuffer() override;
 
+  /**
+   * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+   */
+  void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
 private:
 
   /**
@@ -220,6 +225,7 @@ private:
   Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
   void* mEglImageKHR;                         ///< From EGL extension
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;
 };
 
 } // namespace Adaptor
index ad4851b..e1ae4e0 100755 (executable)
@@ -60,7 +60,8 @@ NativeImageSourceWin::NativeImageSourceWin( unsigned int width, unsigned int hei
   mBlendingRequired( false ),
   mColorDepth( depth ),
   mEglImageKHR( NULL ),
-  mEglImageExtensions( NULL )
+  mEglImageExtensions( NULL ),
+  mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
 
@@ -266,6 +267,11 @@ bool NativeImageSourceWin::ReleaseBuffer()
   return false;
 }
 
+void NativeImageSourceWin::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
 } // namespace Adaptor
 
 } // namespace internal
index d8b13a0..248358e 100755 (executable)
@@ -165,6 +165,11 @@ public:
    */
   bool ReleaseBuffer() override;
 
+  /**
+   * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+   */
+  void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
 private:
 
   /**
@@ -214,6 +219,7 @@ private:
   Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
   void* mEglImageKHR;                         ///< From EGL extension
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;
 };
 
 } // namespace Adaptor