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.
18 * @file FUiEffectsEffect.cpp
19 * @brief This file contains implementation of Effect class.
22 #include <FUiEffectsEffect.h>
28 #include <FBaseColIList.h>
29 #include <FBaseSysLog.h>
30 #include <FBaseErrors.h>
31 #include <FUiTouchEventInfo.h>
33 #include <FUiEffectsEffectManager.h>
34 #include <FUiEffectsEffectTouchInfo.h>
35 #include <FUiEffectsIEffectEventListener.h>
36 #include <FUiEffectsIEffectResourceProvider.h>
38 #include "FUiEffects_EffectManagerImpl.h"
39 #include <FUiEffects_LoggingProfiler.h>
40 #include "FUiEffects_EffectErrorMessages.h"
41 #include <FUiEffects_RuntimeIEffectModelListener.h>
42 #include <FUiEffects_ParserEffectParser.h>
43 #include <FUiEffects_EffectImpl.h>
45 using namespace Tizen::Ui::Controls;
46 using namespace Tizen::Base::Runtime;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Base::Collection;
50 using namespace Tizen::Ui::Effects::_Runtime;
51 using namespace Tizen::Ui::Effects::_Renderer;
52 using namespace Tizen::Ui::Effects::_Parser;
53 using namespace Tizen::Ui::Effects;
54 using namespace Tizen::Ui::Effects::_Utils;
57 using namespace Tizen::Graphics;
58 using namespace Tizen::Base;
60 namespace Tizen { namespace Ui { namespace Effects
66 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
68 SetLastResult(E_SUCCESS);
71 result r = emptyList.Construct();
72 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
74 r = __pEffectImpl->Start(emptyList);
75 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
80 Effect::Start(const Tizen::Base::Collection::IList& effectStartInfo)
82 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
84 SetLastResult(E_SUCCESS);
85 result r = __pEffectImpl->Start(effectStartInfo);
86 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
93 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
95 SetLastResult(E_SUCCESS);
96 result r = __pEffectImpl->Stop();
97 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
102 Effect::SetRenderTarget(Tizen::Ui::Control* pControl)
104 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
106 SetLastResult(E_SUCCESS);
107 result r = __pEffectImpl->SetRenderTarget(pControl);
108 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
114 Effect::FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset)
116 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
118 SetLastResult(E_SUCCESS);
119 result r = __pEffectImpl->FeedTouchPressEvent(touchEventInfo, offset);
120 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
125 Effect::FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo)
127 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
129 SetLastResult(E_SUCCESS);
130 result r = __pEffectImpl->FeedTouchPressEvent(touchEventInfo, Point(0, 0));
131 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
136 Effect::FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset)
138 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
140 SetLastResult(E_SUCCESS);
141 result r = __pEffectImpl->FeedTouchMoveEvent(touchEventInfo, offset);
142 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
147 Effect::FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo)
149 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
151 SetLastResult(E_SUCCESS);
152 result r = __pEffectImpl->FeedTouchMoveEvent(touchEventInfo, Point(0, 0));
153 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
158 Effect::FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset)
160 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
162 SetLastResult(E_SUCCESS);
163 result r = __pEffectImpl->FeedTouchReleaseEvent(touchEventInfo, offset);
164 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
169 Effect::FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo)
171 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
173 SetLastResult(E_SUCCESS);
174 result r = __pEffectImpl->FeedTouchReleaseEvent(touchEventInfo, Point(0, 0));
175 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
180 Effect::FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset)
182 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
184 SetLastResult(E_SUCCESS);
185 result r = __pEffectImpl->FeedTouchDoublePressEvent(touchEventInfo, offset);
186 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
191 Effect::FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo)
193 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
195 SetLastResult(E_SUCCESS);
196 result r = __pEffectImpl->FeedTouchDoublePressEvent(touchEventInfo, Point(0, 0));
197 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
202 Effect::SetBitmap(long bitmapId, const Tizen::Graphics::Bitmap& bitmap)
204 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
206 SetLastResult(E_SUCCESS);
207 result r = __pEffectImpl->SetBitmap(bitmapId, bitmap);
208 SysTryReturn(NID_UI_EFFECT, !(r == E_OUT_OF_MEMORY), E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagating.", GetErrorMessage(r));
209 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
214 Effect::IsRunning(void) const
216 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
218 SetLastResult(E_SUCCESS);
219 bool isRunning = __pEffectImpl->IsRunning();
220 result r = GetLastResult();
221 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, isRunning, r, "[%s] Propagating.", GetErrorMessage(r));
226 Effect::GetType(void) const
228 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
230 SetLastResult(E_SUCCESS);
231 EffectType effectType = __pEffectImpl->GetType();
232 result r = GetLastResult();
233 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, effectType, r, "[%s] Propagating.", GetErrorMessage(r));
238 Effect::GetName(void) const
240 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
242 SetLastResult(E_SUCCESS);
243 String effectName = __pEffectImpl->GetName();
244 result r = GetLastResult();
245 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, effectName, r, "[%s] Propagating.", GetErrorMessage(r));
250 Effect::SetEffectEventListener(IEffectEventListener* pListener)
252 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
254 SetLastResult(E_SUCCESS);
255 __pEffectImpl->SetEffectEventListener(pListener);
256 result r = GetLastResult();
257 SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
260 IEffectEventListener*
261 Effect::GetEffectEventListener(void) const
263 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
265 SetLastResult(E_SUCCESS);
266 IEffectEventListener* listener = null;
267 listener = __pEffectImpl->GetEffectEventListener();
268 result r = GetLastResult();
269 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, listener, r, "[%s] Propagating.", GetErrorMessage(r));
274 Effect::SetResourceProvider(IEffectResourceProvider* pProvider)
276 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
278 SetLastResult(E_SUCCESS);
279 __pEffectImpl->SetResourceProvider(pProvider);
280 result r = GetLastResult();
281 SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
284 IEffectResourceProvider*
285 Effect::GetResourceProvider(void) const
287 SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR);
289 SetLastResult(E_SUCCESS);
290 IEffectResourceProvider* provider = null;
291 provider = __pEffectImpl->GetResourceProvider();
292 result r = GetLastResult();
293 SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, provider, r, "[%s] Propagating.", GetErrorMessage(r));
298 : __pEffectImpl(null)
300 __pEffectImpl = new (std::nothrow) _EffectImpl(*this);
301 SysTryReturnVoidResult(NID_UI_EFFECT, __pEffectImpl != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
303 __pEffectImpl->InitializeEffect();
307 Effect::~Effect(void)
309 if (__pEffectImpl != null)
311 delete __pEffectImpl;
312 __pEffectImpl = null;
316 }}} // Tizen::Ui::Effects