Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / renderer / FUiEffects_RendererRendererGeometry.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        FUiEffects_RendererRendererGeometry.cpp
20  * @brief               This is the source file for the RendererGeometry class
21  */
22
23 #include <FUiEffects_RendererRendererGeometry.h>
24 #include <FUiEffects_RendererEffectShader.h>
25 #include <FUiEffects_RendererLog.h>
26 #include <FUiEffects_EffectErrorMessages.h>
27
28 using namespace Tizen::Ui::Effects::_Renderer::Math;
29 using namespace Tizen::Ui::Effects::_Renderer::EngineModel;
30 using namespace Tizen::Ui::Effects::_Runtime;
31
32 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer
33 {
34
35 RendererGeometry::RendererGeometry(void)
36 {
37         result r = GetLastResult();
38         SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
39
40         __composite = Buffer_CompositeFloatVertexPtr(new (std::nothrow) _Buffer_CompositeFloatVertex());
41         __indexTriangles = Buffer_UIntIndexPtr(new (std::nothrow) _Buffer_UShortIndex());
42
43         __partVertex = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 3, VertexData::OffsetPos(), VertexData::Stride()));
44         __partNormal = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 3,  VertexData::OffsetNorm(), VertexData::Stride()));
45         __partTexCoords = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 2, VertexData::OffsetTexCoords(), VertexData::Stride()));
46
47         r = GetLastResult();
48         SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
49         SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__composite) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
50         SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__indexTriangles) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
51         SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partVertex) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
52         SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partNormal) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
53         SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partTexCoords) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
54 }
55
56 RendererGeometry::~RendererGeometry(void)
57 {
58         return;
59 }
60
61 BufferPtr
62 RendererGeometry::GetBuffer(const std::string& aName) const
63 {
64         if (aName == SHADER_IN_POSITION_STR)
65         {
66                 return __partVertex;
67         }
68         else if (aName == SHADER_IN_TEXCOORDS_STR )
69         {
70                 return __partTexCoords;
71         }
72         else if (aName == SHADER_IN_NORMAL_STR)
73         {
74                 return __partNormal;
75         }
76
77         return BufferPtr();
78 }
79
80 }}}} //Tizen::Ui::Effects::_Renderer