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_VisualElementCoordinateSystem.h
20 * @brief This is the header file for the _VisualElementCoordinateSystem class.
22 * This header file contains the declarations of the _VisualElementCoordinateSystem class.
25 #ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_
26 #define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_
30 namespace Tizen { namespace Ui { namespace Animations
33 class _OSP_EXPORT_ _VisualElementCoordinateSystem
36 static void Initialize(void);
38 static void MakeIntegralPoint(float& x, float& y)
40 x = floorf(x + floatIntegralEpsilon);
41 y = floorf(y + floatIntegralEpsilon);
44 static void MakeIntegralPoint(float x, float y, int& intX, int& intY)
46 intX = int(floorf(x + floatIntegralEpsilon));
47 intY = int(floorf(y + floatIntegralEpsilon));
50 static void MakeIntegralDimension(float& width, float& height)
52 width = floorf(width + floatIntegralEpsilon);
53 height = floorf(height + floatIntegralEpsilon);
56 static void MakeIntegralDimension(float width, float height, int& intWidth, int& intHeight)
58 intWidth = int(floorf(width + floatIntegralEpsilon));
59 intHeight = int(floorf(height + floatIntegralEpsilon));
62 static void ConvertDimensionToPhysical(float& width, float& height)
64 if (unlikely(needScale))
66 width *= scaleFactorX;
67 height *= scaleFactorY;
71 static void ConvertRectangleToPhysical(float& x, float& y, float& width, float& height)
73 if (unlikely(needScale))
75 ConvertPointToPhysical(x, y);
76 ConvertDimensionToPhysical(width, height);;
80 static void ConvertDimensionToPhysicalIntegral(float& width, float& height)
82 if (unlikely(needScale))
84 width *= scaleFactorX;
85 height *= scaleFactorY;
88 // Because auto-scaling coordinate system of graphics ceils only for down-scaling, we do the same !
90 // Separate Horz/Vert handling ?
91 MakeIntegralDimension(width, height);
95 static void ConvertDimensionToPhysicalIntegral(float width, float height, int& intWidth, int& intHeight)
97 ConvertDimensionToPhysicalIntegral(width, height);
98 intWidth = static_cast< int >(width);
99 intHeight = static_cast< int >(height);
102 static void ConvertDimensionToLogicalIntegral(float& width, float& height)
104 if (unlikely(needScale))
106 width /= scaleFactorX;
107 height /= scaleFactorY;
110 // Because auto-scaling coordinate system of graphics ceils only for down-scaling, we do the same !
112 // Separate Horz/Vert handling ?
113 MakeIntegralDimension(width, height);
117 static void ConvertDimensionToLogicalIntegral(float width, float height, int& intWidth, int& intHeight)
119 ConvertDimensionToLogicalIntegral(width, height);
120 intWidth = static_cast< int >(width);
121 intHeight = static_cast< int >(height);
124 static void ConvertDimensionToLogical(float& width, float& height)
126 if (unlikely(needScale))
128 width /= scaleFactorX;
129 height /= scaleFactorY;
133 static void ConvertPointToPhysical(float& x, float& y)
135 if (unlikely(needScale))
142 static void ConvertPointToLogical(float& x, float& y)
144 if (unlikely(needScale))
153 // Some float functions like sin and cos emit too-much float-error.
154 // So, the rounding const must be a bigger value than expected.
155 static const float floatIntegralEpsilon = 0.01f;
157 static bool needScale;
158 static float scaleFactorX;
159 static float scaleFactorY;
160 static int logScreenWidth;
161 static int logScreenHeight;
162 }; // _VisualElementCoordinateSystem
164 }}} // Tizen::Ui::Animations
166 #endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_