Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / FUiEffects_RendererViewport.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  * @file        FUiEffects_RendererViewport.h
19  * @brief               This is the header file for the Viewport class
20  */
21
22 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_
23 #define _FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_
24
25 #include <utils/FUiEffects_Utils.h>
26 #include "FUiEffects_RendererLog.h"
27
28 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer
29 {
30
31 /**
32  * @class       Viewport
33  * @brief       This class for scene viewport and coordinates transformations. Currently for orto projection ONLY!!!!!!, Z = 0
34  *
35  */
36 struct Viewport
37 {
38         /**
39          * Transforms window coordinates to model space
40          *
41          * @param [in]  p       point on screen
42          *
43          * @return              Vec3f           Point in model space
44          */
45         Tizen::Ui::Effects::_Utils::Vec3f TransformScreenToWorld(Tizen::Ui::Effects::_Utils::Vec2f p) const
46         {
47                 if ((fabsf(screenRight - screenLeft) > std::numeric_limits<float>::epsilon()) && (fabsf(screenTop - screenBottom) > std::numeric_limits<float>::epsilon()))
48                 {
49                         return Tizen::Ui::Effects::_Utils::Vec3f((p.x - screenLeft) * (worldRight - worldLeft) / (screenRight - screenLeft) + worldLeft,
50                                         p.y * (worldTop - worldBottom) / (screenBottom - screenTop) + worldBottom,
51                                         0.0f);
52                 }
53                 else
54                 {
55                         return Tizen::Ui::Effects::_Utils::Vec3f(0.0f, 0.0f, 0.0f);
56                 }
57         }
58
59         float screenLeft;
60         float screenRight;
61         float screenTop;
62         float screenBottom;
63         float worldLeft;
64         float worldRight;
65         float worldTop;
66         float worldBottom;
67         float worldZ;
68         float worldNearDist;
69         float worldFarDist;
70
71         int displayWidth;
72         int displayHeight;
73 };
74
75 } } } } // Tizen::Ui::Effects::_EffectRenderer
76
77 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_