Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / FGrp_BufferInfoImpl.cpp
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 /*
19  * @file        FGrp_BufferInfoImpl.cpp
20  * @brief       This is the implementation file for %_BufferInfoImpl class.
21  *
22  */
23
24 #include <FGrpBufferInfo.h>
25
26 #include "FGrp_BufferInfoImpl.h"
27
28
29 namespace Tizen { namespace Graphics
30 {
31
32 _BufferInfoImpl::_BufferInfoImpl()
33         : __handleType(HANDLE_TYPE_NONE)
34         , __handle(INVALID_BUFFER_HANDLE)
35         , __orientation(ORIENTATION_PORTRAIT)
36         , __rotation(ROTATION_0)
37 {
38 }
39
40 _BufferInfoImpl::_BufferInfoImpl(const _BufferInfoImpl& src)
41         : __handleType(src.__handleType)
42         , __handle(src.__handle)
43         , __orientation(src.__orientation)
44         , __rotation(ROTATION_0)
45 {
46 }
47
48 _BufferInfoImpl::~_BufferInfoImpl()
49 {
50 }
51
52 _BufferInfoImpl&
53 _BufferInfoImpl::operator =(const _BufferInfoImpl& rhs)
54 {
55         if (this == &rhs)
56         {
57                 return *this;
58         }
59
60         this->__handle = rhs.__handle;
61         this->__orientation = rhs.__orientation;
62
63         return *this;
64 }
65
66 int
67 _BufferInfoImpl::GetHandle(HandleType handleType) const
68 {
69         switch (handleType)
70         {
71         case HANDLE_TYPE_OVERLAY_REGION:
72         case HANDLE_TYPE_VE_SURFACE:
73         case HANDLE_TYPE_CANVAS_TEXTURE:
74                 return (__handleType == handleType) ? __handle : INVALID_BUFFER_HANDLE;
75         case HANDLE_TYPE_NONE:
76         default:
77                 return INVALID_BUFFER_HANDLE;
78         }
79 }
80
81 void
82 _BufferInfoImpl::SetHandle(HandleType handleType, int handle)
83 {
84         switch (handleType)
85         {
86         case HANDLE_TYPE_NONE:
87                 __handleType = HANDLE_TYPE_NONE;
88                 __handle = INVALID_BUFFER_HANDLE;
89                 break;
90         case HANDLE_TYPE_OVERLAY_REGION:
91         case HANDLE_TYPE_VE_SURFACE:
92         case HANDLE_TYPE_CANVAS_TEXTURE:
93                 __handleType = handleType;
94                 __handle = handle;
95                 break;
96         }
97 }
98
99 _BufferInfoImpl::Orientation
100 _BufferInfoImpl::GetOrientation(void) const
101 {
102         return __orientation;
103 }
104
105 void
106 _BufferInfoImpl::SetOrientation(_BufferInfoImpl::Orientation orientation)
107 {
108         if (orientation >= ORIENTATION_PORTRAIT && orientation <= ORIENTATION_LANDSCAPE_REVERSE)
109         {
110                 __orientation = orientation;
111         }
112         else
113         {
114                 __orientation = ORIENTATION_PORTRAIT;
115         }
116 }
117
118 Rectangle
119 _BufferInfoImpl::GetBounds(void) const
120 {
121         return __bounds;
122 }
123
124 void
125 _BufferInfoImpl::SetBounds(const Rectangle& bounds)
126 {
127         __bounds.x = bounds.x;
128         __bounds.y = bounds.y;
129         __bounds.width = bounds.width;
130         __bounds.height = bounds.height;
131 }
132
133 _BufferInfoImpl::Rotation
134 _BufferInfoImpl::GetRotation(void) const
135 {
136         return __rotation;
137 }
138
139 void
140 _BufferInfoImpl::SetRotation(_BufferInfoImpl::Rotation rotation)
141 {
142         if (rotation >= ROTATION_0 && rotation <= ROTATION_270)
143         {
144                 __rotation = rotation;
145         }
146         else
147         {
148                 __rotation = ROTATION_0;
149         }
150 }
151
152 _BufferInfoImpl*
153 _BufferInfoImpl::GetInstance(BufferInfo& bufferInfo)
154 {
155         return (&bufferInfo != null) ? bufferInfo.__pImpl : null;
156 }
157
158 const _BufferInfoImpl*
159 _BufferInfoImpl::GetInstance(const BufferInfo& bufferInfo)
160 {
161         return (&bufferInfo != null) ? bufferInfo.__pImpl : null;
162 }
163
164 }} // Tizen::Graphics