f65687c5ce55452e14b1ca5f589a4b7190b87d4b
[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) 2022 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  * So we only need 8 values to multiplication.
63  *
64  * Use this method in time critical path as it does not require temporaries.
65  *
66  * result = projection * lhs
67  *
68  * @SINCE_2_1.46
69  * @param[out] result Result of the multiplication
70  * @param[in] lhs Matrix, this cannot be same matrix as result
71  * @param[in] projection Projection Matrix, this can be same matrix as result
72  */
73 void MultiplyProjectionMatrix(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& projection);
74
75 /**
76  * @brief Function to multiply two matrices and store the result onto first one.
77  *
78  * result = result * rhs
79  * result *= rhs
80  *
81  * @note This method might copy data internally.
82  *
83  * @SINCE_2_1.46
84  * @param[in,out] result Result of the multiplication
85  * @param[in] rhs Matrix, this can be same matrix as result
86  */
87 void MultiplyAssign(Dali::Matrix& result, const Dali::Matrix& rhs);
88
89 // Matrix3
90
91 /**
92  * @copydoc Dali::Matrix3::Multiply
93  */
94 void Multiply(Dali::Matrix3& result, const Dali::Matrix3& lhs, const Dali::Matrix3& rhs);
95
96 /**
97  * @brief Function to multiply two matrices and store the result onto first one.
98  *
99  * result = result * rhs
100  * result *= rhs
101  *
102  * @note This method might copy data internally.
103  *
104  * @SINCE_2_1.46
105  * @param[in,out] result Result of the multiplication
106  * @param[in] rhs Matrix, this can be same matrix as result
107  */
108 void MultiplyAssign(Dali::Matrix3& result, const Dali::Matrix3& rhs);
109
110 } // namespace MatrixUtils
111 } // namespace Internal
112 } // namespace Dali
113
114 #endif // DALI_INTERNAL_MATH_UTILS_H