Updates to event/update interface
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / renderer-impl.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/internal/event/actors/renderer-impl.h> // Dali::Internal::Renderer
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/renderer.h> // Dali::Renderer
23 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
24 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
25 #include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31
32 namespace
33 {
34
35 /**
36  *            |name          |type     |writable|animatable|constraint-input|enum for index-checking|
37  */
38 DALI_PROPERTY_TABLE_BEGIN
39 DALI_PROPERTY( "depth-index", INTEGER,  true, true, true, Dali::Renderer::Property::DEPTH_INDEX )
40 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX )
41
42 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
43
44 } // unnamed namespace
45
46 RendererPtr Renderer::New()
47 {
48   return RendererPtr( new Renderer() );
49 }
50
51 void Renderer::SetGeometry( Geometry& geometry )
52 {
53   mGeometryConnector.Set( geometry, OnStage() );
54 }
55
56 void Renderer::SetMaterial( Material& material )
57 {
58   mMaterialConnector.Set( material, OnStage() );
59 }
60
61 void Renderer::SetDepthIndex( int depthIndex )
62 {
63   //SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, &mNode->mPosition, &AnimatableProperty<Vector3>::Bake, position );
64   // TODO: MESH_REWORK
65   DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
66 }
67
68 unsigned int Renderer::GetDefaultPropertyCount() const
69 {
70   return RENDERER_IMPL.GetDefaultPropertyCount();
71 }
72
73 void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
74 {
75   RENDERER_IMPL.GetDefaultPropertyIndices( indices );
76 }
77
78 const char* Renderer::GetDefaultPropertyName(Property::Index index) const
79 {
80   return RENDERER_IMPL.GetDefaultPropertyName( index );
81 }
82
83 Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
84 {
85   return RENDERER_IMPL.GetDefaultPropertyIndex( name );
86 }
87
88 bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
89 {
90   return RENDERER_IMPL.IsDefaultPropertyWritable( index );
91 }
92
93 bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
94 {
95   return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
96 }
97
98 bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
99 {
100   return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
101 }
102
103 Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
104 {
105   return RENDERER_IMPL.GetDefaultPropertyType( index );
106 }
107
108 void Renderer::SetDefaultProperty( Property::Index index,
109                                    const Property::Value& propertyValue )
110 {
111   RENDERER_IMPL.SetDefaultProperty( index, propertyValue );
112 }
113
114 void Renderer::SetSceneGraphProperty( Property::Index index,
115                                       const CustomProperty& entry,
116                                       const Property::Value& value )
117 {
118   RENDERER_IMPL.SetSceneGraphProperty( index, entry, value );
119 }
120
121 Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
122 {
123   return RENDERER_IMPL.GetDefaultProperty( index );
124 }
125
126 const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
127 {
128   return RENDERER_IMPL.GetPropertyOwner();
129 }
130
131 const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
132 {
133   return mSceneObject;
134 }
135
136 const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
137 {
138   return RENDERER_IMPL.GetSceneObjectAnimatableProperty( index );
139 }
140
141 const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
142 {
143   return RENDERER_IMPL.GetSceneObjectInputProperty( index );
144 }
145
146 int Renderer::GetPropertyComponentIndex( Property::Index index ) const
147 {
148   return RENDERER_IMPL.GetPropertyComponentIndex( index );
149 }
150
151 bool Renderer::OnStage() const
152 {
153   // TODO: MESH_REWORK
154   DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
155   return false;
156 }
157
158 void Renderer::Connect()
159 {
160   // TODO: MESH_REWORK : check this
161   mGeometryConnector.OnStageConnect();
162   mMaterialConnector.OnStageConnect();
163 }
164
165 void Renderer::Disconnect()
166 {
167   // TODO: MESH_REWORK : check this
168   mGeometryConnector.OnStageDisconnect();
169   mMaterialConnector.OnStageDisconnect();
170 }
171
172 Renderer::Renderer()
173 : mSceneObject(NULL)
174 {
175 }
176
177 } // namespace Internal
178 } // namespace Dali