Add api for setting resource destruction callback.
this callback will be called when NativeImageSource is desroyed its resource
Change-Id: Ib97573c648105b12bf38f601ace89a5b0fc54608
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
\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
*/\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
return image;
}
-NativeImageSourceAndroid::NativeImageSourceAndroid(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+NativeImageSourceAndroid::NativeImageSourceAndroid( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
: mWidth(width),
- mHeight(height),
+ mHeight(height ),
mOwnPixmap(true),
mPixmap(NULL),
mBlendingRequired(false),
mColorDepth(depth),
mEglImageKHR(NULL),
- mEglImageExtensions(NULL)
+ mEglImageExtensions(NULL),
+ mResourceDestructionCallback()
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
+
+ if(mResourceDestructionCallback)
+ {
+ mResourceDestructionCallback->Trigger();
+ }
}
uint32_t NativeImageSourceAndroid::TargetTexture()
return false;
}
+void NativeImageSourceAndroid::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
} // namespace Adaptor
} // namespace Internal
*/
bool ReleaseBuffer() override;
+ /**
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+ */
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
private:
/**
* Private constructor; @see NativeImageSource::New()
void GetPixmapDetails();
private:
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- AHardwareBuffer* mPixmap; ///<
- 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
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ AHardwareBuffer* mPixmap; ///<
+ 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
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
+
namespace Dali
{
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
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource)
-: mImage(MakeRef<CGImageRef>(nullptr))
+: mImage(MakeRef<CGImageRef>(nullptr)),
+ mResourceDestructionCallback()
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
DALI_ASSERT_ALWAYS(nativeImageSource.Empty());
return false;
}
+void NativeImageSourceCocoa::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
} // namespace Dali::Internal::Adaptor
*/
bool ReleaseBuffer() override;
+ /**
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+ */
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
private:
/**
* Private constructor; @see NativeImageSource::New()
private:
CFRef<CGImageRef> mImage;
+ std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
};
} // namespace Dali::Internal::Adaptor
mEglImageExtensions(NULL),
mSetSource(false),
mMutex(),
- mIsBufferAcquired(false)
+ mIsBufferAcquired(false),
+ mResourceDestructionCallback()
+
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
mEglImageKHR = NULL;
}
+
+ if(mResourceDestructionCallback)
+ {
+ mResourceDestructionCallback->Trigger();
+ }
}
uint32_t NativeImageSourceTizen::TargetTexture()
return ret;
}
+void NativeImageSourceTizen::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
} // namespace Adaptor
} // namespace Internal
*/
bool ReleaseBuffer() override;
+ /**
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+ */
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
private:
/**
* Private constructor; @see NativeImageSource::New()
void DestroySurface();
private:
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image height
- bool mOwnTbmSurface; ///< Whether we created pixmap or not
- tbm_surface_h mTbmSurface;
- tbm_format mTbmFormat;
- bool mBlendingRequired; ///< Whether blending is required
- Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
- void* mEglImageKHR; ///< From EGL extension
- EglGraphics* mEglGraphics; ///< EGL Graphics
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
- bool mSetSource;
- mutable Dali::Mutex mMutex;
- bool mIsBufferAcquired; ///< Whether AcquireBuffer is called
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
+ bool mOwnTbmSurface; ///< Whether we created pixmap or not
+ tbm_surface_h mTbmSurface;
+ tbm_format mTbmFormat;
+ bool mBlendingRequired; ///< Whether blending is required
+ Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
+ void* mEglImageKHR; ///< From EGL extension
+ EglGraphics* mEglGraphics; ///< EGL Graphics
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ bool mSetSource;
+ mutable Dali::Mutex mMutex;
+ bool mIsBufferAcquired; ///< Whether AcquireBuffer is called
+ std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
};
} // namespace Adaptor
mBlendingRequired(false),
mColorDepth(depth),
mEglImageKHR(NULL),
- mEglImageExtensions(NULL)
+ mEglImageExtensions(NULL),
+ mResourceDestructionCallback()
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
+
+ if(mResourceDestructionCallback)
+ {
+ mResourceDestructionCallback->Trigger();
+ }
}
uint32_t NativeImageSourceX::TargetTexture()
return false;
}
+void NativeImageSourceX::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
} // namespace Adaptor
} // namespace Internal
*/
bool ReleaseBuffer() override;
+ /**
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+ */
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
private:
/**
* Private constructor; @see NativeImageSource::New()
void GetPixmapDetails();
private:
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- Ecore_X_Pixmap mPixmap; ///< From Xlib
- 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
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ Ecore_X_Pixmap mPixmap; ///< From Xlib
+ 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
mBlendingRequired(false),
mColorDepth(depth),
mEglImageKHR(NULL),
- mEglImageExtensions(NULL)
+ mEglImageExtensions(NULL),
+ mResourceDestructionCallback()
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
+
+ if(mResourceDestructionCallback)
+ {
+ mResourceDestructionCallback->Trigger();
+ }
}
unsigned int NativeImageSourceWin::TargetTexture()
return false;
}
+void NativeImageSourceWin::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
} // namespace Adaptor
} // namespace Internal
*/
bool ReleaseBuffer() override;
+ /**
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
+ */
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
+
private:
/**
* Private constructor; @see NativeImageSource::New()
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