Render textures created from NativeImages where not handled correctly
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-texture.cpp
index 59c1206..8ca2647 100644 (file)
@@ -625,6 +625,11 @@ void NewTexture::Destroy( Context& context )
   if( mId )
   {
     context.DeleteTextures( 1, &mId );
+
+    if( mNativeImage )
+    {
+      mNativeImage->GlExtensionDestroy();
+    }
   }
 }
 
@@ -645,7 +650,12 @@ void NewTexture::Initialize(Context& context)
       context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
 
       // platform specific implementation decides on what GL extension to use
-      mNativeImage->TargetTexture();
+      if( mNativeImage->TargetTexture() != 0u )
+      {
+        context.DeleteTextures( 1, &mId );
+        mNativeImage->GlExtensionDestroy();
+        mId = 0u;
+      }
     }
   }
   else
@@ -803,6 +813,12 @@ bool NewTexture::Bind( Context& context, unsigned int textureUnit, Render::Sampl
 
     ApplySampler( context, sampler );
 
+    if( mNativeImage )
+    {
+      //Allow implementation specific operations after binding the texture
+      mNativeImage->PrepareTexture();
+    }
+
     return true;
   }