Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / math / matrix3.h
index 2c8a3bb..8876bc1 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_MATRIX3_H__
-#define __DALI_MATRIX3_H__
+#ifndef DALI_MATRIX3_H
+#define DALI_MATRIX3_H
 
 /*
- * Copyright (c) 2014 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.
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/common/type-traits.h>
 #include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/vector3.h>
 
-namespace Dali DALI_IMPORT_API
+namespace Dali
 {
+/**
+ * @addtogroup dali_core_math
+ * @{
+ */
 
 class Matrix;
 struct Vector2;
@@ -31,40 +36,58 @@ struct Vector2;
 /**
  * @brief A 3x3 matrix.
  *
+ * The matrix is stored as a flat array and is Column Major, i.e. the storage order is as follows (numbers represent
+ * indices of array):
+ *
+ * @code
+ *
+ * 0  3  6
+ * 1  4  7
+ * 2  5  8
+ *
+ * @endcode
+ *
+ * Each axis is contiguous in memory, so the x-axis corresponds to elements 0, 1 and 2, the y-axis corresponds to
+ * elements 3, 4 and 5, and the z-axis corresponds to elements 6, 7 and 8.
+ *
+ * @SINCE_1_0.0
  */
-class DALI_IMPORT_API Matrix3
+class DALI_CORE_API Matrix3
 {
 public:
-
-  friend std::ostream& operator<< (std::ostream& o, const Matrix3& matrix);
+  friend DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix);
 
   /**
-   * @brief The identity matrix
+   * @brief The identity matrix.
    */
   static const Matrix3 IDENTITY;
 
   /**
    * @brief Constructor.
+   * @SINCE_1_0.0
    */
   Matrix3();
 
   /**
    * @brief Copy Constructor.
    *
-   * @param[in] m Another 3x3 matrix
+   * @SINCE_1_0.0
+   * @param[in] m A reference to the copied 3x3 matrix
    */
   Matrix3(const Matrix3& m);
 
   /**
    * @brief Constructor.
    *
-   * @param[in] m A 4x4 matrix. The translation and shear components are ignored.
+   * @SINCE_1_0.0
+   * @param[in] m A 4x4 matrix. The translation and shear components are ignored
    */
   Matrix3(const Matrix& m);
 
   /**
    * @brief Constructor.
    *
+   * @SINCE_1_0.0
    * @param[in] s00 First element
    * @param[in] s01 Second element
    * @param[in] s02 Third element
@@ -78,48 +101,69 @@ public:
   Matrix3(float s00, float s01, float s02, float s10, float s11, float s12, float s20, float s21, float s22);
 
   /**
-   * @brief Assignment Operator
-   * @param matrix from which to copy values
-   * @return reference to this object
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.21
+   * @param[in] matrix A reference to the moved matrix
    */
-  Matrix3& operator=( const Matrix3& matrix );
+  Matrix3(Matrix3&& matrix);
 
   /**
-   * @brief Assignment Operator
-   * @param matrix from which to copy values
-   * @return reference to this object
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.21
+   * @param[in] matrix A reference to the moved matrix
+   * @return A reference to this
+   */
+  Matrix3& operator=(Matrix3&& matrix);
+
+  /**
+   * @brief Assignment Operator.
+   * @SINCE_1_0.0
+   * @param[in] matrix From which to copy values
+   * @return Reference to this object
+   */
+  Matrix3& operator=(const Matrix3& matrix);
+
+  /**
+   * @brief Assignment Operator.
+   * @SINCE_1_0.0
+   * @param[in] matrix A reference to the copied matrix
+   * @return A reference to this
    */
-  Matrix3& operator=( const Matrix& matrix );
+  Matrix3& operator=(const Matrix& matrix);
 
   /**
    * @brief The equality operator.
    *
-   * Utilises appropriate machine epsilon values.
+   * Utilizes appropriate machine epsilon values.
    *
-   * @param [in] rhs    the Matrix to compare this to
-   * @return true if the matrices are equal
+   * @SINCE_1_0.0
+   * @param[in] rhs The Matrix to compare this to
+   * @return True if the matrices are equal
    */
-  bool operator==(const Matrix3 & rhs) const;
+  bool operator==(const Matrix3& rhs) const;
 
   /**
    * @brief The inequality operator.
    *
-   * Utilises appropriate machine epsilon values.
+   * Utilizes appropriate machine epsilon values.
    *
-   * @param [in] rhs    the Matrix to compare this to
+   * @SINCE_1_0.0
+   * @param[in] rhs The Matrix to compare this to
    * @return true if the matrices are equal
    */
-  bool operator!=(const Matrix3 & rhs) const;
+  bool operator!=(const Matrix3& rhs) const;
 
   /**
    * @brief Destructor.
+   * @SINCE_1_0.0
    */
-  ~Matrix3()
-  {
-  }
+  ~Matrix3() = default;
 
   /**
    * @brief Sets the matrix to the identity matrix.
+   * @SINCE_1_0.0
    */
   void SetIdentity();
 
@@ -127,42 +171,56 @@ public:
    * @brief Returns the contents of the matrix as an array of 9 floats.
    *
    * The order of the values for a matrix is:
-   *   xAxis.x yAxis.x zAxis.x
-   *   xAxis.y yAxis.y zAxis.y
-   *   xAxis.z yAxis.z zAxis.z
-   * @return the matrix contents as an array of 9 floats.
+   *
+   * @code
+   * [ xAxis.x, xAxis.y, xAxis.z, yAxis.x, yAxis.y, yAxis.z, zAxis.x, zAxis.y, zAxis.z ]
+   * @endcode
+   *
+   * @SINCE_1_0.0
+   * @return The matrix contents as an array of 9 floats
    */
-  const float* AsFloat() const {return &mElements[0];}
+  const float* AsFloat() const
+  {
+    return &mElements[0];
+  }
 
   /**
    * @brief Returns the contents of the matrix as an array of 9 floats.
    *
    * The order of the values for a matrix is:
-   *   xAxis.x yAxis.x zAxis.x
-   *   xAxis.y yAxis.y zAxis.y
-   *   xAxis.z yAxis.z zAxis.z
-   * @return the matrix contents as an array of 9 floats.
+   *
+   * @code
+   * [ xAxis.x, xAxis.y, xAxis.z, yAxis.x, yAxis.y, yAxis.z, zAxis.x, zAxis.y, zAxis.z ]
+   * @endcode
+   *
+   * @SINCE_1_0.0
+   * @return The matrix contents as an array of 9 floats
    */
-  float* AsFloat() {return &mElements[0];}
+  float* AsFloat()
+  {
+    return &mElements[0];
+  }
 
   /**
    * @brief Inverts the matrix.
    *
-   * @return true if successful
+   * @SINCE_1_0.0
+   * @return True if successful
    */
   bool Invert();
 
   /**
-   * @brief Swaps the rows to columns
-   * @return true
+   * @brief Swaps the rows to columns.
+   * @SINCE_1_0.0
+   * @return True if successful
    */
   bool Transpose();
 
   /**
    * @brief Multiplies all elements of the matrix by the scale value.
    *
-   * @param scale - the value by which to scale the whole matrix.
-
+   * @SINCE_1_0.0
+   * @param[in] scale The value by which to scale the whole matrix
    */
   void Scale(float scale);
 
@@ -171,7 +229,8 @@ public:
    * elements * 3.
    *
    * (The Magnitude of the unit matrix is therefore 1)
-   * @return the magnitude - always positive.
+   * @SINCE_1_0.0
+   * @return The magnitude - always positive
    */
   float Magnitude() const;
 
@@ -181,8 +240,9 @@ public:
    * average 1.
    *
    * If the matrix is not invertible, then the matrix is left unchanged.
-
-   * @return true if the matrix is invertible, otherwise false
+   *
+   * @SINCE_1_0.0
+   * @return @c true if the matrix is invertible, otherwise @c false
    */
   bool ScaledInverseTranspose();
 
@@ -190,26 +250,43 @@ public:
    * @brief Function to multiply two matrices and store the result onto third.
    *
    * Use this method in time critical path as it does not require temporaries
-   * @param result of the multiplication
-   * @param lhs matrix, this can be same matrix as result
-   * @param rhs matrix, this cannot be same matrix as result
+   *
+   * result = rhs * lhs
+   *
+   * @SINCE_1_0.0
+   * @param[out] result Result of the multiplication
+   * @param[in] lhs Matrix, this can be same matrix as result
+   * @param[in] rhs Matrix, this cannot be same matrix as result
    */
-  static void Multiply( Matrix3& result, const Matrix3& lhs, const Matrix3& rhs );
+  static void Multiply(Matrix3& result, const Matrix3& lhs, const Matrix3& rhs);
 
 private:
-
   float mElements[9]; ///< The elements of the matrix
 };
 
 /**
- * @brief Print a 3x3 matrix.
+ * @brief Prints a 3x3 matrix.
  *
- * @param [in] o The output stream operator.
- * @param [in] matrix The matrix to print.
- * @return The output stream operator.
+ * @SINCE_1_0.0
+ * @param[in] o The output stream operator
+ * @param[in] matrix The matrix to print
+ * @return The output stream operator
  */
-DALI_IMPORT_API std::ostream& operator<< (std::ostream& o, const Matrix3& matrix);
+DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix);
+
+// Allow Matrix3 to be treated as a POD type
+template<>
+struct TypeTraits<Matrix3> : public BasicTypes<Matrix3>
+{
+  enum
+  {
+    IS_TRIVIAL_TYPE = true
+  };
+};
 
+/**
+ * @}
+ */
 } // namespace Dali
 
-#endif //__DALI_MATRIX3_H__
+#endif //DALI_MATRIX3_H