Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / opengl / FGrpGlPlayer.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        FGrpGlPlayer.cpp
20  * @brief       This is the implementation file for GlPlayer class.
21  *
22  */
23
24 #include <new>
25
26 #include <FGrpGlPlayer.h>
27
28 #include <FBaseErrors.h>
29 #include <FBaseResult.h>
30 #include <FBaseSysLog.h>
31
32 #include "FGrp_GlPlayerImpl.h"
33
34 #define CHECK_CONSTRUCTED \
35         SysAssertf((this->__pImpl != null) && this->__pImpl->IsValid(), "Not yet constructed. Construct() should be called before use.");
36
37 namespace Tizen { namespace Graphics { namespace Opengl
38 {
39
40 GlPlayer::GlPlayer(void)
41         : __pImpl(new (std::nothrow)_GlPlayerImpl)
42 {
43 }
44
45 GlPlayer::~GlPlayer(void)
46 {
47         delete this->__pImpl;
48 }
49
50 result
51 GlPlayer::Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl)
52 {
53         ClearLastResult();
54         SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "Fails to allocate memory.")
55         SysAssertf(this->__pImpl->IsValid() == false , "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
56
57         result r = this->__pImpl->Construct(version, pControl);
58
59         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
60
61         return E_SUCCESS;
62 }
63
64 result
65 GlPlayer::Start(void)
66 {
67         CHECK_CONSTRUCTED;
68
69         result r = this->__pImpl->Start();
70
71         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
72
73         return E_SUCCESS;
74 }
75
76 result
77 GlPlayer::Pause(void)
78 {
79         CHECK_CONSTRUCTED;
80
81         result r = this->__pImpl->Pause();
82
83         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
84
85         return E_SUCCESS;
86 }
87
88 result
89 GlPlayer::Resume(void)
90 {
91         CHECK_CONSTRUCTED;
92
93         result r = this->__pImpl->Resume();
94
95         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
96
97         return E_SUCCESS;
98 }
99
100 result
101 GlPlayer::Stop(void)
102 {
103         CHECK_CONSTRUCTED;
104
105         result r = this->__pImpl->Stop();
106
107         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
108
109         return E_SUCCESS;
110 }
111
112 result
113 GlPlayer::Redraw(void)
114 {
115         CHECK_CONSTRUCTED;
116
117         result r = this->__pImpl->Redraw();
118
119         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
120
121         return E_SUCCESS;
122 }
123
124 void
125 GlPlayer::SetFps(int fps)
126 {
127         CHECK_CONSTRUCTED;
128
129         this->__pImpl->SetFps(fps);
130 }
131
132 result
133 GlPlayer::SetEglAttributeList(const EGLint* pEglConfigList)
134 {
135         CHECK_CONSTRUCTED;
136
137         result r = this->__pImpl->SetEglAttributeList(pEglConfigList);
138
139         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
140
141         return E_SUCCESS;
142 }
143
144 result
145 GlPlayer::SetEglAttributePreset(EglAttributesPreset preset)
146 {
147         CHECK_CONSTRUCTED;
148
149         result r = this->__pImpl->SetEglAttributePreset(preset);
150
151         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
152
153         return E_SUCCESS;
154 }
155
156 result
157 GlPlayer::SetEglAttribute(EGLint key, EGLint value)
158 {
159         CHECK_CONSTRUCTED;
160
161         result r = this->__pImpl->SetEglAttribute(key, value);
162
163         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
164
165         return E_SUCCESS;
166 }
167
168 result
169 GlPlayer::SetIGlRenderer(IGlRenderer* pRenderer)
170 {
171         CHECK_CONSTRUCTED;
172
173         result r = this->__pImpl->SetIGlRenderer(pRenderer);
174
175         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
176
177         return E_SUCCESS;
178 }
179
180 }}} // Tizen::Graphics::Opengl