diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp index 6206b12c21..31b0a16e4e 100644 --- a/gerbview/gerbview_draw_panel_gal.cpp +++ b/gerbview/gerbview_draw_panel_gal.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -28,6 +28,9 @@ #include #include +#include +#include + #include using namespace std::placeholders; @@ -116,6 +119,32 @@ void GERBVIEW_DRAW_PANEL_GAL::OnShow() bool GERBVIEW_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) { bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType ); + + // The next onPaint event will call m_view->UpdateItems() that is very time consumming + // after switching to opengl. Clearing m_view and rebuild it is much faster + if( aGalType == GAL_TYPE_OPENGL ) + { + GERBVIEW_FRAME* frame = dynamic_cast( GetParent() ); + + if( frame ) + { + m_view->Clear(); + + for( int layer = GERBER_DRAWLAYERS_COUNT-1; layer>= 0; --layer ) + { + GERBER_FILE_IMAGE* gerber = frame->GetImagesList()->GetGbrImage( layer ); + + if( gerber == NULL ) // Graphic layer not yet used + continue; + + for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() ) + { + m_view->Add (item ); + } + } + } + } + setDefaultLayerDeps(); GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ ); diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 20dbd6c57f..24f7d719db 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -264,6 +264,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) m_gal->DrawPolyline( absolutePolygon.COutline( 0 ) ); else m_gal->DrawPolygon( absolutePolygon ); + break; }