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.cpp
20 * @brief This file contains implementation of _VisualElementCoordinateSystem class
22 * This file contains implementation _VisualElementCoordinateSystem class.
25 #include <FGrpFloatPoint.h>
26 #include <FGrpFloatDimension.h>
27 #include <FGrpFloatRectangle.h>
28 #include <FGrp_Screen.h>
30 #include "FUi_CoordinateSystemUtils.h"
31 #include "FUiAnim_VisualElementCoordinateSystem.h"
33 namespace Tizen { namespace Ui { namespace Animations
36 float _VisualElementCoordinateSystem::scaleFactorX = 1.0f;
37 float _VisualElementCoordinateSystem::scaleFactorY = 1.0f;
38 int _VisualElementCoordinateSystem::logScreenWidth = 0;
39 int _VisualElementCoordinateSystem::logScreenHeight = 0;
40 bool _VisualElementCoordinateSystem::needScale = false;
43 _VisualElementCoordinateSystem::Initialize(void)
47 // Initialize auto-scale factors
48 Tizen::Graphics::_CoordinateSystem* pCoordSys = Tizen::Graphics::_CoordinateSystem::GetInstance();
50 if (pCoordSys->IsTransformEnabled() == true)
52 scaleFactorX = pCoordSys->GetTransformer()->GetHorizontalScaleFactor();
53 scaleFactorY = pCoordSys->GetTransformer()->GetVerticalScaleFactor();
56 // 1. The values 'scaleFactorX' and 'scaleFactorY' may be greater than expected 'cause of float-error.
57 // So, it is needed to cut-off some significant digits to ensure the scale factors are always less or equal than real values.
58 // The cut-off position should be lower than the compensation value(> 10^3 due to rounding), too.
59 // 2. The number fo siginificant digits for float is about 6 (5 for sure).
60 // So, the scaleFactor to cut-off should be less or equal than 10^6.
62 const float scaleFactor = 1000.0f / floatIntegralEpsilon;
63 //SysAssert(scaleFactor <= 1000000.0f);
65 scaleFactorX = floorf(scaleFactorX * scaleFactor) / scaleFactor;
66 scaleFactorY = floorf(scaleFactorY * scaleFactor) / scaleFactor;
71 int physScreenWidth = Tizen::Graphics::_Screen::GetWidth();
72 int physScreenHeight = Tizen::Graphics::_Screen::GetHeight();
73 float sWidth = static_cast< float >(physScreenWidth);
74 float sHeight = static_cast< float >(physScreenHeight);
76 ConvertDimensionToLogicalIntegral(sWidth, sHeight);
77 logScreenWidth = static_cast< int >(sWidth);
78 logScreenHeight = static_cast< int >(sHeight);
80 ConvertDimensionToPhysicalIntegral(sWidth, sHeight);
82 SysAssert(static_cast< int >(sWidth) <= physScreenWidth);
83 SysAssert(static_cast< int >(sHeight) <= physScreenHeight);
86 }}} // Tizen::Ui::Animations