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 FGrp_ResUtil.h
20 * @brief This is the header file for internal _ResUtil namespace.
24 #ifndef _FGRP_INTERNAL_RES_UTIL_H_
25 #define _FGRP_INTERNAL_RES_UTIL_H_
31 #include <FBaseColArrayList.h>
32 #include <FGrpPoint.h>
33 #include <FGrpRectangle.h>
35 #include "util/FGrp_UtilType.h"
36 #include "FGrp_Screen.h"
39 #include "FGrp_CoordSystem.h"
40 ////////////////////////////////////////////////////////////////////////////////
41 // Coordinate conversion
43 namespace Tizen { namespace Graphics
60 Rect(int _x, int _y, int _w, int _h)
104 template<unsigned int VirRes, unsigned int PhyRes>
107 inline static int ToVirCoord(int phy);
108 inline static int ToPhyCoord(int vir);
109 inline static int ToPhyCoord4Size(int vir);
113 template<unsigned int VirResX, unsigned int VirResY, unsigned int PhyResX, unsigned int PhyResY>
116 inline static int ToVirCoordX(int phyX)
118 return ResConv1d <VirResX, PhyResX>::ToVirCoord(phyX);
121 inline static int ToVirCoordY(int phyY)
123 return ResConv1d <VirResY, PhyResY>::ToVirCoord(phyY);
126 inline static int ToPhyCoordX(int virX)
128 return ResConv1d <VirResX, PhyResX>::ToPhyCoord(virX);
131 inline static int ToPhyCoordY(int virY)
133 return ResConv1d <VirResY, PhyResY>::ToPhyCoord(virY);
136 inline static int ToPhyCoord4Size(int vir)
138 return ResConv1d <VirResY, PhyResY>::ToPhyCoord4Size(vir);
142 /////////////////////
153 template<ResType Res>
158 template<ResType VirRes, ResType PhyRes>
161 typedef ResConv2d <ResTraits <VirRes>::ResWidth, ResTraits <VirRes>::ResHeight, ResTraits <PhyRes>::ResWidth,
162 ResTraits <PhyRes>::ResHeight> CurrentResConv;
165 inline static T ToPhyCoord(const T& sour)
167 return CurrentResConv::ToPhyCoordY(sour);
171 inline static T ToVirCoord(const T& sour)
173 return CurrentResConv::ToVirCoordY(sour);
176 inline static int ToPhyCoordSize(int sour)
178 return CurrentResConv::ToPhyCoord4Size(sour);
181 inline static int ToPhyCoordX(int sour)
183 return CurrentResConv::ToPhyCoordX(sour);
186 inline static int ToPhyCoordY(int sour)
188 return CurrentResConv::ToPhyCoordY(sour);
191 inline static int ToPhyCoordW(int sour)
193 return CurrentResConv::ToPhyCoordX(sour);
196 inline static int ToPhyCoordH(int sour)
198 return CurrentResConv::ToPhyCoordY(sour);
201 inline static int ToVirCoordX(int sour)
203 return CurrentResConv::ToVirCoordX(sour);
206 inline static int ToVirCoordY(int sour)
208 return CurrentResConv::ToVirCoordY(sour);
211 inline static int ToVirCoordW(int sour)
213 return CurrentResConv::ToVirCoordX(sour);
216 inline static int ToVirCoordH(int sour)
218 return CurrentResConv::ToVirCoordY(sour);
221 inline static Rect ToPhyCoord(const Rect& sour)
223 int destX = CurrentResConv::ToPhyCoordX(sour.x);
224 int destY = CurrentResConv::ToPhyCoordY(sour.y);
230 CurrentResConv::ToPhyCoordX(sour.x + sour.w) - destX,
231 CurrentResConv::ToPhyCoordY(sour.y + sour.h) - destY
235 inline static Pos ToPhyCoord(const Pos& sour)
239 CurrentResConv::ToPhyCoordX(sour.x),
240 CurrentResConv::ToPhyCoordY(sour.y)
244 inline static Size ToPhyCoord(const Size& sour)
248 CurrentResConv::ToPhyCoordX(sour.w),
249 CurrentResConv::ToPhyCoordY(sour.h)
253 inline static Tizen::Graphics::Rectangle ToPhyCoord(const Tizen::Graphics::Rectangle& sour)
255 Tizen::Graphics::Rectangle dest;
257 dest.x = CurrentResConv::ToPhyCoordX(sour.x);
258 dest.y = CurrentResConv::ToPhyCoordY(sour.y);
260 dest.width = CurrentResConv::ToPhyCoordX(sour.x + sour.width) - dest.x;
261 dest.height = CurrentResConv::ToPhyCoordY(sour.y + sour.height) - dest.y;
266 inline static Tizen::Graphics::Point ToPhyCoord(const Tizen::Graphics::Point& sour)
268 return Tizen::Graphics::Point(CurrentResConv::ToPhyCoordX(sour.x), CurrentResConv::ToPhyCoordY(sour.y));
271 inline static Tizen::Graphics::Dimension ToPhyCoord(const Tizen::Graphics::Dimension& sour)
273 return Tizen::Graphics::Dimension(CurrentResConv::ToPhyCoordX(sour.width), CurrentResConv::ToPhyCoordY(sour.height));
276 inline static Rect ToVirCoord(const Rect& sour)
278 int destX = CurrentResConv::ToVirCoordX(sour.x);
279 int destY = CurrentResConv::ToVirCoordY(sour.y);
285 CurrentResConv::ToVirCoordX(sour.x + sour.w) - destX,
286 CurrentResConv::ToVirCoordY(sour.y + sour.h) - destY
290 inline static Pos ToVirCoord(const Pos& sour)
294 CurrentResConv::ToVirCoordX(sour.x),
295 CurrentResConv::ToVirCoordY(sour.y)
299 inline static Size ToVirCoord(const Size& sour)
303 CurrentResConv::ToVirCoordX(sour.w),
304 CurrentResConv::ToVirCoordY(sour.h)
308 inline static Tizen::Graphics::Rectangle ToVirCoord(const Tizen::Graphics::Rectangle& sour)
310 Rect pc_rect = Rect(sour.x, sour.y, sour.width, sour.height);
311 Rect vc_rect = ResConv <VirRes, PhyRes>::ToVirCoord(pc_rect);
313 return Tizen::Graphics::Rectangle(vc_rect.x, vc_rect.y, vc_rect.w, vc_rect.h);
316 inline static Tizen::Graphics::Point ToVirCoord(const Tizen::Graphics::Point& sour)
318 return Tizen::Graphics::Point(CurrentResConv::ToVirCoordX(sour.x), CurrentResConv::ToVirCoordY(sour.y));
321 inline static Tizen::Graphics::Dimension ToVirCoord(const Tizen::Graphics::Dimension& sour)
323 return Tizen::Graphics::Dimension(CurrentResConv::ToVirCoordX(sour.width), CurrentResConv::ToVirCoordY(sour.height));
327 } // Tizen::Graphics::_ResUtil
329 }} // Tizen::Graphics
331 ////////////////////////////////////////////////////////////////////////////////
334 namespace Tizen { namespace Graphics
339 // (480x800) -> (240x400)
342 ResConv1d <480, 240>::ToVirCoord(int phy)
349 ResConv1d <480, 240>::ToPhyCoord(int vir)
356 ResConv1d <480, 240>::ToPhyCoord4Size(int vir)
358 return (vir >= 0) ? ((vir + 1) >> 1) : (vir >> 1);
363 ResConv1d <800, 400>::ToVirCoord(int phy)
370 ResConv1d <800, 400>::ToPhyCoord(int vir)
377 ResConv1d <800, 400>::ToPhyCoord4Size(int vir)
379 return (vir >= 0) ? ((vir + 1) >> 1) : (vir >> 1);
382 // (240x400) -> (480x800)
385 ResConv1d <240, 480>::ToVirCoord(int phy)
392 ResConv1d <240, 480>::ToPhyCoord(int vir)
399 ResConv1d <240, 480>::ToPhyCoord4Size(int vir)
406 ResConv1d <400, 800>::ToVirCoord(int phy)
413 ResConv1d <400, 800>::ToPhyCoord(int vir)
420 ResConv1d <400, 800>::ToPhyCoord4Size(int vir)
425 // (480x800) -> (320x480)
428 ResConv1d <480, 320>::ToVirCoord(int phy)
430 return ((phy) >= 0) ? ((phy) * 3 / 2) : (((phy) * 3 - 1) / 2);
435 ResConv1d <480, 320>::ToPhyCoord(int vir)
437 return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3);
442 ResConv1d <480, 320>::ToPhyCoord4Size(int vir)
444 return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3);
449 ResConv1d <800, 480>::ToVirCoord(int phy)
451 return ((phy) >= 0) ? ((phy) * 3 / 2) : (((phy) * 3 - 1) / 2);
456 ResConv1d <800, 480>::ToPhyCoord(int vir)
458 return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3);
463 ResConv1d <800, 480>::ToPhyCoord4Size(int vir)
465 return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3);
468 // (480x800) -> (320x480) compatibility
471 ResConv1d <801, 480>::ToVirCoord(int phy)
473 return (phy * 5 / 3);
478 ResConv1d <801, 480>::ToPhyCoord(int vir)
480 return (vir * 3 / 5);
485 ResConv1d <801, 480>::ToPhyCoord4Size(int vir)
487 return (vir * 3 / 5);
490 // (240x400) -> (320x480) compatibility
493 ResConv1d <240, 320>::ToVirCoord(int phy)
495 return (phy * 3 / 4);
500 ResConv1d <240, 320>::ToPhyCoord(int vir)
502 return (vir * 4 / 3);
507 ResConv1d <240, 320>::ToPhyCoord4Size(int vir)
509 return (vir * 4 / 3);
514 ResConv1d <400, 480>::ToVirCoord(int phy)
516 return (phy * 5 / 6);
521 ResConv1d <400, 480>::ToPhyCoord(int vir)
523 return (vir * 6 / 5);
528 ResConv1d <400, 480>::ToPhyCoord4Size(int vir)
530 return (vir * 6 / 5);
533 // (480x800) -> (540x960)
536 ResConv1d <480, 540>::ToVirCoord(int phy)
538 return (phy * 8 / 9);
543 ResConv1d <480, 540>::ToPhyCoord(int vir)
545 return (vir * 9 / 8);
550 ResConv1d <480, 540>::ToPhyCoord4Size(int vir)
552 return (vir >= 0) ? ((vir + 5) * 9 / 8) : (vir * 9 / 8);
557 ResConv1d <800, 960>::ToVirCoord(int phy)
559 return (phy * 8 / 9);
564 ResConv1d <800, 960>::ToPhyCoord(int vir)
566 return (vir * 9 / 8);
571 ResConv1d <800, 960>::ToPhyCoord4Size(int vir)
573 return (vir >= 0) ? ((vir + 5) * 9 / 8) : (vir * 9 / 8);
576 ////////////////////////////////////////////////////////////////////////////////
579 struct ResTraits <RES_WVGA>
592 struct ResTraits <RES_WQVGA>
605 struct ResTraits <RES_HVGA>
618 struct ResTraits <RES_WVGA_COMPAT>
626 ResHeight = (800 + 1)
631 struct ResTraits <RES_QHD>
643 } // Tizen::Graphics::_ResUtil
645 }} // Tizen::Graphics
647 ////////////////////////////////////////////////////////////////////////////////
650 namespace Tizen { namespace Graphics
657 NEED_TO_CONVERT(void)
659 _Resolution virRes = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution();
660 _Resolution PhyRes = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetDeviceResolution();
662 return (virRes != PhyRes);
665 typedef ResConv<RES_WQVGA, RES_WVGA> ResWQVGA2WVGA;
666 typedef ResConv<RES_WVGA, RES_WQVGA> ResWVGA2WQVGA;
667 typedef ResConv<RES_WVGA, RES_HVGA> ResWVGA2HVGA;
668 typedef ResConv<RES_WQVGA, RES_HVGA> ResWQVGA2HVGA;
669 typedef ResConv<RES_WVGA_COMPAT, RES_HVGA> ResWVGAcompat2HVGA;
670 typedef ResConv<RES_WVGA, RES_QHD> ResWVGA2QHD;
672 #if defined(_MODEL_RES_WVGA)
673 // #error "Base resolution: 480 x 800"
674 typedef ResWQVGA2WVGA CurrentResConv;
675 #elif defined(_MODEL_RES_WQVGA)
676 // #error "Base resolution: 240 x 400"
677 typedef ResWVGA2WQVGA CurrentResConv;
678 #elif defined(_MODEL_RES_HVGA)
679 // #error "Base resolution: 320 x 480"
680 typedef ResWVGA2HVGA CurrentResConv;
681 #elif defined(_MODEL_RES_QHD)
682 // #error "Base resolution: 800 x 1280"
683 typedef ResWVGA2QHD CurrentResConv;
685 //#error "Open CMakeLists.txt and define base resolution for new model"
686 typedef ResWVGA2WQVGA CurrentResConv;
690 #if 0 // defined(_MODEL_RES_HVGA)
691 #define NOT_FROM_WQVGA() (Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution() != \
692 Tizen::Graphics::RESOLUTION_WQVGA)
693 #define NOT_FROM_WVGA_COMPAT() (Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution() != \
694 Tizen::Graphics::RESOLUTION_WVGA_COMPAT)
695 #define TRANSFORM(func, sour) \
703 NOT_FROM_WVGA_COMPAT() \
706 CurrentResConv::func(sour) \
710 ResWVGAcompat2HVGA::func(sour) \
715 ResWQVGA2HVGA::func(sour) \
724 TO_PHY_COORD(const T& sour)
726 return TRANSFORM(ToPhyCoord, sour);
731 TO_VIR_COORD(const T& sour)
733 return TRANSFORM(ToVirCoord, sour);
736 #define CONVERT_TO_P_COORD_X(sour) TRANSFORM(ToPhyCoordX, sour)
737 #define CONVERT_TO_P_COORD_Y(sour) TRANSFORM(ToPhyCoordY, sour)
738 #define CONVERT_TO_P_COORD_W(sour) TRANSFORM(ToPhyCoordW, sour)
739 #define CONVERT_TO_P_COORD_H(sour) TRANSFORM(ToPhyCoordH, sour)
740 #define CONVERT_TO_P_COORD_SIZE(sour) TRANSFORM(ToPhyCoordSize, sour)
742 #define CONVERT_TO_V_COORD_X(sour) TRANSFORM(ToVirCoordX, sour)
743 #define CONVERT_TO_V_COORD_Y(sour) TRANSFORM(ToVirCoordY, sour)
744 #define CONVERT_TO_V_COORD_W(sour) TRANSFORM(ToVirCoordW, sour)
745 #define CONVERT_TO_V_COORD_H(sour) TRANSFORM(ToVirCoordH, sour)
748 CONVERT_TO_P_COORD_POINT_LIST(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour)
752 if (NEED_TO_CONVERT())
754 r = dest.Construct();
758 for (int i = 0; i < sour.GetCount(); i++)
760 Tizen::Graphics::Point* pSourPoint =
761 dynamic_cast <Tizen::Graphics::Point*>(const_cast <Tizen::Base::Object*>(sour.GetAt(i)));
763 if (pSourPoint == null)
768 Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y);
770 if (pDestPoint == null)
775 if (NOT_FROM_WQVGA())
777 if (NOT_FROM_WVGA_COMPAT())
779 *pDestPoint = CurrentResConv::ToPhyCoord(*pDestPoint);
783 *pDestPoint = ResWVGAcompat2HVGA::ToPhyCoord(*pDestPoint);
788 *pDestPoint = ResWQVGA2HVGA::ToPhyCoord(*pDestPoint);
791 dest.Add(*pDestPoint);
797 r = dest.Construct(sour);
800 return (r == E_SUCCESS);
806 TO_PHY_COORD(const T& sour)
808 return _ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoord(sour) : sour;
813 TO_VIR_COORD(const T& sour)
815 return NEED_TO_CONVERT() ? CurrentResConv::ToVirCoord(sour) : sour;
819 CONVERT_TO_P_COORD_POINT_LIST(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour)
823 if (NEED_TO_CONVERT())
825 r = dest.Construct();
829 for (int i = 0; i < sour.GetCount(); i++)
831 Tizen::Graphics::Point* pSourPoint =
832 dynamic_cast <Tizen::Graphics::Point*>(const_cast <Tizen::Base::Object*>(sour.GetAt(i)));
834 if (pSourPoint == null)
839 Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y);
841 if (pDestPoint == null)
846 *pDestPoint = CurrentResConv::ToPhyCoord(*pDestPoint);
848 dest.Add(*pDestPoint);
854 r = dest.Construct(sour);
857 return (r == E_SUCCESS);
860 #define CONVERT_TO_P_COORD_X(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordX(sour) : sour)
861 #define CONVERT_TO_P_COORD_Y(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordY(sour) : sour)
862 #define CONVERT_TO_P_COORD_W(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordW(sour) : sour)
863 #define CONVERT_TO_P_COORD_H(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordH(sour) : sour)
864 #define CONVERT_TO_P_COORD_SIZE(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordSize(sour) : sour)
866 #define CONVERT_TO_V_COORD_X(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordX(sour) : sour)
867 #define CONVERT_TO_V_COORD_Y(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordY(sour) : sour)
868 #define CONVERT_TO_V_COORD_W(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordW(sour) : sour)
869 #define CONVERT_TO_V_COORD_H(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordH(sour) : sour)
871 #endif // #if defined(_MODEL_RES_HVGA)
873 } // Tizen::Graphics::_ResUtil
875 }} // Tizen::Graphics
877 ////////////////////////////////////////////////////////////////////////////////
878 // struct CoordHolder
880 namespace Tizen { namespace Graphics
892 void operator =(const T& in)
895 phyCoord = TO_PHY_COORD(required);
896 virCoord = TO_VIR_COORD(phyCoord);
899 } // Tizen::Graphics::_ResUtil
901 }} // Tizen::Graphics
905 #include "FGrp_CoordinateSystem.h"
907 namespace Tizen { namespace Graphics
928 Rect(int _x, int _y, int _w, int _h)
973 ////////////////////////////////////////////////////////////////////////////////
980 ToPhyCoord(const T& sour)
982 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
983 return (pTransformer) ? pTransformer->Transform(sour) : sour;
988 ToVirCoord(const T& sour)
990 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
991 return (pTransformer) ? pTransformer->Transform(sour) : sour;
995 inline _Util::Point<int>
996 ToPhyCoord(const _Util::Point<int>& sour)
998 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1000 if (pTransformer == null)
1005 _Util::Point<int> dest =
1007 pTransformer->TransformHorizontal(sour.x),
1008 pTransformer->TransformVertical(sour.y)
1015 inline _Util::Point<double>
1016 ToPhyCoord(const _Util::Point<double>& sour)
1018 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1022 _Util::Point<double> temp =
1024 sour.x * double(pTransformer->GetHorizontalScaleFactor()),
1025 sour.y * double(pTransformer->GetVerticalScaleFactor())
1037 inline _Util::Point<float>
1038 ToPhyCoord(const _Util::Point<float>& sour)
1040 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1044 _Util::Point<float> temp =
1046 sour.x * float(pTransformer->GetHorizontalScaleFactor()),
1047 sour.y * float(pTransformer->GetVerticalScaleFactor())
1059 inline _Util::Dimension<int>
1060 ToPhyCoord(const _Util::Dimension<int>& sour)
1062 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1064 if (pTransformer == null)
1069 _Util::Dimension<int> dest =
1071 pTransformer->TransformHorizontal(sour.w),
1072 pTransformer->TransformVertical(sour.h)
1079 inline _Util::Dimension<double>
1080 ToPhyCoord(const _Util::Dimension<double>& sour)
1082 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1086 _Util::Dimension<double> temp =
1088 sour.w * double(pTransformer->GetHorizontalScaleFactor()),
1089 sour.h * double(pTransformer->GetVerticalScaleFactor())
1101 inline _Util::Dimension<float>
1102 ToPhyCoord(const _Util::Dimension<float>& sour)
1104 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1108 _Util::Dimension<float> temp =
1110 sour.w * float(pTransformer->GetHorizontalScaleFactor()),
1111 sour.h * float(pTransformer->GetVerticalScaleFactor())
1123 inline _Util::Rectangle<int>
1124 ToPhyCoord(const _Util::Rectangle<int>& sour)
1126 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1128 if (pTransformer == null)
1133 _Util::Rectangle<int> dest =
1135 pTransformer->TransformHorizontal(sour.x),
1136 pTransformer->TransformVertical(sour.y),
1137 pTransformer->TransformHorizontal(sour.w),
1138 pTransformer->TransformVertical(sour.h)
1145 inline _Util::Rectangle<double>
1146 ToPhyCoord(const _Util::Rectangle<double>& sour)
1148 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1152 _Util::Rectangle<double> temp =
1154 sour.x * double(pTransformer->GetHorizontalScaleFactor()),
1155 sour.y * double(pTransformer->GetVerticalScaleFactor()),
1156 sour.w * double(pTransformer->GetHorizontalScaleFactor()),
1157 sour.h * double(pTransformer->GetVerticalScaleFactor())
1169 inline _Util::Rectangle<float>
1170 ToPhyCoord(const _Util::Rectangle<float>& sour)
1172 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1176 _Util::Rectangle<float> temp =
1178 sour.x * float(pTransformer->GetHorizontalScaleFactor()),
1179 sour.y * float(pTransformer->GetVerticalScaleFactor()),
1180 sour.w * float(pTransformer->GetHorizontalScaleFactor()),
1181 sour.h * float(pTransformer->GetVerticalScaleFactor())
1194 ToPhyCoord(const Rect& sour)
1196 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1198 if (pTransformer == null)
1203 Rectangle rect1(sour.x, sour.y, sour.w, sour.h);
1204 Rectangle rect2 = pTransformer->Transform(rect1);
1206 return Rect(rect2.x, rect2.y, rect2.width, rect2.height);
1211 ToVirCoord(const Rect& sour)
1213 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1215 if (pTransformer == null)
1220 Rectangle rect1(sour.x, sour.y, sour.w, sour.h);
1221 Rectangle rect2 = pTransformer->Transform(rect1);
1223 return Rect(rect2.x, rect2.y, rect2.width, rect2.height);
1228 ToPhyCoord(const Pos& sour)
1230 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1232 if (pTransformer == null)
1237 Point point1(sour.x, sour.y);
1238 Point point2 = pTransformer->Transform(point1);
1240 return Pos(point2.x, point2.y);
1245 ToVirCoord(const Pos& sour)
1247 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1249 if (pTransformer == null)
1254 Point point1(sour.x, sour.y);
1255 Point point2 = pTransformer->Transform(point1);
1257 return Pos(point2.x, point2.y);
1261 inline _Util::Dimension<int>
1262 ToVirCoord(const _Util::Dimension<int>& sour)
1264 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1266 if (pTransformer == null)
1271 Dimension dim1(sour.w, sour.h);
1272 Dimension dim2 = pTransformer->Transform(dim1);
1274 _Util::Dimension<int> temp = { dim2.width, dim2.height };
1279 ////////////////////////////////////////////////////////////////////////////////
1281 template<typename T>
1283 ToVirCoordX(const T& sour)
1285 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1286 return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour;
1289 template<typename T>
1291 ToVirCoordY(const T& sour)
1293 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1294 return (pTransformer) ? pTransformer->TransformVertical(sour) : sour;
1297 template<typename T>
1299 ToPhyCoordW(const T& sour)
1301 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1302 return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour;
1305 template<typename T>
1307 ToVirCoordW(const T& sour)
1309 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1310 return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour;
1313 template<typename T>
1315 ToPhyCoordH(const T& sour)
1317 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1318 return (pTransformer) ? pTransformer->TransformVertical(sour) : sour;
1321 template<typename T>
1323 ToVirCoordH(const T& sour)
1325 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1326 return (pTransformer) ? pTransformer->TransformVertical(sour) : sour;
1329 template<typename T>
1331 ToPhyCoordSize(const T& sour)
1333 _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
1334 return (pTransformer) ? pTransformer->TransformVertical(sour) : sour;
1339 ////////////////////////////////////////////////////////////////////////////////
1342 NeedToConvertCoord(void)
1344 int logicalResolution = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolutionInt();
1345 int physicalResolution = (_Screen::GetWidth() < _Screen::GetHeight()) ? _Screen::GetWidth() : _Screen::GetHeight();
1347 return (logicalResolution != physicalResolution);
1350 template<typename T>
1352 ConvertToPhyCoord(const T& sour)
1354 return NeedToConvertCoord() ? ToPhyCoord(sour) : sour;
1357 template<typename T>
1359 ConvertToVirCoord(const T& sour)
1361 return NeedToConvertCoord() ? ToVirCoord(sour) : sour;
1364 template<typename T>
1366 ConvertToPhyCoordWidth(const T& sour)
1368 return NeedToConvertCoord() ? ToPhyCoordW(sour) : sour;
1371 template<typename T>
1373 ConvertToPhyCoordHeight(const T& sour)
1375 return NeedToConvertCoord() ? ToPhyCoordH(sour) : sour;
1378 template<typename T>
1380 ConvertToPhyCoordSize(const T& sour)
1382 return NeedToConvertCoord() ? ToPhyCoordSize(sour) : sour;
1385 template<typename T>
1387 ConvertToVirCoordX(const T& sour)
1389 return NeedToConvertCoord() ? ToVirCoordX(sour) : sour;
1392 template<typename T>
1394 ConvertToVirCoordY(const T& sour)
1396 return NeedToConvertCoord() ? ToVirCoordY(sour) : sour;
1400 ConvertToPhyCoordPointList(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour)
1404 if (NeedToConvertCoord())
1406 r = dest.Construct();
1410 for (int i = 0; i < sour.GetCount(); i++)
1412 Tizen::Graphics::Point* pSourPoint =
1413 dynamic_cast <Tizen::Graphics::Point*>(const_cast <Tizen::Base::Object*>(sour.GetAt(i)));
1415 if (pSourPoint == null)
1417 dest.RemoveAll(true);
1421 Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y);
1423 if (pDestPoint == null)
1425 dest.RemoveAll(true);
1429 *pDestPoint = ToPhyCoord(*pDestPoint);
1431 dest.Add(*pDestPoint);
1437 r = dest.Construct(sour);
1440 return (r == E_SUCCESS);
1443 ////////////////////////////////////////////////////////////////////////////////
1445 template<typename T>
1452 void operator =(const T& in)
1455 phyCoord = ConvertToPhyCoord(required);
1456 virCoord = ConvertToVirCoord(phyCoord);
1460 template<typename FloatType, typename IntType>
1461 struct CoordinateHolder
1464 FloatType vcFloatActual;
1469 template<typename FloatType, typename IntType>
1470 struct CoordinateHolderSimple
1478 ////////////////////////////////////////////////////////////////////////////////
1480 inline int _FloatToIntForPos(float f)
1482 return static_cast<int>(floorf(f + 0.01f));
1485 inline int _DoubleToIntForPos(double f)
1487 return static_cast<int>(floor(f + 0.01));
1490 inline int _FloatToIntForSize(float f)
1494 int i = static_cast<int>(f + 0.01f);
1495 return (i > 0) ? i : 1;
1503 inline int _DoubleToIntForSize(double f)
1507 int i = static_cast<int>(f + 0.01);
1508 return (i > 0) ? i : 1;
1516 inline int _DoubleToIntForRound(double f)
1518 return static_cast<int>(floor(f + 0.5));
1521 }} // Tizen::Graphics
1525 #endif //_FGRP_INTERNAL_RES_UTIL_H_