[4.0] PixelBuffer::Rotate() amendments.
[platform/core/uifw/dali-adaptor.git] / adaptors / common / pixel-buffer-impl.cpp
index fbf72a1..84b5c9d 100644 (file)
@@ -216,7 +216,7 @@ void PixelBuffer::AllocateFixedSize( uint32_t size )
   mBufferSize = size;
 }
 
-void PixelBuffer::Rotate( Degree angle )
+bool PixelBuffer::Rotate( Degree angle )
 {
   // Check first if Rotate() can perform the operation in the current pixel buffer.
 
@@ -247,7 +247,7 @@ void PixelBuffer::Rotate( Degree angle )
   {
     // Can't rotate the pixel buffer with the current pixel format.
     DALI_LOG_ERROR( "Can't rotate the pixel buffer with the current pixel format\n" );
-    return;
+    return false;
   }
 
   float radians = Radian( angle ).radian;
@@ -259,7 +259,7 @@ void PixelBuffer::Rotate( Degree angle )
   if( radians < Dali::Math::MACHINE_EPSILON_10 )
   {
     // Nothing to do if the angle is zero.
-    return;
+    return true;
   }
 
   const unsigned int pixelSize = Pixel::GetBytesPerPixel( mPixelFormat );
@@ -274,13 +274,21 @@ void PixelBuffer::Rotate( Degree angle )
                            mWidth,
                            mHeight );
 
-  // Release the memory of the current pixel buffer.
-  ReleaseBuffer();
+  // Check whether the rotation succedded and set the new pixel buffer data.
+  const bool success = nullptr != pixelsOut;
 
-  // Set the new pixel buffer.
-  mBuffer = pixelsOut;
-  pixelsOut = nullptr;
-  mBufferSize = mWidth * mHeight * pixelSize;
+  if( success )
+  {
+    // Release the memory of the current pixel buffer.
+    ReleaseBuffer();
+
+    // Set the new pixel buffer.
+    mBuffer = pixelsOut;
+    pixelsOut = nullptr;
+    mBufferSize = mWidth * mHeight * pixelSize;
+  }
+
+  return success;
 }
 
 void PixelBuffer::ScaleAndCrop( float scaleFactor, ImageDimensions cropDimensions )
@@ -456,9 +464,6 @@ void PixelBuffer::MultiplyColorByAlpha()
   }
 }
 
-
-
-
 }// namespace Adaptor
 }// namespace Internal
 }// namespace Dali