mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 16:21:41 +00:00
Always default to Accelerated (OpenGL) rendering and fallback if required
When falling back the GAL, let's not update the user preference and instead just keep track of the failure that happened this session. Fixes https://gitlab.com/kicad/code/kicad/-/issues/11720
This commit is contained in:
parent
f5c5b00e40
commit
1eef438a96
@ -78,6 +78,7 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
|
||||
EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
bool EDA_DRAW_FRAME::m_openGLFailureOccured = false;
|
||||
|
||||
EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
||||
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
||||
@ -92,7 +93,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
m_gridSelectBox = nullptr;
|
||||
m_zoomSelectBox = nullptr;
|
||||
m_searchPane = nullptr;
|
||||
m_firstRunDialogSetting = 0;
|
||||
m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
||||
|
||||
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||
@ -319,14 +319,21 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
||||
m_galDisplayOptions.ReadCommonConfig( *settings, this );
|
||||
|
||||
#ifndef __WXMAC__
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
|
||||
resolveCanvasType();
|
||||
|
||||
if( cfg )
|
||||
canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
|
||||
if( m_canvasType != GetCanvas()->GetBackend() )
|
||||
{
|
||||
// Try to switch (will automatically fallback if necessary)
|
||||
GetCanvas()->SwitchBackend( m_canvasType );
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE newGAL = GetCanvas()->GetBackend();
|
||||
bool success = newGAL == m_canvasType;
|
||||
|
||||
if( canvasType != GetCanvas()->GetBackend() )
|
||||
GetCanvas()->SwitchBackend( canvasType );
|
||||
if( !success )
|
||||
{
|
||||
m_canvasType = newGAL;
|
||||
m_openGLFailureOccured = true; // Store failure for other EDA_DRAW_FRAMEs
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Notify all tools the preferences have changed
|
||||
@ -666,7 +673,6 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
|
||||
|
||||
m_undoRedoCountMax = aCfg->m_System.max_undo_items;
|
||||
m_firstRunDialogSetting = aCfg->m_System.first_run_shown;
|
||||
|
||||
m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
|
||||
|
||||
@ -692,7 +698,6 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
|
||||
|
||||
aCfg->m_System.units = static_cast<int>( GetUserUnits() );
|
||||
aCfg->m_System.first_run_shown = m_firstRunDialogSetting;
|
||||
aCfg->m_System.max_undo_items = GetMaxUndoItems();
|
||||
|
||||
m_galDisplayOptions.WriteConfig( *window );
|
||||
@ -1192,27 +1197,11 @@ void EDA_DRAW_FRAME::resolveCanvasType()
|
||||
{
|
||||
m_canvasType = loadCanvasTypeSetting();
|
||||
|
||||
// Nudge user to switch to OpenGL if they are on legacy or Cairo
|
||||
if( m_firstRunDialogSetting < 1 )
|
||||
{
|
||||
if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
|
||||
{
|
||||
// Save Cairo as default in case OpenGL crashes
|
||||
saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
|
||||
// If we had an OpenGL failure this session, use the fallback GAL but don't update the
|
||||
// user preference silently:
|
||||
|
||||
// Switch to OpenGL, which will save the new setting if successful
|
||||
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
|
||||
|
||||
// Switch back to Cairo if OpenGL is not supported
|
||||
if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
|
||||
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
|
||||
|
||||
HardRedraw();
|
||||
}
|
||||
|
||||
m_firstRunDialogSetting = 1;
|
||||
SaveSettings( config() );
|
||||
}
|
||||
if( m_openGLFailureOccured && m_canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
|
||||
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||
m_appSettingsSchemaVersion( aSchemaVersion )
|
||||
{
|
||||
// Make Coverity happy:
|
||||
m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
|
||||
m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
|
||||
|
||||
// Build parameters list:
|
||||
m_params.emplace_back(
|
||||
@ -68,7 +68,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||
&m_FindReplace.replace_history, {} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
|
||||
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) );
|
||||
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<float>( "graphics.highlight_factor",
|
||||
&m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
|
||||
@ -130,7 +130,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||
&m_Printing.layers, {} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
|
||||
&m_System.first_run_shown, false ) );
|
||||
&m_System.first_run_shown, false ) ); //@todo RFB remove? - not used
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "system.max_undo_items",
|
||||
&m_System.max_undo_items, 0 ) );
|
||||
|
@ -499,7 +499,6 @@ protected:
|
||||
bool m_polarCoords; // For those frames that support polar coordinates
|
||||
|
||||
bool m_showBorderAndTitleBlock; // Show the drawing sheet (border & title block).
|
||||
long m_firstRunDialogSetting; // Show first run dialog on startup
|
||||
|
||||
wxChoice* m_gridSelectBox;
|
||||
wxChoice* m_zoomSelectBox;
|
||||
@ -522,6 +521,9 @@ protected:
|
||||
///< The current canvas type.
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType;
|
||||
|
||||
static bool m_openGLFailureOccured; ///< Has any failure occured when switching to OpenGL in
|
||||
///< any EDA_DRAW_FRAME?
|
||||
|
||||
private:
|
||||
BASE_SCREEN* m_currentScreen; ///< current used SCREEN
|
||||
EDA_DRAW_PANEL_GAL* m_canvas;
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
|
||||
struct SYSTEM
|
||||
{
|
||||
bool first_run_shown;
|
||||
bool first_run_shown; //@todo RFB remove? - not used
|
||||
int max_undo_items;
|
||||
std::vector<wxString> file_history;
|
||||
int units;
|
||||
|
Loading…
Reference in New Issue
Block a user