Remove current and future memory leaks with messages by forcing the use of OwnerPoint...
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / texture-impl.cpp
index 704ab40..4887adf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,26 +27,26 @@ namespace Dali
 namespace Internal
 {
 
-NewTexturePtr NewTexture::New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
+TexturePtr Texture::New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
 {
-  NewTexturePtr texture( new NewTexture( type, format, width, height ) );
+  TexturePtr texture( new Texture( type, format, width, height ) );
   texture->Initialize();
   return texture;
 }
 
-NewTexturePtr NewTexture::New( NativeImageInterface& nativeImageInterface )
+TexturePtr Texture::New( NativeImageInterface& nativeImageInterface )
 {
-  NewTexturePtr texture( new NewTexture( &nativeImageInterface ) );
+  TexturePtr texture( new Texture( &nativeImageInterface ) );
   texture->Initialize();
   return texture;
 }
 
-Render::NewTexture* NewTexture::GetRenderObject() const
+Render::Texture* Texture::GetRenderObject() const
 {
   return mRenderObject;
 }
 
-NewTexture::NewTexture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
+Texture::Texture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
 : mEventThreadServices( *Stage::GetCurrent() ),
   mRenderObject( NULL ),
   mNativeImage(),
@@ -57,7 +57,7 @@ NewTexture::NewTexture(TextureType::Type type, Pixel::Format format, unsigned in
 {
 }
 
-NewTexture::NewTexture( NativeImageInterfacePtr nativeImageInterface )
+Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
 : mEventThreadServices( *Stage::GetCurrent() ),
   mRenderObject( NULL ),
   mNativeImage( nativeImageInterface ),
@@ -68,24 +68,25 @@ NewTexture::NewTexture( NativeImageInterfacePtr nativeImageInterface )
 {
 }
 
-void NewTexture::Initialize()
+void Texture::Initialize()
 {
   if( EventThreadServices::IsCoreRunning() )
   {
     if( mNativeImage )
     {
-      mRenderObject = new Render::NewTexture( mNativeImage );
+      mRenderObject = new Render::Texture( mNativeImage );
     }
     else
     {
-      mRenderObject = new Render::NewTexture( mType, mFormat, mWidth, mHeight );
+      mRenderObject = new Render::Texture( mType, mFormat, mWidth, mHeight );
     }
 
-    AddTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+    OwnerPointer< Render::Texture > transferOwnership( mRenderObject );
+    AddTexture( mEventThreadServices.GetUpdateManager(), transferOwnership );
   }
 }
 
-NewTexture::~NewTexture()
+Texture::~Texture()
 {
   if( EventThreadServices::IsCoreRunning() && mRenderObject )
   {
@@ -93,12 +94,12 @@ NewTexture::~NewTexture()
   }
 }
 
-bool NewTexture::Upload( PixelDataPtr pixelData )
+bool Texture::Upload( PixelDataPtr pixelData )
 {
-  return Upload( pixelData, 0u, 0u, 0u, 0u, mWidth, mHeight );
+  return Upload( pixelData, 0u, 0u, 0u, 0u, pixelData->GetWidth(), pixelData->GetHeight() );
 }
 
-bool NewTexture::Upload( PixelDataPtr pixelData,
+bool Texture::Upload( PixelDataPtr pixelData,
                          unsigned int layer, unsigned int mipmap,
                          unsigned int xOffset, unsigned int yOffset,
                          unsigned int width, unsigned int height )
@@ -108,14 +109,14 @@ bool NewTexture::Upload( PixelDataPtr pixelData,
   {
     if( mNativeImage )
     {
-      DALI_LOG_ERROR( "OpenGL ES does not support uploading data to native texture");
+      DALI_LOG_ERROR( "OpenGL ES does not support uploading data to native texture\n");
     }
     else
     {
       unsigned int pixelDataSize = pixelData->GetWidth()*pixelData->GetHeight();
       if( pixelData->GetBuffer() == NULL || pixelDataSize == 0 )
       {
-        DALI_LOG_ERROR( "PixelData is empty");
+        DALI_LOG_ERROR( "PixelData is empty\n");
       }
       else
       {
@@ -124,12 +125,12 @@ bool NewTexture::Upload( PixelDataPtr pixelData,
         {
           if( pixelDataSize < width * height )
           {
-            DALI_LOG_ERROR( "PixelData of an incorrect size when trying to update texture");
+            DALI_LOG_ERROR( "PixelData of an incorrect size when trying to update texture\n");
           }
           else if( ( xOffset + width  > ( mWidth  / (1<<mipmap) ) ) ||
               ( yOffset + height > ( mHeight / (1<<mipmap) ) ) )
           {
-            DALI_LOG_ERROR( "Texture update area out of bounds");
+            DALI_LOG_ERROR( "Texture update area out of bounds\n");
           }
           else
           {
@@ -141,7 +142,7 @@ bool NewTexture::Upload( PixelDataPtr pixelData,
         }
         else
         {
-          DALI_LOG_ERROR( "Bad format");
+          DALI_LOG_ERROR( "Bad format\n");
         }
       }
     }
@@ -150,7 +151,7 @@ bool NewTexture::Upload( PixelDataPtr pixelData,
   return result;
 }
 
-void NewTexture::GenerateMipmaps()
+void Texture::GenerateMipmaps()
 {
   if( EventThreadServices::IsCoreRunning() && mRenderObject )
   {
@@ -158,12 +159,12 @@ void NewTexture::GenerateMipmaps()
   }
 }
 
-unsigned int NewTexture::GetWidth() const
+unsigned int Texture::GetWidth() const
 {
   return mWidth;
 }
 
-unsigned int NewTexture::GetHeight() const
+unsigned int Texture::GetHeight() const
 {
   return mHeight;
 }