9852f97efeb3edb7033d66df1574152cd1259cc3
[platform/core/uifw/dali-core.git] / dali / internal / common / matrix-utils.h
1 #ifndef DALI_INTERNAL_MATRIX_UTILS_H
2 #define DALI_INTERNAL_MATRIX_UTILS_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 namespace Dali
22 {
23 class Matrix;
24 class Matrix3;
25 class Quaternion;
26
27 namespace Internal
28 {
29 namespace MatrixUtils
30 {
31 // Quaternion
32
33 /**
34  * @brief Function to convert from Quaternion to Matrix as float16 array form
35  *
36  * @SINCE_2_1.46
37  * @param[out] result Result stored float16 array. It must have at least 16 * sizeof(float) bytes.
38  * @param[in] rotation Input Quaternion.
39  */
40 void ConvertQuaternion(float*& result, const Dali::Quaternion& rotation);
41
42 // Matrix
43
44 /**
45  * @copydoc Dali::Matrix::Multiply
46  */
47 void Multiply(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& rhs);
48
49 /**
50  * @copydoc Dali::Matrix::Multiply
51  */
52 void Multiply(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Quaternion& rhs);
53
54 /**
55  * @brief Function to multiply projection matrix and store the result onto third.
56  *
57  * This API assume that projection is Projection Matrix which top/bottom/left/right is symmetrical.
58  *
59  * Perspective matrix only has 0, 5, 10, 11, 14 (14 is const value, 1.0f).
60  * Orthographic matrix only has 0, 5, 10, 14, 15 (15 is const value, 1.0f).
61  * If window rotated, we use 1, 4 index instead of 0, 5.
62  * If reflect plane used, we use 2, 6 index.
63  * So we only need 10 values to multiplication.
64  *
65  * Use this method in time critical path as it does not require temporaries.
66  *
67  * result = projection * lhs
68  *
69  * @SINCE_2_1.46
70  * @param[out] result Result of the multiplication
71  * @param[in] lhs Matrix, this cannot be same matrix as result
72  * @param[in] projection Projection Matrix, this can be same matrix as result
73  */
74 void MultiplyProjectionMatrix(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& projection);
75
76 /**
77  * @brief Function to multiply two matrices and store the result onto first one.
78  *
79  * result = result * rhs
80  * result *= rhs
81  *
82  * @note This method might copy data internally.
83  *
84  * @SINCE_2_1.46
85  * @param[in,out] result Result of the multiplication
86  * @param[in] rhs Matrix, this can be same matrix as result
87  */
88 void MultiplyAssign(Dali::Matrix& result, const Dali::Matrix& rhs);
89
90 // Matrix3
91
92 /**
93  * @copydoc Dali::Matrix3::Multiply
94  */
95 void Multiply(Dali::Matrix3& result, const Dali::Matrix3& lhs, const Dali::Matrix3& rhs);
96
97 /**
98  * @brief Function to multiply two matrices and store the result onto first one.
99  *
100  * result = result * rhs
101  * result *= rhs
102  *
103  * @note This method might copy data internally.
104  *
105  * @SINCE_2_1.46
106  * @param[in,out] result Result of the multiplication
107  * @param[in] rhs Matrix, this can be same matrix as result
108  */
109 void MultiplyAssign(Dali::Matrix3& result, const Dali::Matrix3& rhs);
110
111 } // namespace MatrixUtils
112 } // namespace Internal
113 } // namespace Dali
114
115 #endif // DALI_INTERNAL_MATH_UTILS_H