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