X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fcommon%2Frender-instruction-container.cpp;h=4389f2f2a259aaf27517849bad8de97b5f630b6e;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=9b16af87ea1e2d941e886a7beb03d2fa6b11f9ef;hpb=caa6ad4e65d9483f1e09198d717e3d4b04724667;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/common/render-instruction-container.cpp b/dali/internal/render/common/render-instruction-container.cpp index 9b16af8..4389f2f 100644 --- a/dali/internal/render/common/render-instruction-container.cpp +++ b/dali/internal/render/common/render-instruction-container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,58 +31,45 @@ namespace SceneGraph { RenderInstructionContainer::RenderInstructionContainer() +: mInstructions{} { - // array initialisation in ctor initializer list not supported until C++ 11 - mIndex[ 0 ] = 0u; - mIndex[ 1 ] = 0u; } RenderInstructionContainer::~RenderInstructionContainer() { - // OwnerContainer deletes the instructions } -void RenderInstructionContainer::ResetAndReserve( BufferIndex bufferIndex, size_t capacityRequired ) +void RenderInstructionContainer::ResetAndReserve( BufferIndex bufferIndex, uint32_t capacityRequired ) { - mIndex[ bufferIndex ] = 0u; - size_t oldcapacity = mInstructions[ bufferIndex ].Capacity(); - if( oldcapacity < capacityRequired ) + // Only re-allocate if necessary. + if( mInstructions.size() < capacityRequired ) { - mInstructions[ bufferIndex ].Reserve( capacityRequired ); - // add N new elements - for( ; oldcapacity < capacityRequired; ++oldcapacity ) - { - mInstructions[ bufferIndex ].PushBack( new RenderInstruction ); - } + mInstructions.reserve( capacityRequired ); } - // Note that we may have spare elements in the list, we don't remove them as that would - // decrease the capacity of our container and lead to possibly reallocating, which we hate - // RenderInstruction holds a lot of data so we keep them and recycle instead of new & delete + + mInstructions.clear(); } -size_t RenderInstructionContainer::Count( BufferIndex bufferIndex ) +uint32_t RenderInstructionContainer::Count( BufferIndex bufferIndex ) { - // mIndex contains the number of instructions that have been really prepared and updated - // (from UpdateManager through GetNextInstruction) - return mIndex[ bufferIndex ]; + return static_cast( mInstructions.size() ); } -RenderInstruction& RenderInstructionContainer::GetNextInstruction( BufferIndex bufferIndex ) +RenderInstruction& RenderInstructionContainer::At( BufferIndex bufferIndex, uint32_t index ) { - // At protects against running out of space - return At( bufferIndex, mIndex[ bufferIndex ]++ ); + DALI_ASSERT_DEBUG( index < mInstructions.size() ); + + return *mInstructions[ index ]; } -RenderInstruction& RenderInstructionContainer::At( BufferIndex bufferIndex, size_t index ) +void RenderInstructionContainer::PushBack( BufferIndex bufferIndex, RenderInstruction* renderInstruction ) { - DALI_ASSERT_DEBUG( index < mInstructions[ bufferIndex ].Count() ); - - return *mInstructions[ bufferIndex ][ index ]; + mInstructions.push_back( renderInstruction ); } -void RenderInstructionContainer::DiscardCurrentInstruction( BufferIndex bufferIndex ) +void RenderInstructionContainer::DiscardCurrentInstruction( BufferIndex updateBufferIndex ) { - mIndex[ bufferIndex ]--; + mInstructions.pop_back(); } } // namespace SceneGraph