MCPcopy Create free account
hub / github.com/TankOs/SFGUI / SortPrimitives

Method SortPrimitives

src/SFGUI/Renderer.cpp:745–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743/// @endcond
744
745void Renderer::SortPrimitives() {
746 if( m_primitives_sorted ) {
747 return;
748 }
749
750 std::size_t current_position = 1;
751 std::size_t sort_index;
752
753 auto primitives_size = m_primitives.size();
754
755 // Classic insertion sort.
756 while( current_position < primitives_size ) {
757 sort_index = current_position++;
758
759 while( ( sort_index > 0 ) && ( m_primitives[sort_index - 1]->GetLayer() * 1048576 + m_primitives[sort_index - 1]->GetLevel() > m_primitives[sort_index]->GetLayer() * 1048576 + m_primitives[sort_index]->GetLevel() ) ) {
760 m_primitives[sort_index].swap( m_primitives[sort_index - 1] );
761 --sort_index;
762 }
763 }
764
765 m_primitives_sorted = true;
766}
767
768void Renderer::AddPrimitive( Primitive::Ptr primitive ) {
769 m_primitives.push_back( primitive );

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
GetLayerMethod · 0.80
GetLevelMethod · 0.80

Tested by

no test coverage detected