Add API for setting resource destruction callback
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / android / native-image-source-impl-android.cpp
index e06af8e..bb6693f 100644 (file)
@@ -56,15 +56,16 @@ NativeImageSourceAndroid* NativeImageSourceAndroid::New(uint32_t width, uint32_t
   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());
 
@@ -285,6 +286,11 @@ void NativeImageSourceAndroid::DestroyResource()
   mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
 
   mEglImageKHR = NULL;
+
+  if(mResourceDestructionCallback)
+  {
+    mResourceDestructionCallback->Trigger();
+  }
 }
 
 uint32_t NativeImageSourceAndroid::TargetTexture()
@@ -390,6 +396,11 @@ bool NativeImageSourceAndroid::ReleaseBuffer()
   return false;
 }
 
+void NativeImageSourceAndroid::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
 } // namespace Adaptor
 
 } // namespace Internal