e33b31dbf504cc2f6160e840967942d4278d0f6b
[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 public: // Default property extensions from Object
72
73   /**
74    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
75    */
76   virtual unsigned int GetDefaultPropertyCount() const;
77
78   /**
79    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
80    */
81   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
82
83   /**
84    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
85    */
86   virtual const char* GetDefaultPropertyName(Property::Index index) const;
87
88   /**
89    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
90    */
91   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
92
93   /**
94    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
95    */
96   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
97
98   /**
99    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
100    */
101   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
102
103   /**
104    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
105    */
106   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
107
108   /**
109    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
110    */
111   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
112
113   /**
114    * @copydoc Dali::Internal::Object::SetDefaultProperty()
115    */
116   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
117
118   /**
119    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
120    */
121   virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
122
123   /**
124    * @copydoc Dali::Internal::Object::GetDefaultProperty()
125    */
126   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
127
128   /**
129    * @copydoc Dali::Internal::Object::GetPropertyOwner()
130    */
131   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
132
133   /**
134    * @copydoc Dali::Internal::Object::GetSceneObject()
135    */
136   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
137
138   /**
139    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
140    */
141   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
142
143   /**
144    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
145    */
146   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
147
148   /**
149    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
150    */
151   virtual int GetPropertyComponentIndex( Property::Index index ) const;
152
153 public: // Functions from Connectable
154   /**
155    * @copydoc Dali::Internal::Connectable::OnStage()
156    */
157   virtual bool OnStage() const;
158
159   /**
160    * @copydoc Dali::Internal::Connectable::Connect()
161    */
162   virtual void Connect();
163
164   /**
165    * @copydoc Dali::Internal::Connectable::Disconnect()
166    */
167   virtual void Disconnect();
168
169 private: // implementation
170   Renderer();
171
172 private: // unimplemented methods
173   Renderer( const Renderer& );
174   Renderer& operator=( const Renderer& );
175
176 private: // data
177   SceneGraph::RendererAttachment* mSceneObject;
178   ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
179   ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
180
181 };
182
183 } // namespace Internal
184
185 // Helpers for public-api forwarding methods
186 inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
187 {
188   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
189
190   BaseObject& object = handle.GetBaseObject();
191
192   return static_cast<Internal::Renderer&>(object);
193 }
194
195 inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
196 {
197   DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
198
199   const BaseObject& object = handle.GetBaseObject();
200
201   return static_cast<const Internal::Renderer&>(object);
202 }
203
204 } // namespace Dali
205
206 #endif // DALI_INTERNAL_RENDERER_H