1 #ifndef DALI_INTERNAL_RENDERER_H
2 #define DALI_INTERNAL_RENDERER_H
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
25 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
26 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
27 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
28 #include <dali/internal/event/rendering/material-impl.h> // Dali::Internal::Material
29 #include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
42 typedef IntrusivePtr<Renderer> RendererPtr;
45 * Renderer is an object that can be used to show content by combining a Geometry with a material.
47 class Renderer : public Object
52 * Create a new Renderer.
53 * @return A smart-pointer to the newly allocated Renderer.
55 static RendererPtr New();
58 * @copydoc Dali::Renderer::SetGeometry()
60 void SetGeometry( Geometry& geometry );
63 * @copydoc Dali::Renderer::GetGeometry()
65 Geometry* GetGeometry() const;
68 * @copydoc Dali::Renderer::SetMaterial()
70 void SetMaterial( Material& material );
73 * @copydoc Dali::Renderer::GetMaterial()
75 Material* GetMaterial() const;
78 * @copydoc Dali::Renderer::SetDepthIndex()
80 void SetDepthIndex( int depthIndex );
83 * @copydoc Dali::Renderer::GetDepthIndex()
85 int GetDepthIndex() const;
88 * @brief Get the scene graph object ( the node attachment )
90 * @return the scene object
92 SceneGraph::Renderer* GetRendererSceneObject();
94 public: // Default property extensions from Object
97 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
99 virtual unsigned int GetDefaultPropertyCount() const;
102 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
104 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
107 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
109 virtual const char* GetDefaultPropertyName(Property::Index index) const;
112 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
114 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
117 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
119 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
122 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
124 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
127 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
129 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
132 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
134 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
137 * @copydoc Dali::Internal::Object::SetDefaultProperty()
139 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
142 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
144 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
147 * @copydoc Dali::Internal::Object::GetDefaultProperty()
149 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
152 * @copydoc Dali::Internal::Object::GetPropertyOwner()
154 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
157 * @copydoc Dali::Internal::Object::GetSceneObject()
159 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
162 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
164 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
167 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
169 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
172 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
174 virtual int GetPropertyComponentIndex( Property::Index index ) const;
176 public: // Functions from Connectable
178 * @copydoc Dali::Internal::Connectable::OnStage()
180 virtual bool OnStage() const;
183 * @copydoc Dali::Internal::Connectable::Connect()
185 virtual void Connect();
188 * @copydoc Dali::Internal::Connectable::Disconnect()
190 virtual void Disconnect();
192 private: // implementation
199 * A reference counted object may only be deleted by calling Unreference()
203 private: // unimplemented methods
204 Renderer( const Renderer& );
205 Renderer& operator=( const Renderer& );
208 SceneGraph::Renderer* mSceneObject;
209 ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
210 ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
215 } // namespace Internal
217 // Helpers for public-api forwarding methods
218 inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
220 DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
222 BaseObject& object = handle.GetBaseObject();
224 return static_cast<Internal::Renderer&>(object);
227 inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
229 DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
231 const BaseObject& object = handle.GetBaseObject();
233 return static_cast<const Internal::Renderer&>(object);
238 #endif // DALI_INTERNAL_RENDERER_H