2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiAnim_MatrixUtil.h
20 * @brief Header file of _MatrixUtil module
22 * This file contains declarations _MatrixUtil module.
25 #ifndef _FUI_ANIM_INTERNAL_MATRIX_UTIL_H_
26 #define _FUI_ANIM_INTERNAL_MATRIX_UTIL_H_
28 #include <FBaseSysLog.h>
29 #include <FGrpFloatMatrix4.h>
30 #include <FGrpFloatRectangle.h>
32 #include "FUiAnim_TransformMatrix3Df.h"
35 namespace Tizen { namespace Ui { namespace Animations
39 RectUtilIsEqual(const Tizen::Graphics::FloatRectangle& r1, const Tizen::Graphics::FloatRectangle& r2)
41 return (memcmp(&r1.x, &r2.x, sizeof(r1.x) * 4) == 0);
45 RectUtilCopy(Tizen::Graphics::FloatRectangle& d, const Tizen::Graphics::FloatRectangle& s)
47 memcpy(&d.x, &s.x, sizeof(d.x) * 4);
51 RectUtilMakeIntegral(Tizen::Graphics::FloatRectangle& rectangle)
53 if (unlikely(rectangle.IsEmpty()))
56 rectangle.width = ceilf(rectangle.x + rectangle.width);
57 rectangle.height = ceilf(rectangle.y + rectangle.height);
59 rectangle.x = floorf(rectangle.x);
60 rectangle.y = floorf(rectangle.y);
62 rectangle.width -= rectangle.x;
63 rectangle.height -= rectangle.y;
67 RectUtilIntersect(Tizen::Graphics::FloatRectangle& rectangle, const Tizen::Graphics::FloatRectangle& mask)
69 if (unlikely(rectangle.IsEmpty()) || unlikely(mask.IsEmpty()))
72 if (unlikely(rectangle.x >= mask.x + mask.width))
75 if (unlikely(rectangle.y >= mask.y + mask.height))
78 if (unlikely(rectangle.x + rectangle.width <= mask.x))
81 if (unlikely(rectangle.y + rectangle.height <= mask.y))
87 rectangle.x = _Max(rectangle.x, mask.x);
88 rectangle.y = _Max(rectangle.y, mask.y);
89 rectangle.width = _Min(rectangle.x + rectangle.width, mask.x + mask.width) - rectangle.x;
90 rectangle.height = _Min(rectangle.y + rectangle.height, mask.y + mask.height) - rectangle.y;
94 RectUtilUnion(Tizen::Graphics::FloatRectangle& rectangle, const Tizen::Graphics::FloatRectangle& source)
96 if (rectangle.IsEmpty())
106 if (source.IsEmpty())
112 float x = _Min(rectangle.x, source.x);
113 float y = _Min(rectangle.y, source.y);
114 float width = _Max(rectangle.x + rectangle.width, source.x + source.width) - x;
115 float height = _Max(rectangle.y + rectangle.height, source.y + source.height) - y;
117 rectangle.SetBounds(x, y, width, height);
122 MatrixUtilCopy(Tizen::Graphics::FloatMatrix4& d, const Tizen::Graphics::FloatMatrix4& s)
124 memcpy(d.matrix, s.matrix, sizeof(d.matrix));
127 Matrix4Type _GetMatrix4Type(const Tizen::Graphics::FloatMatrix4& floatMatrix);
128 void _MatrixUtilSetIdentity(Tizen::Graphics::FloatMatrix4& m);
129 bool _MatrixUtilIsEqual(const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2);
130 void _MatrixUtilSetTranslation(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz);
131 void _MatrixUtilTransform(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ);
132 void _MatrixUtilTranslate(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz);
133 bool _MatrixUtilIsTranslation(const Tizen::Graphics::FloatMatrix4& m);
134 void _MatrixUtilScale(Tizen::Graphics::FloatMatrix4& m, float sx, float sy, float sz);
135 void _MatrixUtilAtAnchor(Tizen::Graphics::FloatMatrix4& m, float x, float y, float z);
136 void _MatrixUtilRotate(Tizen::Graphics::FloatMatrix4& m, float angle, float x, float y, float z);
137 bool _MatrixUtilInvert(Tizen::Graphics::FloatMatrix4& m);
138 void _MatrixUtilMultiply(Tizen::Graphics::FloatMatrix4& d, const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2);
141 }}} // Tizen::Ui::Animations
143 #endif //_FUI_ANIM_INTERNAL_MATRIX_UTIL_H_