ca341ffeb59619e24932c7405ba9e23de2e5fe1b
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / renderer-impl.h
1 #ifndef DALI_INTERNAL_RENDERER_H
2 #define DALI_INTERNAL_RENDERER_H
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/renderer.h> // Dali::Renderer
23 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
24 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
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/effects/material-impl.h> // Dali::Internal::Material
29 #include <dali/internal/event/geometry/geometry-impl.h> // Dali::Internal::Geometry
30
31 namespace Dali
32 {
33 namespace Internal
34 {
35 namespace SceneGraph
36 {
37 class RendererAttachment;
38 }
39
40 class Renderer;
41 typedef IntrusivePtr<Renderer> RendererPtr;
42
43 /**
44  * Renderer is an object that can be used to show content by combining a Geometry with a material.
45  */
46 class Renderer : public Object, public Connectable
47 {
48 public:
49
50   /**
51    * Create a new Renderer.
52    * @return A smart-pointer to the newly allocated Renderer.
53    */
54   static RendererPtr New();
55
56   /**
57    * @copydoc Dali::Renderer::SetGeometry()
58    */
59   void SetGeometry( Geometry& geometry );
60
61   /**
62    * @copydoc Dali::Renderer::SetMaterial()
63    */
64   void SetMaterial( Material& material );
65
66   /**
67    * @copydoc Dali::Renderer::SetDepthIndex()
68    */
69   void SetDepthIndex( int depthIndex );
70
71   /**
72    * @brief Get the scene graph object ( the node attachment )
73    *
74    * @return the scene object
75    */
76   SceneGraph::RendererAttachment* GetRendererSceneObject();
77
78 public: // Default property extensions from Object
79
80   /**
81    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
82    */
83   virtual unsigned int GetDefaultPropertyCount() const;
84
85   /**
86    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
87    */
88   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
89
90   /**
91    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
92    */
93   virtual const char* GetDefaultPropertyName(Property::Index index) const;
94
95   /**
96    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
97    */
98   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
99
100   /**
101    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
102    */
103   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
104
105   /**
106    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
107    */
108   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
109
110   /**
111    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
112    */
113   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
114
115   /**
116    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
117    */
118   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
119
120   /**
121    * @copydoc Dali::Internal::Object::SetDefaultProperty()
122    */
123   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
124
125   /**
126    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
127    */
128   virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
129
130   /**
131    * @copydoc Dali::Internal::Object::GetDefaultProperty()
132    */
133   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
134
135   /**
136    * @copydoc Dali::Internal::Object::GetPropertyOwner()
137    */
138   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
139
140   /**
141    * @copydoc Dali::Internal::Object::GetSceneObject()
142    */
143   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
144
145   /**
146    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
147    */
148   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
149
150   /**
151    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
152    */
153   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
154
155   /**
156    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
157    */
158   virtual int GetPropertyComponentIndex( Property::Index index ) const;
159
160 public: // Functions from Connectable
161   /**
162    * @copydoc Dali::Internal::Connectable::OnStage()
163    */
164   virtual bool OnStage() const;
165
166   /**
167    * @copydoc Dali::Internal::Connectable::Connect()
168    */
169   virtual void Connect();
170
171   /**
172    * @copydoc Dali::Internal::Connectable::Disconnect()
173    */
174   virtual void Disconnect();
175
176 private: // implementation
177   Renderer();
178
179   void Initialize();
180
181 private: // unimplemented methods
182   Renderer( const Renderer& );
183   Renderer& operator=( const Renderer& );
184
185 private: // data
186   SceneGraph::RendererAttachment* mSceneObject;
187   ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
188   ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
189   bool mOnStage;
190 };
191
192 } // namespace Internal
193
194 // Helpers for public-api forwarding methods
195 inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
196 {
197   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
198
199   BaseObject& object = handle.GetBaseObject();
200
201   return static_cast<Internal::Renderer&>(object);
202 }
203
204 inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
205 {
206   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
207
208   const BaseObject& object = handle.GetBaseObject();
209
210   return static_cast<const Internal::Renderer&>(object);
211 }
212
213 } // namespace Dali
214
215 #endif // DALI_INTERNAL_RENDERER_H