Use the default methods in the rect class rather 51/242351/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 25 Aug 2020 14:03:31 +0000 (15:03 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 26 Aug 2020 13:56:15 +0000 (14:56 +0100)
Change-Id: Ib99649fada571d2ed933e644fbcdbe0cab52c4e1

dali/public-api/file.list
dali/public-api/math/rect.cpp [new file with mode: 0644]
dali/public-api/math/rect.h

index aee008e..4b4d5b6 100644 (file)
@@ -42,6 +42,7 @@ SET( public_api_src_files
   ${public_api_src_dir}/math/matrix.cpp
   ${public_api_src_dir}/math/matrix3.cpp
   ${public_api_src_dir}/math/quaternion.cpp
+  ${public_api_src_dir}/math/rect.cpp
   ${public_api_src_dir}/math/vector2.cpp
   ${public_api_src_dir}/math/vector3.cpp
   ${public_api_src_dir}/math/vector4.cpp
diff --git a/dali/public-api/math/rect.cpp b/dali/public-api/math/rect.cpp
new file mode 100644 (file)
index 0000000..94bd0c6
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/math/rect.h>
+
+namespace Dali
+{
+// Ensure Rect is maintained as a trivially copyable type
+static_assert(std::is_trivially_copyable<Rect<float>>::value);
+} // namespace Dali
+
index 9d136d4..3de2dd0 100644 (file)
@@ -36,7 +36,6 @@ namespace Dali
  * @brief Template class to create and operate on rectangles.
  * @SINCE_1_0.0
  */
-
 template< typename T = float >
 struct Rect
 {
@@ -86,72 +85,38 @@ struct Rect
   }
 
   /**
-   * @brief Copy constructor.
+   * @brief Default copy constructor.
    *
-   * @SINCE_1_0.0
+   * @SINCE_1_9.27
    * @param[in] rhs The original object
    */
-  Rect(const Rect<T>& rhs)
-  {
-    x = rhs.x;
-    y = rhs.y;
-    width = rhs.width;
-    height = rhs.height;
-  }
+  Rect( const Rect<T>& rhs ) = default;
 
   /**
-   * @brief Copy assignment operator.
+   * @brief Default copy assignment operator.
    *
-   * @SINCE_1_0.0
+   * @SINCE_1_9.27
    * @param[in] rhs The original object
    * @return Reference to this
    */
-  Rect<T>& operator= (const Rect<T>& rhs)
-  {
-    if (this != &rhs)
-    {
-      x = rhs.x;
-      y = rhs.y;
-      width = rhs.width;
-      height = rhs.height;
-    }
-
-    return *this;
-  }
+  Rect<T>& operator=( const Rect<T>& rhs ) = default;
 
   /**
-   * @brief Move constructor.
+   * @brief Default move constructor.
    *
-   * @SINCE_1_9.21
+   * @SINCE_1_9.27
    * @param[in] rhs The original object
    */
-  Rect<T>( Rect<T>&& rhs )
-  : x( rhs.x ),
-    y( rhs.y ),
-    width( rhs.width ),
-    height( rhs.height )
-  {
-  }
+  Rect<T>( Rect<T>&& rhs ) = default;
 
   /**
-   * @brief Move assignment operator.
+   * @brief Default move assignment operator.
    *
-   * @SINCE_1_9.21
+   * @SINCE_1_9.27
    * @param[in] rhs The original object
    * @return Reference to this
    */
-  Rect<T>& operator=( Rect<T>&& rhs )
-  {
-    if (this != &rhs)
-    {
-      x = rhs.x;
-      y = rhs.y;
-      width = rhs.width;
-      height = rhs.height;
-    }
-
-    return *this;
-  }
+  Rect<T>& operator=( Rect<T>&& rhs ) = default;
 
   /**
    * @brief Assignment operator.
@@ -160,7 +125,7 @@ struct Rect
    * @param[in] vec4 The Vector4 to assign
    * @return Reference to this
    */
-  Rect<T>& operator= (const Vector4& vec4)
+  Rect<T>& operator=(const Vector4& vec4)
   {
     x = vec4.x;
     y = vec4.y;