From 9383987b1ce8ec61bcb240d2836d121e56ff1504 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 24 Sep 2017 21:22:23 -0400 Subject: [PATCH] Skip calling RTREE::Remove() when adding items to a VIEW --- common/view/view.cpp | 23 ++++++++++++++++------- include/view/view_item.h | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 80536ce1a7..af2633e3e2 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -335,7 +335,7 @@ void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority ) } SetVisible( aItem, true ); - Update( aItem, KIGFX::ALL ); + Update( aItem, KIGFX::INITIAL_ADD ); } @@ -827,7 +827,7 @@ struct VIEW::drawItem { wxASSERT( aItem->viewPrivData() ); - // Conditions that have te be fulfilled for an item to be drawn + // Conditions that have to be fulfilled for an item to be drawn bool drawCondition = aItem->viewPrivData()->isRenderable() && aItem->ViewGetLOD( layer, view ) < view->m_scale; if( !drawCondition ) @@ -1076,14 +1076,23 @@ void VIEW::clearGroupCache() void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) { - // updateLayers updates geometry too, so we do not have to update both of them at the same time - if( aUpdateFlags & LAYERS ) + if( aUpdateFlags & INITIAL_ADD ) { - updateLayers( aItem ); + // Don't update layers or bbox, since it was done in VIEW::Add() + // Now that we have initialized, set flags to ALL for the code below + aUpdateFlags = ALL; } - else if( aUpdateFlags & GEOMETRY ) + else { - updateBbox( aItem ); + // updateLayers updates geometry too, so we do not have to update both of them at the same time + if( aUpdateFlags & LAYERS ) + { + updateLayers( aItem ); + } + else if( aUpdateFlags & GEOMETRY ) + { + updateBbox( aItem ); + } } int layers[VIEW_MAX_LAYERS], layers_count; diff --git a/include/view/view_item.h b/include/view/view_item.h index bec8016bfe..6ce69434e2 100644 --- a/include/view/view_item.h +++ b/include/view/view_item.h @@ -56,7 +56,8 @@ enum VIEW_UPDATE_FLAGS { COLOR = 0x02, /// Color has changed GEOMETRY = 0x04, /// Position or shape has changed LAYERS = 0x08, /// Layers have changed - ALL = 0xff + INITIAL_ADD = 0x10, /// Item is being added to the view + ALL = 0xef /// All except INITIAL_ADD }; /**