(Vector2) Add a Uint16Pair constructor 17/238117/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 8 Jul 2020 17:10:24 +0000 (18:10 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 10 Jul 2020 20:55:29 +0000 (21:55 +0100)
Change-Id: Icb1380d889d12369c040ba67fbe741f39233abe6

automated-tests/src/dali/utc-Dali-Vector2.cpp
dali/public-api/math/vector2.cpp
dali/public-api/math/vector2.h

index be57951..3217d5b 100644 (file)
@@ -83,6 +83,16 @@ int UtcDaliVector2Constructor05P(void)
   END_TEST;
 }
 
+int UtcDaliVector2ConstructorUint16PairP(void)
+{
+  TestApplication application;
+  Uint16Pair pair( 20, 30 );
+  Vector2 vec2(pair);
+  DALI_TEST_EQUALS(vec2.x, 20.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(vec2.y, 30.0f, 0.001, TEST_LOCATION);
+  END_TEST;
+}
+
 int UtcDaliVector2CopyConstructor01P(void)
 {
   TestApplication application;
index 6e4b07a..678a90f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
@@ -26,6 +26,7 @@
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/vector3.h>
 #include <dali/public-api/math/math-utils.h>
+#include <dali/public-api/math/uint-16-pair.h>
 #include <dali/internal/render/common/performance-monitor.h>
 
 namespace Dali
@@ -50,6 +51,12 @@ Vector2::Vector2(const Vector4& vec4)
 {
 }
 
+Vector2::Vector2(const Uint16Pair& pair)
+: width(pair.GetWidth()),
+  height(pair.GetHeight())
+{
+}
+
 Vector2& Vector2::operator=(const Vector3& rhs)
 {
   x = rhs.x;
index f248994..c8df6dd 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_VECTOR_2_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * 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.
@@ -28,6 +28,9 @@
 
 namespace Dali
 {
+
+class Uint16Pair;
+
 /**
  * @addtogroup dali_core_math
  * @{
@@ -98,6 +101,15 @@ public:
    */
   explicit Vector2(const Vector4& vec4);
 
+  /**
+   * @brief Conversion constructor from a Uint16Pair.
+   *
+   * @SINCE_1_9.21
+   *
+   * @param[in] pair The Uint16Pair to create this vector from
+   */
+  Vector2(const Uint16Pair& pair);
+
 // Constants
 
   static const Vector2 ONE;               ///< (1.0f,1.0f)