Discard render instruction if it is empty
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-instruction-container.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_CONTAINER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_CONTAINER_H__
3
4 /*
5  * Copyright (c) 2014 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/devel-api/common/owner-container.h>
23 #include <dali/internal/common/buffer-index.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace SceneGraph
32 {
33 class RenderInstruction;
34
35 /**
36  * Class to encapsulate double buffered render instruction data
37  */
38 class RenderInstructionContainer
39 {
40 public:
41
42   /**
43    * Constructor
44    */
45   RenderInstructionContainer();
46
47   /**
48    * Destructor
49    */
50   ~RenderInstructionContainer();
51
52   /**
53    * Reset the container index and reserve space in the container if needed
54    * @param bufferIndex to reset
55    * @param capacityRequired in the container
56    */
57   void ResetAndReserve( BufferIndex bufferIndex, size_t capacityRequired );
58
59   /**
60    * Return the count of instructions in the container
61    * @param bufferIndex to use
62    * @return the count of elements
63    */
64   size_t Count( BufferIndex bufferIndex );
65
66   /**
67    * Get a reference to the next instruction
68    * @param bufferIndex to use
69    */
70   RenderInstruction& GetNextInstruction( BufferIndex bufferIndex );
71
72   /**
73    * Get a reference to the instruction at index
74    * @param bufferIndex to use
75    * @param index to use
76    */
77   RenderInstruction& At( BufferIndex bufferIndex, size_t index );
78
79   /**
80    * Discard the current container index
81    * @param bufferIndex to reset
82    */
83   void DiscardCurrentInstruction( BufferIndex bufferIndex );
84
85 private:
86
87   unsigned int mIndex[ 2 ]; ///< count of the elements that have been added
88   typedef OwnerContainer< RenderInstruction* > InstructionContainer;
89   InstructionContainer mInstructions[ 2 ]; /// Double buffered instruction lists
90
91 };
92
93 } // namespace SceneGraph
94
95 } // namespace Internal
96
97 } // namespace Dali
98
99 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_CONTAINER_H__