kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #34331
[PATCH] Don't use the RTREE in UpdateAllLayersOrder() / UpdateAllLayersColor()
This patch uses simple iteration instead of the RTREE search to update the
layer order and color in VIEW. On my Linux system, this results in a ~50%
speedup in release build (less in debug build) and is most noticeable when
switching layers in GerbView with large Gerber files loaded (i.e. high
number of items in the view).
-Jon
From a7bda21efef9ca6eee250ea3ce420d058b3cf354 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Sun, 25 Feb 2018 15:38:05 -0500
Subject: [PATCH] Don't use the RTREE in UpdateAllLayersOrder() /
UpdateAllLayersColor()
Since we are going to inspect every item for these calls, we don't
need to use the RTREE search, which is expensive with high item count.
This results in ~50% improvement in layer switching time in GerbView
when working with a set of large Gerber files.
---
common/view/view.cpp | 46 ++++++++++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/common/view/view.cpp b/common/view/view.cpp
index 9b7a48cfc..0b82766ce 100644
--- a/common/view/view.cpp
+++ b/common/view/view.cpp
@@ -671,21 +671,26 @@ void VIEW::UpdateLayerColor( int aLayer )
void VIEW::UpdateAllLayersColor()
{
- BOX2I r;
-
- r.SetMaximum();
m_gal->BeginUpdate();
- for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
+ for( VIEW_ITEM* item : m_allItems )
{
- VIEW_LAYER* l = &( ( *i ).second );
+ auto viewData = item->viewPrivData();
- // There is no point in updating non-cached layers
- if( !IsCached( l->id ) )
+ if( !viewData )
continue;
- updateItemsColor visitor( l->id, m_painter, m_gal );
- l->items->Query( r, visitor );
+ int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
+ viewData->getLayers( layers, layers_count );
+
+ for( int i = 0; i < layers_count; ++i )
+ {
+ const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
+ int group = viewData->getGroup( layers[i] );
+
+ if( group >= 0 )
+ m_gal->ChangeGroupColor( group, color );
+ }
}
m_gal->EndUpdate();
@@ -793,17 +798,26 @@ void VIEW::ClearTopLayers()
void VIEW::UpdateAllLayersOrder()
{
- BOX2I r;
- r.SetMaximum();
-
sortLayers();
m_gal->BeginUpdate();
- for( LAYER_MAP::value_type& l : m_layers )
+ for( VIEW_ITEM* item : m_allItems )
{
- int layer = l.first;
- changeItemsDepth visitor( layer, l.second.renderingOrder, m_gal );
- m_layers[layer].items->Query( r, visitor );
+ auto viewData = item->viewPrivData();
+
+ if( !viewData )
+ continue;
+
+ int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
+ viewData->getLayers( layers, layers_count );
+
+ for( int i = 0; i < layers_count; ++i )
+ {
+ int group = viewData->getGroup( layers[i] );
+
+ if( group >= 0 )
+ m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
+ }
}
m_gal->EndUpdate();
--
2.14.1
Follow ups