Added missing newline chars to logging commands
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / native-texture.cpp
index 8ac99c6..8110880 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/vertex.h>
 #include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture.h>
 #include <dali/internal/render/gl-resources/texture-units.h>
+#include <dali/internal/render/gl-resources/gl-texture.h>
 
 namespace Dali
 {
@@ -45,27 +44,30 @@ NativeTexture::NativeTexture(NativeImageInterface* nativeImg, Context& context)
 NativeTexture::~NativeTexture()
 {
   DALI_LOG_INFO (Debug::Filter::gImage, Debug::General, "NativeTexture destroyed\n");
+
   // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
   // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
 }
 
-bool NativeTexture::Bind(GLenum target, TextureUnit textureunit )
+bool NativeTexture::Bind( GLenum target, TextureUnit textureunit )
 {
-  bool created = false;
+  bool result = true;
 
-  if( mId==0 )
+  if( mId == 0 )
   {
-    CreateGlTexture();
-    created = true;
+    result = CreateGlTexture();
   }
 
-  // Bind the texture id
-  mContext.ActiveTexture( textureunit );
-  mContext.Bind2dTexture( mId );
+  if( result )
+  {
+    // Bind the texture id
+    mContext.ActiveTexture( textureunit );
+    mContext.Bind2dTexture(mId);
 
-  mNativeImage->PrepareTexture();
+    mNativeImage->PrepareTexture();
+  }
 
-  return created;
+  return result;
 }
 
 bool NativeTexture::IsFullyOpaque() const
@@ -80,6 +82,12 @@ bool NativeTexture::HasAlphaChannel() const
 
 bool NativeTexture::CreateGlTexture()
 {
+  if( mId != 0 )
+  {
+    DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "GL texture creation duplicate for GL id: %d\n", &mId );
+    return true;
+  }
+
   if( mNativeImage->GlExtensionCreate() )
   {
     mContext.GenTextures( 1, &mId );
@@ -96,7 +104,7 @@ bool NativeTexture::CreateGlTexture()
   }
   else
   {
-    DALI_LOG_ERROR( "Error creating native image!" );
+    DALI_LOG_ERROR( "Error creating native image!\n" );
   }
 
   return mId != 0;
@@ -106,10 +114,9 @@ void NativeTexture::GlCleanup()
 {
   Texture::GlCleanup();
 
-  DALI_ASSERT_DEBUG(mNativeImage);
+  DALI_ASSERT_DEBUG( mNativeImage );
 
   mNativeImage->GlExtensionDestroy();
-
   mNativeImage.Reset();
 }