Merge "Path registration with type registry" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / geometry-impl.h
1 #ifndef DALI_INTERNAL_GEOMETRY_H
2 #define DALI_INTERNAL_GEOMETRY_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h> // std::vector
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
26 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
27 #include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
28 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
29 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
30 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
31 #include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
32
33 namespace Dali
34 {
35 namespace Internal
36 {
37 namespace SceneGraph
38 {
39 class Geometry;
40 }
41
42 class Geometry;
43 typedef IntrusivePtr<Geometry> GeometryPtr;
44
45 /**
46  * Geometry is an object that contains an array of structures of values that
47  * can be accessed as properties.
48  */
49 class Geometry : public Object, public Connectable
50 {
51 public:
52
53   /**
54    * Create a new Geometry.
55    * @return A smart-pointer to the newly allocated Geometry.
56    */
57   static GeometryPtr New();
58
59   /**
60    * @copydoc Dali::Geometry::AddVertexBuffer()
61    */
62   std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
63
64   /**
65    * @copydoc Dali::Geometry::GetNumberOfVertexBuffers()
66    */
67   std::size_t GetNumberOfVertexBuffers() const;
68
69   /**
70    * @copydoc Dali::Geometry::RemoveVertexBuffer()
71    */
72   void RemoveVertexBuffer( std::size_t index );
73
74   /**
75    * @copydoc Dali::Geometry::SetIndexBuffer()
76    */
77   void SetIndexBuffer( PropertyBuffer& indexBuffer );
78
79   /**
80    * @copydoc Dali::Geometry::SetGeometryType()
81    */
82   void SetGeometryType( Dali::Geometry::GeometryType geometryType );
83
84   /**
85    * @copydoc Dali::Geometry::GetGeometryType()
86    */
87   Dali::Geometry::GeometryType GetGeometryType() const;
88
89   /**
90    * @copydoc Dali::Geometry::SetRequiresDepthTesting()
91    */
92   void SetRequiresDepthTesting( bool requiresDepthTest );
93
94   /**
95    * @copydoc Dali::Geometry::GetRequiresDepthTesting()
96    */
97   bool GetRequiresDepthTesting() const;
98
99   /**
100    * @brief Get the geometry scene object
101    *
102    * @return the geometry scene object
103    */
104   const SceneGraph::Geometry* GetGeometrySceneObject() const;
105
106 public: // Default property extensions from Object
107
108   /**
109    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
110    */
111   virtual unsigned int GetDefaultPropertyCount() const;
112
113   /**
114    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
115    */
116   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
117
118   /**
119    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
120    */
121   virtual const char* GetDefaultPropertyName(Property::Index index) const;
122
123   /**
124    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
125    */
126   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
127
128   /**
129    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
130    */
131   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
132
133   /**
134    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
135    */
136   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
137
138   /**
139    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
140    */
141   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
142
143   /**
144    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
145    */
146   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
147
148   /**
149    * @copydoc Dali::Internal::Object::SetDefaultProperty()
150    */
151   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
152
153   /**
154    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
155    */
156   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
157
158   /**
159    * @copydoc Dali::Internal::Object::GetDefaultProperty()
160    */
161   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
162
163   /**
164    * @copydoc Dali::Internal::Object::GetPropertyOwner()
165    */
166   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
167
168   /**
169    * @copydoc Dali::Internal::Object::GetSceneObject()
170    */
171   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
172
173   /**
174    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
175    */
176   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
177
178   /**
179    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
180    */
181   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
182
183 public: // Functions from Connectable
184   /**
185    * @copydoc Dali::Internal::Connectable::OnStage()
186    */
187   virtual bool OnStage() const;
188
189   /**
190    * @copydoc Dali::Internal::Connectable::Connect()
191    */
192   virtual void Connect();
193
194   /**
195    * @copydoc Dali::Internal::Connectable::Disconnect()
196    */
197   virtual void Disconnect();
198
199 private: // implementation
200   Geometry();
201
202   /**
203    * Second stage initialization of the Geometry
204    */
205   void Initialize();
206
207 protected:
208   /**
209    * A reference counted object may only be deleted by calling Unreference()
210    */
211   virtual ~Geometry();
212
213 private: // unimplemented methods
214   Geometry( const Geometry& );
215   Geometry& operator=( const Geometry& );
216
217 private: // data
218
219   SceneGraph::Geometry* mSceneObject;
220
221   std::vector<PropertyBufferPtr> mVertexBuffers; ///< Vector of intrusive pointers to vertex buffers
222   PropertyBufferPtr              mIndexBuffer;   ///< Intrusive pointer to index buffer
223
224   Dali::Geometry::GeometryType mGeometryType;      ///< Geometry type (cached)
225   bool                         mRequiresDepthTest; ///< Establish if geometry requires depth testing (cached)
226
227   bool mOnStage;
228 };
229
230 } // namespace Internal
231
232 // Helpers for public-api forwarding methods
233 inline Internal::Geometry& GetImplementation(Dali::Geometry& handle)
234 {
235   DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
236
237   BaseObject& object = handle.GetBaseObject();
238
239   return static_cast<Internal::Geometry&>(object);
240 }
241
242 inline const Internal::Geometry& GetImplementation(const Dali::Geometry& handle)
243 {
244   DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
245
246   const BaseObject& object = handle.GetBaseObject();
247
248   return static_cast<const Internal::Geometry&>(object);
249 }
250
251 } // namespace Dali
252
253 #endif // DALI_INTERNAL_GEOMETRY_H