From: sunghyun kim Date: Thu, 19 Aug 2021 13:33:55 +0000 (+0900) Subject: [Tizen] Add API for setting resource destruction callback X-Git-Tag: accepted/tizen/6.0/unified/20210908.124509^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=b80d34eb658c531558e53721fa44b2df5a853633 [Tizen] Add API for setting resource destruction callback Add api for setting resource destruction callback. this callback will be called when NativeImageSource is desroyed its resource Change-Id: Ib97573c648105b12bf38f601ace89a5b0fc54608 --- diff --git a/dali/devel-api/adaptor-framework/native-image-source-devel.cpp b/dali/devel-api/adaptor-framework/native-image-source-devel.cpp index 948e52b..6b2ea45 100644 --- a/dali/devel-api/adaptor-framework/native-image-source-devel.cpp +++ b/dali/devel-api/adaptor-framework/native-image-source-devel.cpp @@ -40,6 +40,11 @@ bool ReleaseBuffer(NativeImageSource& image) return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).ReleaseBuffer(); } +void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback) +{ + return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).SetResourceDestructionCallback(callback); +} + } // namespace DevelNativeImageSource } // namespace Dali diff --git a/dali/devel-api/adaptor-framework/native-image-source-devel.h b/dali/devel-api/adaptor-framework/native-image-source-devel.h index 605cca5..3ddc317 100644 --- a/dali/devel-api/adaptor-framework/native-image-source-devel.h +++ b/dali/devel-api/adaptor-framework/native-image-source-devel.h @@ -19,6 +19,8 @@ // EXTERNAL INCLUDES #include +#include + namespace Dali { @@ -60,6 +62,15 @@ DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint16_t& widt */ DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image); +/** + * @brief Set the Resource Destruction Callback object + * + * @param image The instance of NativeImageSource. + * @param callback The Resource Destruction callback + * @note Ownership of the callback is passed onto this class. + */ +DALI_ADAPTOR_API void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback); + } // namespace DevelNativeImageSource } // namespace Dali diff --git a/dali/internal/imaging/android/native-image-source-impl-android.cpp b/dali/internal/imaging/android/native-image-source-impl-android.cpp index 2a64bfb..280762c 100755 --- a/dali/internal/imaging/android/native-image-source-impl-android.cpp +++ b/dali/internal/imaging/android/native-image-source-impl-android.cpp @@ -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(callback); +} + } // namespace Adaptor } // namespace internal diff --git a/dali/internal/imaging/android/native-image-source-impl-android.h b/dali/internal/imaging/android/native-image-source-impl-android.h index bd3e101..ba6d20b 100755 --- a/dali/internal/imaging/android/native-image-source-impl-android.h +++ b/dali/internal/imaging/android/native-image-source-impl-android.h @@ -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 mResourceDestructionCallback; }; } // namespace Adaptor diff --git a/dali/internal/imaging/common/native-image-source-impl.h b/dali/internal/imaging/common/native-image-source-impl.h index d0a8010..ab2be5a 100755 --- a/dali/internal/imaging/common/native-image-source-impl.h +++ b/dali/internal/imaging/common/native-image-source-impl.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include 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 diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp index 4c8621d..3cd6831 100755 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp @@ -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(callback); +} } // namespace Adaptor diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h index 502ad7f..77d3bd5 100755 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h @@ -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 mResourceDestructionCallback; }; } // namespace Adaptor diff --git a/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp b/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp index 54ad246..72a90d0 100755 --- a/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp +++ b/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp @@ -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(callback); +} + } // namespace Adaptor } // namespace internal diff --git a/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h b/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h index c905912..7c52239 100755 --- a/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h +++ b/dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h @@ -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 mResourceDestructionCallback; }; } // namespace Adaptor diff --git a/dali/internal/imaging/windows/native-image-source-impl-win.cpp b/dali/internal/imaging/windows/native-image-source-impl-win.cpp index ad4851b..e1ae4e0 100755 --- a/dali/internal/imaging/windows/native-image-source-impl-win.cpp +++ b/dali/internal/imaging/windows/native-image-source-impl-win.cpp @@ -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(callback); +} + } // namespace Adaptor } // namespace internal diff --git a/dali/internal/imaging/windows/native-image-source-impl-win.h b/dali/internal/imaging/windows/native-image-source-impl-win.h index d8b13a0..248358e 100755 --- a/dali/internal/imaging/windows/native-image-source-impl-win.h +++ b/dali/internal/imaging/windows/native-image-source-impl-win.h @@ -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 mResourceDestructionCallback; }; } // namespace Adaptor