[3.0] Render textures created from NativeImages error 97/84897/1
authorFerran Sole <ferran.sole@samsung.com>
Thu, 4 Aug 2016 09:45:19 +0000 (10:45 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 22 Aug 2016 17:03:46 +0000 (18:03 +0100)
* GlExtensionDestroy() was not being called on clean-up
* PrepareTexture() was not being called when binding the texture
* Error code returned from TargetTexture() was not being handled

Change-Id: Ie3e8f9d5cc973da8a72eea68838e9443a3421077

dali/internal/render/renderers/render-texture.cpp

index 59c1206c9e0a0f3470de0413c6abbe768e80a071..8ca26470376ddf94362076e1fbb60c6cdac2141a 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;
   }