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