2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/actors/renderer-impl.h> // Dali::Internal::Renderer
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/event/common/stage-impl.h>
26 #include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
37 * |name |type |writable|animatable|constraint-input|enum for index-checking|
39 DALI_PROPERTY_TABLE_BEGIN
40 DALI_PROPERTY( "depth-index", INTEGER, true, true, true, Dali::Renderer::Property::DEPTH_INDEX )
41 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX )
43 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
45 } // unnamed namespace
47 RendererPtr Renderer::New()
49 RendererPtr rendererPtr( new Renderer() );
50 rendererPtr->Initialize();
54 void Renderer::SetGeometry( Geometry& geometry )
56 mGeometryConnector.Set( geometry, OnStage() );
57 const SceneGraph::Geometry* geometrySceneObject = geometry.GetGeometrySceneObject();
58 SetGeometryMessage( Stage::GetCurrent()->GetUpdateInterface(), *mSceneObject, *geometrySceneObject );
61 void Renderer::SetMaterial( Material& material )
63 mMaterialConnector.Set( material, OnStage() );
64 const SceneGraph::Material* materialSceneObject = material.GetMaterialSceneObject();
65 SetMaterialMessage( Stage::GetCurrent()->GetUpdateInterface(), *mSceneObject, *materialSceneObject );
68 void Renderer::SetDepthIndex( int depthIndex )
70 //SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, &mNode->mPosition, &AnimatableProperty<Vector3>::Bake, position );
72 DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
75 SceneGraph::RendererAttachment* Renderer::GetRendererSceneObject()
80 unsigned int Renderer::GetDefaultPropertyCount() const
82 return RENDERER_IMPL.GetDefaultPropertyCount();
85 void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
87 RENDERER_IMPL.GetDefaultPropertyIndices( indices );
90 const char* Renderer::GetDefaultPropertyName(Property::Index index) const
92 return RENDERER_IMPL.GetDefaultPropertyName( index );
95 Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
97 return RENDERER_IMPL.GetDefaultPropertyIndex( name );
100 bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
102 return RENDERER_IMPL.IsDefaultPropertyWritable( index );
105 bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
107 return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
110 bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
112 return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
115 Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
117 return RENDERER_IMPL.GetDefaultPropertyType( index );
120 void Renderer::SetDefaultProperty( Property::Index index,
121 const Property::Value& propertyValue )
123 RENDERER_IMPL.SetDefaultProperty( index, propertyValue );
126 void Renderer::SetSceneGraphProperty( Property::Index index,
127 const CustomProperty& entry,
128 const Property::Value& value )
130 RENDERER_IMPL.SetSceneGraphProperty( index, entry, value );
133 Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
135 return RENDERER_IMPL.GetDefaultProperty( index );
138 const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
140 return RENDERER_IMPL.GetPropertyOwner();
143 const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
148 const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
150 return RENDERER_IMPL.GetSceneObjectAnimatableProperty( index );
153 const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
155 return RENDERER_IMPL.GetSceneObjectInputProperty( index );
158 int Renderer::GetPropertyComponentIndex( Property::Index index ) const
160 return RENDERER_IMPL.GetPropertyComponentIndex( index );
163 bool Renderer::OnStage() const
166 //DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
170 void Renderer::Connect()
172 // TODO: MESH_REWORK : check this
173 mGeometryConnector.OnStageConnect();
174 mMaterialConnector.OnStageConnect();
178 void Renderer::Disconnect()
180 // TODO: MESH_REWORK : check this
181 mGeometryConnector.OnStageDisconnect();
182 mMaterialConnector.OnStageDisconnect();
187 : mSceneObject(NULL),
192 void Renderer::Initialize()
194 // Transfer object ownership of scene-object to message
195 mSceneObject = SceneGraph::RendererAttachment::New();
197 // Send message to update to connect to scene graph:
198 AttachToSceneGraphMessage( Stage::GetCurrent()->GetUpdateManager(), mSceneObject );
202 } // namespace Internal