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.
19 * @file FUiAnimVisualElementSurface.cpp
20 * @brief This file contains implementation of VisualElementSurface class
22 * This file contains implementation VisualElementSurface class.
25 #include <unique_ptr.h>
26 #include <FBaseSysLog.h>
27 #include <FUiAnimVisualElementSurface.h>
29 #include "FUiAnim_VisualElementCanvas.h"
30 #include "FUiAnim_VisualElementSurfaceImpl.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
37 #define CHECK_NOT_CONSTRUCTED \
38 SysAssertf(__pVisualElementSurfaceImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
40 #define CHECK_CONSTRUCTED \
41 SysAssertf(__pVisualElementSurfaceImpl, "Not yet constructed! Construct() should be called before use.");
43 #define CHECK_PARAMETER_CONSTRUCTED(element) \
44 SysAssertf((element).__pVisualElementSurfaceImpl, "Not yet constructed! Construct() should be called before use.");
46 namespace Tizen { namespace Ui { namespace Animations
49 VisualElementSurface::VisualElementSurface(void)
50 : __pVisualElementSurfaceImpl(null)
54 VisualElementSurface::VisualElementSurface(const VisualElementSurface& rhs)
55 : __pVisualElementSurfaceImpl(null)
57 CHECK_PARAMETER_CONSTRUCTED(rhs);
59 __pVisualElementSurfaceImpl = rhs.__pVisualElementSurfaceImpl;
60 __pVisualElementSurfaceImpl->AddRef();
64 VisualElementSurface::operator =(const VisualElementSurface& rhs)
66 CHECK_PARAMETER_CONSTRUCTED(rhs);
70 if (__pVisualElementSurfaceImpl != null)
72 __pVisualElementSurfaceImpl->Release();
74 __pVisualElementSurfaceImpl = rhs.__pVisualElementSurfaceImpl;
75 __pVisualElementSurfaceImpl->AddRef();
81 VisualElementSurface::~VisualElementSurface(void)
85 if (__pVisualElementSurfaceImpl->Release())
87 __pVisualElementSurfaceImpl = null;
92 VisualElementSurface::Construct(const DisplayContext& displayContext, const Dimension& size)
94 CHECK_NOT_CONSTRUCTED;
96 SysTryReturnResult(NID_UI_ANIM, size.width >= 0 && size.height >= 0, E_OUT_OF_RANGE, "Can't create the canvas which size is less than zero.");
98 unique_ptr<_VisualElementSurfaceImpl> pImpl(_VisualElementSurfaceImpl::CreateInstanceN(displayContext, size));
99 result r = GetLastResult();
100 SysTryReturnResult(NID_UI_ANIM, pImpl, r, "Propagating.");
102 __pVisualElementSurfaceImpl = pImpl.release();
108 VisualElementSurface::GetBufferInfo(BufferInfo& bufferInfo) const
112 SysTryReturnResult(NID_UI_ANIM, &bufferInfo != null, E_INVALID_STATE, "BufferInfo is not initialized.");
114 __pVisualElementSurfaceImpl->GetBufferInfo(bufferInfo);
120 VisualElementSurface::GetSize(void) const
124 return __pVisualElementSurfaceImpl->GetSize();
128 VisualElementSurface::Equals(const Tizen::Base::Object& obj) const
132 return __pVisualElementSurfaceImpl->Equals(obj);
136 VisualElementSurface::GetHashCode(void) const
140 return __pVisualElementSurfaceImpl->GetHashCode();
143 }}} // Tizen::Ui::Animations