Merge "Change the timing of Context::GlContextCreated()" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / renderer.cpp
1 /*
2  * Copyright (c) 2020 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/public-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, Shader& shader )
28 {
29   Internal::RendererPtr renderer = Internal::Renderer::New(  );
30   renderer->SetGeometry( GetImplementation(geometry) );
31   renderer->SetShader( GetImplementation(shader) );
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 ) = default;
44
45 Renderer Renderer::DownCast( BaseHandle handle )
46 {
47   return Renderer( dynamic_cast<Dali::Internal::Renderer*>(handle.GetObjectPtr()));
48 }
49
50 Renderer& Renderer::operator=( const Renderer& handle ) = default;
51
52 Renderer::Renderer( Renderer&& rhs ) =  default;
53
54 Renderer& Renderer::operator=( Renderer&& rhs ) =  default;
55
56 void Renderer::SetGeometry( Geometry& geometry )
57 {
58   DALI_ASSERT_ALWAYS( geometry && "Geometry handle not initialized" );
59   GetImplementation(*this).SetGeometry( GetImplementation(geometry) );
60 }
61
62 Geometry Renderer::GetGeometry() const
63 {
64   return Dali::Geometry( GetImplementation(*this).GetGeometry().Get() );
65 }
66
67 void Renderer::SetTextures( TextureSet& textureSet )
68 {
69   DALI_ASSERT_ALWAYS( textureSet && "TextureSet handle not initialized" );
70   GetImplementation(*this).SetTextures( GetImplementation(textureSet) );
71 }
72
73 TextureSet Renderer::GetTextures() const
74 {
75   return Dali::TextureSet( GetImplementation(*this).GetTextures().Get() );
76 }
77
78 void Renderer::SetShader( Shader& shader )
79 {
80   DALI_ASSERT_ALWAYS( shader && "Shader handle not initialized" );
81   GetImplementation(*this).SetShader( GetImplementation(shader) );
82 }
83
84 Shader Renderer::GetShader() const
85 {
86   return Dali::Shader( GetImplementation(*this).GetShader().Get() );
87 }
88
89 Renderer::Renderer( Internal::Renderer* pointer )
90 : Handle( pointer )
91 {
92 }
93
94 } //namespace Dali