[Tizen] Add API for setting resource destruction callback
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / ubuntu-x11 / native-image-source-impl-x.cpp
index c222d3b..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() );
 
@@ -139,7 +140,8 @@ NativeImageSourceX::~NativeImageSourceX()
 {
   if (mOwnPixmap && mPixmap)
   {
-    ecore_x_pixmap_free(mPixmap);
+    // Temporarily disable this as this causes a crash with EFL Version 1.24.0
+    //ecore_x_pixmap_free(mPixmap);
   }
 }
 
@@ -282,12 +284,12 @@ bool NativeImageSourceX::IsColorDepthSupported( Dali::NativeImageSource::ColorDe
   return true;
 }
 
-bool NativeImageSourceX::GlExtensionCreate()
+bool NativeImageSourceX::CreateResource()
 {
   // if the image existed previously delete it.
   if (mEglImageKHR != NULL)
   {
-    GlExtensionDestroy();
+    DestroyResource();
   }
 
   // casting from an unsigned int to a void *, which should then be cast back
@@ -299,7 +301,7 @@ bool NativeImageSourceX::GlExtensionCreate()
   return mEglImageKHR != NULL;
 }
 
-void NativeImageSourceX::GlExtensionDestroy()
+void NativeImageSourceX::DestroyResource()
 {
   mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
 
@@ -350,6 +352,31 @@ int NativeImageSourceX::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth)
   }
 }
 
+int NativeImageSourceX::GetTextureTarget() const
+{
+  return GL_TEXTURE_2D;
+}
+
+const char* NativeImageSourceX::GetCustomFragmentPrefix() const
+{
+  return nullptr;
+}
+
+const char* NativeImageSourceX::GetCustomSamplerTypename() const
+{
+  return nullptr;
+}
+
+Any NativeImageSourceX::GetNativeImageHandle() const
+{
+  return Any(mPixmap);
+}
+
+bool NativeImageSourceX::SourceChanged() const
+{
+  return false;
+}
+
 Ecore_X_Pixmap NativeImageSourceX::GetPixmapFromAny(Any pixmap) const
 {
   if (pixmap.Empty())
@@ -399,6 +426,11 @@ bool NativeImageSourceX::ReleaseBuffer()
   return false;
 }
 
+void NativeImageSourceX::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+  mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
 } // namespace Adaptor
 
 } // namespace internal