Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_OverlayAgent.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        FUiCtrl_OverlayAgent.h
19  * @brief       This is the header file for the _OverlayAgent class.
20  *
21  * This header file contains the declarations of the _OverlayAgent class.
22  *
23  */
24 #ifndef _FUI_INTERNAL_OVERLAY_AGENT_H_
25 #define _FUI_INTERNAL_OVERLAY_AGENT_H_
26
27 #include <X11/Xlib.h>
28 #include <X11/extensions/Xvlib.h>
29
30 #include <Evas.h>
31 #include <Ecore.h>
32 #include <Ecore_X.h>
33
34 #include <FBaseDataType.h>
35
36 namespace Tizen { namespace Base
37 {
38 class ByteBuffer;
39 }} // Tizen::Base
40
41 namespace Tizen { namespace Ui
42 {
43 class _Controls;
44 }} // Tizen::Base
45
46 namespace Tizen { namespace Graphics
47 {
48 class BufferInfo;
49 class Dimension;
50 class Rectangle;
51 }} // Tizen::Graphics
52
53 namespace Tizen { namespace Ui { namespace Animations
54 {
55 class _VisualElement;
56 } } }
57
58 namespace Tizen { namespace Ui { namespace Controls
59 {
60 enum _OverlayAgentRotation
61 {
62         _OVERLAY_AGENT_ROTATION_NONE,
63         _OVERLAY_AGENT_ROTATION_90,
64         _OVERLAY_AGENT_ROTATION_180,
65         _OVERLAY_AGENT_ROTATION_270,
66         _OVERLAY_AGENT_ROTATION_NONE_LR,
67         _OVERLAY_AGENT_ROTATION_NONE_UD,
68         _OVERLAY_AGENT_ROTATION_90_LR,
69         _OVERLAY_AGENT_ROTATION_90_UD,
70         _OVERLAY_AGENT_ROTATION_180_LR,
71         _OVERLAY_AGENT_ROTATION_180_UD,
72         _OVERLAY_AGENT_ROTATION_270_LR,
73         _OVERLAY_AGENT_ROTATION_270_UD,
74         _OVERLAY_AGENT_ROTATION_MAX
75 };
76
77 enum _OverlayAgentBufferPixelFormat
78 {
79         _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888,
80         _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565,
81         _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR,
82         _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_NV12,
83         _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_UYVY
84 };
85
86 enum _OverlayAgentStyle
87 {
88         _OVERLAY_AGENT_STYLE_NONE,
89         _OVERLAY_AGENT_STYLE_REGION_SW,
90         _OVERLAY_AGENT_STYLE_REGION_GL,
91         _OVERLAY_AGENT_STYLE_PANEL_SW,
92         _OVERLAY_AGENT_STYLE_PANEL_GL
93 };
94
95 class _OverlayAgent
96 {
97 public:
98         static _OverlayAgent* CreateInstanceN(_OverlayAgentStyle style, const _Control& control, const Tizen::Graphics::Rectangle& phyBounds);
99         ~_OverlayAgent(void);
100
101         result Draw(void);
102         result GetBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const;
103
104         result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer,
105                                         const Tizen::Graphics::Dimension& srcDim, _OverlayAgentBufferPixelFormat srcFormat);
106         result SetRotation(_OverlayAgentRotation rotation);
107         result SetDestination(const Tizen::Graphics::Dimension& dimension);
108         result SetAspectRatio(bool enable);
109
110         result CreatePixmap(void);
111         Pixmap GetPixmap(void) const;
112         Evas_Object* GetPixmapImageObject(void) const;
113
114         result GrabXvPort(void);
115         void UngrabXvPort(void);
116
117         result Show(void) const;
118         result AdjustImageObject(void);
119
120         static int GetOverlayAgentCount(void);
121
122         static int GetDstRectMinWidth(void);
123         static int GetDstRectMinHeight(void);
124         static int GetSrcRectMinWidth(void);
125         static int GetSrcRectMinHeight(void);
126
127 private:
128         result CreateImageObjectForOverlayRegion(const _Control& control, const Tizen::Graphics::Rectangle& bounds);
129         result CreateImageObject(const _Control& control, const Tizen::Graphics::Rectangle& bounds);
130
131         result PutXvImage(void);
132         result PutEvasImage(void);
133
134         bool IsValidSourceDimension(const Tizen::Graphics::Dimension& dimension) const;
135         bool IsValidDestinationDimension(const Tizen::Graphics::Dimension& dimension) const;
136
137         _OverlayAgent(_OverlayAgentStyle style, const _Control& control, const Tizen::Graphics::Rectangle& bounds);
138
139         _OverlayAgent(const _OverlayAgent& rhs);
140         _OverlayAgent& operator=(const _OverlayAgent& rhs);
141
142 private:
143         const static int _OVERLAYAGENT_XV_PORT = 100;
144
145         static int overlayAgentcount;
146         static int overlayAgentXvPortCount;
147         static int baseXvPort;
148         static bool isPortGrapped[_OVERLAYAGENT_XV_PORT];
149
150         static int dstRectMinWidth;
151         static int dstRectMinHegith;
152         static int srcRectMinWidth;
153         static int srcRectMinHegith;
154
155         Evas_Object* __pImageObject;
156         Evas_Object* __pRenderImageObject;
157         Evas_Object* __pSmartObject;
158
159         Ecore_X_Damage  __pixmapDamageHandle;
160         Ecore_Event_Handler *__pPixmapEventHandler;
161         Pixmap __pixmap;
162
163         Tizen::Ui::Animations::_VisualElement* __pVisualElement;
164         Tizen::Graphics::Color  __bgColor;
165
166         int __xvPort;
167         bool __grabXvPort;
168
169         unsigned int __colorFormat;
170         int __userRotation;
171         bool __flushRotate;
172         int __udMirroring;
173         int __lrMirroring;
174         bool __aspectRatio;
175
176         Tizen::Graphics::Dimension __srcDimension;
177         Tizen::Graphics::Dimension __destDimension;
178         Tizen::Graphics::Rectangle __pixmapPhyRect;
179         Tizen::Graphics::Rectangle __resizeRect;
180
181         _OverlayAgentStyle __style;
182
183         XvImage* __pXvImage;
184         unsigned int __newColorFormat;
185         XShmSegmentInfo* __pShmInfo;
186
187         _OverlayAgentBufferPixelFormat __overlayAgentColorFormat;
188         const Tizen::Base::ByteBuffer* __pRefUserByteBuffer;
189         Tizen::Base::ByteBuffer* __pOrgUserByteBuffer;
190         Tizen::Graphics::Dimension __orgImgDimension;
191
192 }; // _OverlayAgent
193
194 }}} // Tizen::Ui
195
196 #endif // _FUI_INTERNAL_OVERLAY_AGENT_H_
197