Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-instruction-container.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/render/common/render-instruction-container.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/render/common/render-instruction.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace SceneGraph
31 {
32
33 RenderInstructionContainer::RenderInstructionContainer()
34 : mInstructions{}
35 {
36 }
37
38 RenderInstructionContainer::~RenderInstructionContainer() = default;
39
40 void RenderInstructionContainer::ResetAndReserve( BufferIndex bufferIndex, uint32_t capacityRequired )
41 {
42   // Only re-allocate if necessary.
43   if( mInstructions.size() < capacityRequired )
44   {
45     mInstructions.reserve( capacityRequired );
46   }
47
48   mInstructions.clear();
49 }
50
51 uint32_t RenderInstructionContainer::Count( BufferIndex bufferIndex )
52 {
53   return static_cast<uint32_t>( mInstructions.size() );
54 }
55
56 RenderInstruction& RenderInstructionContainer::At( BufferIndex bufferIndex, uint32_t index )
57 {
58   DALI_ASSERT_DEBUG( index < mInstructions.size() );
59
60   return *mInstructions[ index ];
61 }
62
63 void RenderInstructionContainer::PushBack( BufferIndex bufferIndex, RenderInstruction* renderInstruction )
64 {
65   mInstructions.push_back( renderInstruction );
66 }
67
68 void RenderInstructionContainer::DiscardCurrentInstruction( BufferIndex updateBufferIndex )
69 {
70   mInstructions.pop_back();
71 }
72
73 } // namespace SceneGraph
74
75 } // namespace Internal
76
77 } // namespace Dali