Merge "use modern construct '= default' for special functions." into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / common / blending-options.cpp
index 17668a0..81b4db4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
@@ -241,7 +241,7 @@ namespace Internal
 
 BlendingOptions::BlendingOptions()
 : mBitmask( 0u ),
-  mBlendColor( NULL )
+  mBlendColor( nullptr )
 {
   SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA,
                 BlendFactor::ONE,       BlendFactor::ONE_MINUS_SRC_ALPHA );
@@ -249,10 +249,7 @@ BlendingOptions::BlendingOptions()
   SetBlendEquation( BlendEquation::ADD, BlendEquation::ADD );
 }
 
-BlendingOptions::~BlendingOptions()
-{
-  delete mBlendColor;
-}
+BlendingOptions::~BlendingOptions() = default;
 
 void BlendingOptions::SetBitmask( unsigned int bitmask )
 {
@@ -315,31 +312,27 @@ BlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const
 
 void BlendingOptions::SetBlendColor( const Vector4& color )
 {
-  if( Vector4::ZERO == color )
+  if( Color::TRANSPARENT == color )
   {
-    if( mBlendColor )
-    {
-      // Discard unnecessary vector
-      delete mBlendColor;
-      mBlendColor = NULL;
-    }
-    return;
-  }
-
-  if( mBlendColor )
-  {
-    *mBlendColor = color;
+    mBlendColor = nullptr;
   }
   else
   {
-    // Lazy allocation when non-default is set
-    mBlendColor = new Vector4( color );
+    if( mBlendColor )
+    {
+      *mBlendColor = color;
+    }
+    else
+    {
+      // Lazy allocation when non-default is set
+      mBlendColor = new Vector4( color );
+    }
   }
 }
 
 const Vector4* BlendingOptions::GetBlendColor() const
 {
-  return mBlendColor;
+  return mBlendColor.Get();
 }
 
 } // namespace Internal