069ac85e2c7aca57ec5d7e4f04217e5d5b0788af
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / geometry-batcher.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_BATCHER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_BATCHER_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 // INTERNAL INCLUDES
22 #include <dali/internal/render/renderers/render-property-buffer.h>
23 #include <dali/internal/update/rendering/scene-graph-texture-set.h>
24 #include <dali/internal/render/common/render-list.h>
25
26 // PUBLIC INCLUDES
27 #include <dali/public-api/common/dali-vector.h>
28
29 /// Value used by a node to indicate the batch index as null or invalid
30 #define BATCH_NULL_HANDLE 0xFFFFFFFF
31
32 namespace Dali
33 {
34
35 namespace Internal
36 {
37
38 namespace Render
39 {
40 class Geometry;
41 }
42
43 namespace SceneGraph
44 {
45 struct BatchInfo;
46 struct BatchStreamMarker;
47
48 class Node;
49 class RenderInstructionContainer;
50
51 class GeometryBatcher
52 {
53
54 public:
55
56   /**
57    * The constructor of GeometryBatcher
58    */
59   GeometryBatcher();
60
61   /**
62    * The destructor of GeometryBatcher
63    */
64   ~GeometryBatcher();
65
66   /**
67    * Assigns the update manager object
68    * @param[in] updateManager Pointer to instance of update manager
69    */
70   void SetUpdateManager( UpdateManager* updateManager );
71
72   /**
73    * Updates all batches
74    * @param[in] index Update buffer index
75    */
76   void Update( BufferIndex index );
77
78   /**
79    * @brief Add node to batch parents list
80    * @param[in] node instance of a node to be added
81    */
82   void AddBatchParent( Node* node );
83
84   /**
85    * @brief Remove node from list of batch parents
86    * @param[in] node valid instance of node to be removed
87    */
88   void RemoveBatchParent( Node* node );
89
90   /**
91    * @brief Add batchable node
92    * @param[in] node valid instance of the node to be added
93    */
94   void AddNode( Node* node );
95
96   /**
97    * @brief Remove batchable node
98    * @param[in] node valid instance of the node to be removed
99    */
100   void RemoveNode( Node* node );
101
102   /**
103    * @brief Return the geometry object associated with specified batch index
104    * @param[in] batchIndex VALID index of the batch
105    * @return instance of the batched geometry
106    */
107   Render::Geometry* GetGeometry( uint32_t batchIndex );
108
109   /**
110    * @brief Query if a batch at given index has been already rendered
111    * @param batchIndex VALID index of a batch to query
112    * @return true if batch has rendered, false otherwise
113    */
114   bool HasRendered( uint32_t batchIndex );
115
116   /**
117    * @brief Sets a batch at given index as rendered
118    * @param batchIndex VALID index of a batch
119    */
120   void SetRendered( uint32_t batchIndex );
121
122 private:
123
124   GeometryBatcher( const GeometryBatcher& ); ///< Undefined
125   GeometryBatcher& operator=( const GeometryBatcher& ); ///< Undefined
126
127   /**
128    * @brief Clones vertex format of source geometry and stores generated data in the batchInfo object
129    * @param[in] sourceGeometry Geometry of the very first batched item
130    * @param[out] batchInfo Batch info object used to store cloned vertex format
131    * @return true on success, false otherwise
132    */
133   bool CloneVertexFormat( const Render::Geometry* sourceGeometry, struct VertexDescriptor& batchInfo );
134
135 private:
136
137   struct Impl* mImpl; ///< Pointer to an instance of geometry batcher implementation
138
139 };
140
141 } // SceneGraph
142
143 } // Internal
144
145 } // Dali
146
147
148 #endif //DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_BATCHER_H
149