Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / renderer / math / FUiEffects_RendererMathMatrix1Traits.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file       FUiEffects_RendererMathMatrix1Traits.h
20  * @brief      The Matrix1Traits class
21  *
22  */
23
24 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_
25 #define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_
26
27 #include <renderer/math/FUiEffects_RendererMathMatrixTraits.h>
28 #include <renderer/math/FUiEffects_RendererMathCommon.h>
29 #include <renderer/math/FUiEffects_RendererMathAdapterFunctions.h>
30
31 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math
32 {
33
34 template<typename T>
35 class MatrixTraits<T, 1> :
36         public MatrixTraitsBase<T, 1>
37 {
38 public:
39         typedef Matrix<T, 1> MatrixType;
40         typedef Vector<T, 1> VectorType;
41         typedef MatrixTraitsBase<T, 1> MatrixTraitsBaseType;
42         typedef typename MatrixTraitsBaseType::TypeReference TypeReference;
43
44         using MatrixTraitsBaseType::data;
45
46         inline VectorType& I(void);
47         inline const VectorType& I(void) const;
48
49         inline MatrixType& Set(const VectorType& i);
50         inline MatrixType& Set(const TypeReference a0);
51
52         inline static MatrixType& GetIdentity(void);
53
54         inline VectorType& ApplyTransform(void) const;
55         inline VectorType GetAppliedTransform(void) const;
56
57         inline MatrixType& MakeScale(const TypeReference x, const TypeReference y);
58         inline MatrixType& SetScale(const TypeReference x, const TypeReference y);
59         static inline MatrixType CreateScale(const TypeReference x, const TypeReference y);
60         inline MatrixType& Scale(const TypeReference x, const TypeReference y);
61 };
62
63 template<typename T>
64 typename MatrixTraits<T, 1>::VectorType& MatrixTraits<T, 1>::I(void)
65 {
66         return data[0];
67 }
68
69 template<typename T>
70 const typename MatrixTraits<T, 1>::VectorType& MatrixTraits<T, 1>::I(void) const
71 {
72         return data[0];
73 }
74
75 template<typename T>
76 typename MatrixTraits<T, 1>::MatrixType& MatrixTraits<T, 1>::Set(const VectorType& i)
77 {
78         data[0] = i;
79         return *(static_cast<MatrixType*>(this));
80 }
81
82 template<typename T>
83 typename MatrixTraits<T, 1>::MatrixType& MatrixTraits<T, 1>::Set(const TypeReference a0)
84 {
85         data[0].Set(a0);
86         return *(static_cast<MatrixType*>(this));
87 }
88
89 template<typename T>
90 typename MatrixTraits<T, 1>::MatrixType& MatrixTraits<T, 1>::GetIdentity(void)
91 {
92         static MatrixType identityMatrix = MatrixType(T(1.0f));
93         return identityMatrix;
94 }
95
96 }}}}} //Tizen::Ui::Effects::_Renderer::Math
97
98
99 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_