[dali_1.4.23] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / geometry.h
1 #ifndef DALI_GEOMETRY_H
2 #define DALI_GEOMETRY_H
3
4 /*
5  * Copyright (c) 2018 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 <cstddef> // std::size_t
23 #include <cstdint> // uint16_t
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/object/handle.h> // Dali::Handle
27 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
28 #include <dali/public-api/rendering/property-buffer.h> // Dali::PropertyBuffer
29
30 namespace Dali
31 {
32 /**
33  * @addtogroup dali_core_rendering_effects
34  * @{
35  */
36
37 namespace Internal DALI_INTERNAL
38 {
39 class Geometry;
40 }
41
42 /**
43  * @brief Geometry is handle to an object that can be used to define a geometric elements.
44  *
45  * @SINCE_1_1.43
46  */
47 class DALI_CORE_API Geometry : public BaseHandle
48 {
49 public:
50
51   /**
52    * @brief Enumeration for the description of the type of geometry, used to determine how the coordinates will be used.
53    * @SINCE_1_1.45
54    */
55   enum Type
56   {
57     POINTS,        ///< Individual points                                                                                          @SINCE_1_1.45
58     LINES,         ///< Individual lines (made of 2 points each)                                                                   @SINCE_1_1.45
59     LINE_LOOP,     ///< A strip of lines (made of 1 point each) which also joins the first and last point                          @SINCE_1_1.45
60     LINE_STRIP,    ///< A strip of lines (made of 1 point each)                                                                    @SINCE_1_1.45
61     TRIANGLES,     ///< Individual triangles (made of 3 points each)                                                               @SINCE_1_1.45
62     TRIANGLE_FAN,  ///< A fan of triangles around a centre point (after the first triangle, following triangles need only 1 point) @SINCE_1_1.45
63     TRIANGLE_STRIP ///< A strip of triangles (after the first triangle, following triangles need only 1 point)                     @SINCE_1_1.45
64   };
65
66
67   /**
68    * @brief Creates a new Geometry object.
69    *
70    * @SINCE_1_1.43
71    * @return A handle to a newly allocated Geometry object
72    */
73   static Geometry New();
74
75   /**
76    * @brief Default constructor, creates an empty handle.
77    *
78    * @SINCE_1_1.43
79    */
80   Geometry();
81
82   /**
83    * @brief Destructor.
84    *
85    * @SINCE_1_1.43
86    */
87   ~Geometry();
88
89   /**
90    * @brief Copy constructor, creates a new handle to the same object.
91    *
92    * @SINCE_1_1.43
93    * @param[in] handle Handle to an object
94    */
95   Geometry( const Geometry& handle );
96
97   /**
98    * @brief Downcasts to a geometry.
99    * If not, the returned handle is left uninitialized.
100    *
101    * @SINCE_1_1.43
102    * @param[in] handle Handle to an object
103    * @return Geometry handle or an uninitialized handle
104    */
105   static Geometry DownCast( BaseHandle handle );
106
107   /**
108    * @brief Assignment operator, changes this handle to point at the same object.
109    *
110    * @SINCE_1_1.43
111    * @param[in] handle Handle to an object
112    * @return Reference to the assigned object
113    */
114   Geometry& operator=( const Geometry& handle );
115
116   /**
117    * @brief Adds a PropertyBuffer to be used as source of geometry vertices.
118    *
119    * @SINCE_1_1.43
120    * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
121    * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
122    *         this buffer if no longer required
123    */
124   std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
125
126   /**
127    * @brief Retrieves the number of vertex buffers that have been added to this geometry.
128    *
129    * @SINCE_1_1.43
130    * @return Number of vertex buffers that have been added to this geometry
131    */
132   std::size_t GetNumberOfVertexBuffers() const;
133
134   /**
135    * @brief Removes a vertex buffer.
136    * The index must be between 0 and GetNumberOfVertexBuffers().
137    *
138    * @SINCE_1_1.43
139    * @param[in] index Index to the vertex buffer to remove
140    */
141   void RemoveVertexBuffer( std::size_t index );
142
143   /**
144    * @brief Sets a the index data to be used as a source of indices for the geometry
145    * Setting this buffer will cause the geometry to be rendered using indices.
146    * To unset call SetIndexBuffer with a null pointer or count 0.
147    *
148    * @SINCE_1_1.43
149    * @param[in] indices Array of indices
150    * @param[in] count Number of indices in the array
151    */
152   void SetIndexBuffer( const uint16_t* indices, size_t count );
153
154   /**
155    * @brief Sets the type of primitives this geometry contains.
156    *
157    * @SINCE_1_1.43
158    * @param[in] geometryType Type of primitives this geometry contains
159    */
160   void SetType( Type geometryType );
161
162   /**
163    * @brief Gets the type of primitives this geometry contains.
164    * Calling this function sets the property GEOMETRY_TYPE.
165    *
166    * @SINCE_1_1.43
167    * @return Type of primitives this geometry contains
168    */
169   Type GetType() const;
170
171 public:
172
173   /**
174    * @brief The constructor.
175    * @note  Not intended for application developers.
176    * @SINCE_1_1.43
177    * @param[in] pointer A pointer to a newly allocated Geometry
178    */
179   explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
180 };
181
182 /**
183  * @}
184  */
185 } //namespace Dali
186
187 #endif // DALI_GEOMETRY_H