Merge branch 'devel/master (1.1.16)' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / 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/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
30
31 namespace Dali
32 {
33 namespace Internal
34 {
35 namespace SceneGraph
36 {
37 class Renderer;
38 }
39
40
41 class Renderer;
42 typedef IntrusivePtr<Renderer> RendererPtr;
43
44 /**
45  * Renderer is an object that can be used to show content by combining a Geometry with a material.
46  */
47 class Renderer : public Object
48 {
49 public:
50
51   /**
52    * Create a new Renderer.
53    * @return A smart-pointer to the newly allocated Renderer.
54    */
55   static RendererPtr New();
56
57   /**
58    * @copydoc Dali::Renderer::SetGeometry()
59    */
60   void SetGeometry( Geometry& geometry );
61
62   /**
63    * @copydoc Dali::Renderer::GetGeometry()
64    */
65   Geometry* GetGeometry() const;
66
67   /**
68    * @copydoc Dali::Renderer::SetMaterial()
69    */
70   void SetMaterial( Material& material );
71
72   /**
73    * @copydoc Dali::Renderer::GetMaterial()
74    */
75   Material* GetMaterial() const;
76
77   /**
78    * @copydoc Dali::Renderer::SetDepthIndex()
79    */
80   void SetDepthIndex( int depthIndex );
81
82   /**
83    * @copydoc Dali::Renderer::GetDepthIndex()
84    */
85   int GetDepthIndex() const;
86
87   /**
88    * @brief Get the scene graph object ( the node attachment )
89    *
90    * @return the scene object
91    */
92   SceneGraph::Renderer* GetRendererSceneObject();
93
94 public: // Default property extensions from Object
95
96   /**
97    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
98    */
99   virtual unsigned int GetDefaultPropertyCount() const;
100
101   /**
102    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
103    */
104   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
105
106   /**
107    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
108    */
109   virtual const char* GetDefaultPropertyName(Property::Index index) const;
110
111   /**
112    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
113    */
114   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
115
116   /**
117    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
118    */
119   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
120
121   /**
122    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
123    */
124   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
125
126   /**
127    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
128    */
129   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
130
131   /**
132    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
133    */
134   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
135
136   /**
137    * @copydoc Dali::Internal::Object::SetDefaultProperty()
138    */
139   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
140
141   /**
142    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
143    */
144   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
145
146   /**
147    * @copydoc Dali::Internal::Object::GetDefaultProperty()
148    */
149   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
150
151   /**
152    * @copydoc Dali::Internal::Object::GetPropertyOwner()
153    */
154   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
155
156   /**
157    * @copydoc Dali::Internal::Object::GetSceneObject()
158    */
159   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
160
161   /**
162    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
163    */
164   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
165
166   /**
167    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
168    */
169   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
170
171   /**
172    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
173    */
174   virtual int GetPropertyComponentIndex( Property::Index index ) const;
175
176 public: // Functions from Connectable
177   /**
178    * @copydoc Dali::Internal::Connectable::OnStage()
179    */
180   virtual bool OnStage() const;
181
182   /**
183    * @copydoc Dali::Internal::Connectable::Connect()
184    */
185   virtual void Connect();
186
187   /**
188    * @copydoc Dali::Internal::Connectable::Disconnect()
189    */
190   virtual void Disconnect();
191
192 private: // implementation
193   Renderer();
194
195   void Initialize();
196
197 protected:
198   /**
199    * A reference counted object may only be deleted by calling Unreference()
200    */
201   virtual ~Renderer();
202
203 private: // unimplemented methods
204   Renderer( const Renderer& );
205   Renderer& operator=( const Renderer& );
206
207 private: // data
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
211   int mDepthIndex;
212   int mOnStageCount;
213 };
214
215 } // namespace Internal
216
217 // Helpers for public-api forwarding methods
218 inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
219 {
220   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
221
222   BaseObject& object = handle.GetBaseObject();
223
224   return static_cast<Internal::Renderer&>(object);
225 }
226
227 inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
228 {
229   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
230
231   const BaseObject& object = handle.GetBaseObject();
232
233   return static_cast<const Internal::Renderer&>(object);
234 }
235
236 } // namespace Dali
237
238 #endif // DALI_INTERNAL_RENDERER_H