Minor coverity issue fixes
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / pixel-buffer.cpp
index f8d12b2..e391463 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -28,20 +28,19 @@ namespace Dali
 {
 namespace Devel
 {
-
-PixelBuffer PixelBuffer::New( unsigned int width,
-                              unsigned int height,
-                              Dali::Pixel::Format pixelFormat )
+PixelBuffer PixelBuffer::New(uint32_t            width,
+                             uint32_t            height,
+                             Dali::Pixel::Format pixelFormat)
 {
   Internal::Adaptor::PixelBufferPtr internal =
-    Internal::Adaptor::PixelBuffer::New( width, height, pixelFormat );
-  return Devel::PixelBuffer( internal.Get() );
+    Internal::Adaptor::PixelBuffer::New(width, height, pixelFormat);
+  return Devel::PixelBuffer(internal.Get());
 }
 
-Dali::PixelData PixelBuffer::Convert( PixelBuffer& pixelBuffer )
+Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer)
 {
   Dali::PixelData pixelData =
-    Internal::Adaptor::PixelBuffer::Convert( GetImplementation(pixelBuffer) );
+    Internal::Adaptor::PixelBuffer::Convert(GetImplementation(pixelBuffer));
   pixelBuffer.Reset();
   return pixelData;
 }
@@ -51,7 +50,6 @@ Dali::PixelData PixelBuffer::CreatePixelData() const
   return GetImplementation(*this).CreatePixelData();
 }
 
-
 PixelBuffer::PixelBuffer()
 {
 }
@@ -60,60 +58,67 @@ PixelBuffer::~PixelBuffer()
 {
 }
 
-PixelBuffer::PixelBuffer( Internal::Adaptor::PixelBuffer* internal )
-: BaseHandle( internal )
+PixelBuffer::PixelBuffer(Internal::Adaptor::PixelBuffer* internal)
+: BaseHandle(internal)
 {
 }
 
-PixelBuffer::PixelBuffer(const PixelBuffer& handle)
-: BaseHandle( handle )
-{
-}
+PixelBuffer::PixelBuffer(const PixelBuffer& handle) = default;
 
-PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs)
-{
-  BaseHandle::operator=(rhs);
-  return *this;
-}
+PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs) = default;
+
+PixelBuffer::PixelBuffer(PixelBuffer&& handle) = default;
+
+PixelBuffer& PixelBuffer::operator=(PixelBuffer&& rhs) = default;
 
-unsigned int PixelBuffer::GetWidth() const
+uint32_t PixelBuffer::GetWidth() const
 {
   return GetImplementation(*this).GetWidth();
 }
 
-unsigned int PixelBuffer::GetHeight() const
+uint32_t PixelBuffer::GetHeight() const
 {
   return GetImplementation(*this).GetHeight();
 }
 
+uint32_t PixelBuffer::GetStride() const
+{
+  return GetImplementation(*this).GetStride();
+}
+
 Pixel::Format PixelBuffer::GetPixelFormat() const
 {
   return GetImplementation(*this).GetPixelFormat();
 }
 
-unsigned char* PixelBuffer::GetBuffer()
+uint8_t* PixelBuffer::GetBuffer()
 {
   return GetImplementation(*this).GetBuffer();
 }
 
-void PixelBuffer::ApplyMask( PixelBuffer mask, float contentScale, bool cropToMask )
+const uint8_t* PixelBuffer::GetBuffer() const
 {
-  GetImplementation(*this).ApplyMask( GetImplementation( mask ), contentScale, cropToMask );
+  return GetImplementation(*this).GetConstBuffer();
 }
 
-void PixelBuffer::ApplyGaussianBlur( const float blurRadius )
+void PixelBuffer::ApplyMask(PixelBuffer mask, float contentScale, bool cropToMask)
 {
-  GetImplementation(*this).ApplyGaussianBlur( blurRadius );
+  GetImplementation(*this).ApplyMask(GetImplementation(mask), contentScale, cropToMask);
 }
 
-void PixelBuffer::Crop( uint16_t x, uint16_t y, uint16_t width, uint16_t height )
+void PixelBuffer::ApplyGaussianBlur(const float blurRadius)
 {
-  GetImplementation(*this).Crop( x, y, ImageDimensions( width, height ) );
+  GetImplementation(*this).ApplyGaussianBlur(blurRadius);
 }
 
-void PixelBuffer::Resize( uint16_t width, uint16_t height )
+void PixelBuffer::Crop(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
 {
-  GetImplementation(*this).Resize( ImageDimensions( width, height ) );
+  GetImplementation(*this).Crop(x, y, ImageDimensions(width, height));
+}
+
+void PixelBuffer::Resize(uint16_t width, uint16_t height)
+{
+  GetImplementation(*this).Resize(ImageDimensions(width, height));
 }
 
 void PixelBuffer::MultiplyColorByAlpha()
@@ -121,14 +126,24 @@ void PixelBuffer::MultiplyColorByAlpha()
   GetImplementation(*this).MultiplyColorByAlpha();
 }
 
-bool PixelBuffer::GetMetadata( Property::Map& metadata ) const
+bool PixelBuffer::GetMetadata(Property::Map& metadata) const
 {
   return GetImplementation(*this).GetMetadata(metadata);
 }
 
-bool PixelBuffer::Rotate( Degree angle )
+bool PixelBuffer::Rotate(Degree angle)
+{
+  return GetImplementation(*this).Rotate(angle);
+}
+
+bool PixelBuffer::IsAlphaPreMultiplied() const
+{
+  return GetImplementation(*this).IsAlphaPreMultiplied();
+}
+
+uint32_t PixelBuffer::GetBrightness() const
 {
-  return GetImplementation(*this).Rotate( angle );
+  return GetImplementation(*this).GetBrightness();
 }
 
 } // namespace Devel