Merge branch 'devel/new_mesh' into devel/master
[platform/core/uifw/dali-core.git] / dali / devel-api / rendering / renderer.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/rendering/renderer.h>  // Dali::Renderer
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/rendering/renderer-impl.h> // Dali::Internal::Renderer
23
24 namespace Dali
25 {
26
27 Renderer Renderer::New( Geometry& geometry, Material& material )
28 {
29   Internal::RendererPtr renderer = Internal::Renderer::New(  );
30   renderer->SetGeometry( GetImplementation(geometry) );
31   renderer->SetMaterial( GetImplementation(material) );
32   return Renderer( renderer.Get() );
33 }
34
35 Renderer::Renderer()
36 {
37 }
38
39 Renderer::~Renderer()
40 {
41 }
42
43 Renderer::Renderer( const Renderer& handle )
44 : Handle( handle )
45 {
46 }
47
48 Renderer Renderer::DownCast( BaseHandle handle )
49 {
50   return Renderer( dynamic_cast<Dali::Internal::Renderer*>(handle.GetObjectPtr()));
51 }
52
53 Renderer& Renderer::operator=( const Renderer& handle )
54 {
55   BaseHandle::operator=( handle );
56   return *this;
57 }
58
59 void Renderer::SetGeometry( Geometry& geometry )
60 {
61   DALI_ASSERT_ALWAYS( geometry && "Geometry handle not initialized" );
62   GetImplementation(*this).SetGeometry( GetImplementation(geometry) );
63 }
64
65 Geometry Renderer::GetGeometry() const
66 {
67   Internal::Geometry* geometryPtr( GetImplementation(*this).GetGeometry() );
68   return Dali::Geometry( geometryPtr );
69 }
70
71 void Renderer::SetMaterial( Material& material )
72 {
73   DALI_ASSERT_ALWAYS( material && "Material handle not initialized" );
74   GetImplementation(*this).SetMaterial( GetImplementation(material) );
75 }
76
77 Material Renderer::GetMaterial() const
78 {
79   Internal::Material* materialPtr( GetImplementation(*this).GetMaterial() );
80   return Dali::Material( materialPtr );
81 }
82
83 void Renderer::SetDepthIndex( int depthIndex )
84 {
85   GetImplementation(*this).SetDepthIndex( depthIndex );
86 }
87
88 int Renderer::GetDepthIndex()
89 {
90   return GetImplementation(*this).GetDepthIndex();
91 }
92
93 Renderer::Renderer( Internal::Renderer* pointer )
94 : Handle( pointer )
95 {
96 }
97
98 } //namespace Dali