From 2697fc386437a343ff6d6b6ae9e2b50224eb8c31 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 31 Aug 2020 18:47:44 +0100 Subject: [PATCH] Remove canvas-switching from OSX. The Cairo renderer doesn't work on Retina displays. Fixes https://gitlab.com/kicad/code/kicad/issues/4788 --- common/draw_panel_gal.cpp | 35 +++++++++++++++------- common/eda_draw_frame.cpp | 16 +++++----- common/settings/app_settings.cpp | 10 ++----- common/tool/actions.cpp | 8 ----- common/tool/common_tools.cpp | 2 ++ cvpcb/display_footprints_frame.cpp | 9 ++---- eeschema/libedit/menubar_libedit.cpp | 2 ++ eeschema/menubar.cpp | 2 ++ eeschema/sch_base_frame.cpp | 2 +- eeschema/sch_draw_panel.cpp | 12 +++++--- eeschema/widgets/symbol_preview_widget.cpp | 6 ++-- gerbview/menubar.cpp | 2 ++ include/class_draw_panel_gal.h | 7 +++++ pagelayout_editor/pl_editor_frame.cpp | 7 +---- pcbnew/dialogs/dialog_pad_properties.cpp | 12 +++----- pcbnew/footprint_wizard_frame.cpp | 12 +++----- pcbnew/menubar_footprint_editor.cpp | 2 ++ pcbnew/menubar_pcb_editor.cpp | 2 ++ pcbnew/pcb_draw_panel_gal.cpp | 12 +++++--- pcbnew/pcb_edit_frame.cpp | 2 +- 20 files changed, 86 insertions(+), 76 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 86c64b060c..aead9860ba 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -233,13 +233,19 @@ void EDA_DRAW_PANEL_GAL::DoRePaint() } catch( std::runtime_error& err ) { - constexpr auto GAL_FALLBACK = GAL_TYPE_CAIRO; + if( GAL_FALLBACK != m_backend ) + { + SwitchBackend( GAL_FALLBACK ); - SwitchBackend( GAL_FALLBACK ); - - DisplayInfoMessage( m_parent, - _( "Could not use OpenGL, falling back to software rendering" ), - wxString( err.what() ) ); + DisplayInfoMessage( m_parent, + _( "Could not use OpenGL, falling back to software rendering" ), + wxString( err.what() ) ); + } + else + { + // We're well and truly banjaxed if we get here without a fallback. + DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), wxString( err.what() ) ); + } } #ifdef PROFILE @@ -398,10 +404,19 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) } else { - aGalType = GAL_TYPE_CAIRO; - DisplayInfoMessage( m_parent, - _( "Could not use OpenGL, falling back to software rendering" ), errormsg ); - new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this ); + if( GAL_FALLBACK != aGalType ) + { + aGalType = GAL_FALLBACK; + DisplayInfoMessage( m_parent, + _( "Could not use OpenGL, falling back to software rendering" ), + errormsg ); + new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this ); + } + else + { + // We're well and truly banjaxed if we get here without a fallback. + DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), errormsg ); + } } break; } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index b72a72eaf6..ca3285115f 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -651,6 +650,12 @@ void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() { +#ifdef __WXMAC__ + // Cairo renderer doesn't handle Retina displays so there's really only one game + // in town for Mac + return EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; +#endif + EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings(); @@ -667,14 +672,7 @@ EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() // Legacy canvas no longer supported. Switch to Cairo, and on the first instantiation // the user will be prompted to switch to OpenGL if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) - { -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif - } + canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; return canvasType; } diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 9d1d31b3ea..859820a9fe 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -45,7 +45,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV { // Make Coverity happy: m_LibTree.column_width = 360; - m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; + m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; // Build parameters list: m_params.emplace_back( new PARAM( "find_replace.flags", &m_FindReplace.flags, 1 ) ); @@ -62,14 +62,8 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV m_params.emplace_back( new PARAM_LIST( "find_replace.replace_history", &m_FindReplace.replace_history, {} ) ); -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays so default to OpenGL m_params.emplace_back( new PARAM( "graphics.canvas_type", - &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ); -#else - m_params.emplace_back( new PARAM( "graphics.canvas_type", - &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ); -#endif + &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) ); m_params.emplace_back( new PARAM( "graphics.highlight_factor", &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) ); diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 1527a818f2..c1a4158332 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -555,22 +555,14 @@ TOOL_ACTION ACTIONS::updateSchematicFromPcb( "common.Control.updateSchematicFrom TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics", AS_GLOBAL, -#ifdef __WXMAC__ - MD_ALT + WXK_F11, -#else WXK_F11, -#endif LEGACY_HK_NAME( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), _( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ), tools_xpm ); TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics", AS_GLOBAL, -#ifdef __WXMAC__ - MD_ALT + WXK_F12, -#else WXK_F12, -#endif LEGACY_HK_NAME( "Switch to Modern Toolset with software graphics (fall-back)" ), _( "Standard Graphics" ), _( "Use software graphics (fall-back)" ), tools_xpm ); diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 9ba321ae92..92ae667b25 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -522,8 +522,10 @@ int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent ) { if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) ) m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ); +#ifndef __WXMAC__ else if( aEvent.IsAction( &ACTIONS::standardGraphics ) ) m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); +#endif else wxFAIL_MSG( "Unknown canvas type" ); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 21c8dfa5e6..0558e4356c 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -78,14 +78,9 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); // Create GAL canvas before loading settings -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif auto* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), backend ); + GetGalDisplayOptions(), + EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); SetCanvas( gal_drawPanel ); // Don't show the default board solder mask clearance. Only the diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index edcf66ecb1..3e39867f88 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -160,9 +160,11 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); +#ifndef __WXMAC__ prefsMenu->AppendSeparator(); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif //-- Menubar ------------------------------------------------------------- diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 9be1fcb579..0bc5e9dadc 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -268,9 +268,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); +#ifndef __WXMAC__ prefsMenu->AppendSeparator(); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif //-- Menubar ------------------------------------------------------------- diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 7be87328a5..28c3fca321 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -304,7 +304,7 @@ void SCH_BASE_FRAME::createCanvas() // Allows only a CAIRO or OPENGL canvas: if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL - && m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) + && m_canvasType != EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) { m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; } diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index a607cc98fc..29a03b4821 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -192,12 +192,16 @@ void SCH_DRAW_PANEL::OnShow() } catch( const std::runtime_error& e ) { - // Fallback to software renderer DisplayInfoMessage( frame, e.what() ); - SwitchBackend( GAL_TYPE_CAIRO ); - if( frame ) - frame->ActivateGalCanvas(); + // Use fallback if one is available + if( GAL_FALLBACK != m_backend ) + { + SwitchBackend( GAL_FALLBACK ); + + if( frame ) + frame->ActivateGalCanvas(); + } } } diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 65ec96c792..c9130e22ff 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -48,9 +48,11 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = aCanvasType; // Allows only a CAIRO or OPENGL canvas: - if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL && - canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) + if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL + && canvasType != EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) + { canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; + } m_preview = new SCH_PREVIEW_PANEL( aParent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), m_galDisplayOptions, canvasType ); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 23e9693c76..7cab0278d6 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -239,9 +239,11 @@ void GERBVIEW_FRAME::ReCreateMenuBar() preferencesMenu->AppendSeparator(); AddMenuLanguageList( preferencesMenu, selTool ); +#ifndef __WXMAC__ preferencesMenu->AppendSeparator(); preferencesMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); preferencesMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif //-- Menubar ------------------------------------------------------------- diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index cfb5f4699e..725080aa4b 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -63,6 +63,13 @@ public: GAL_TYPE_LAST ///< Sentinel, do not use as a parameter }; +#ifdef __WXMAC__ + // Cairo doesn't work on OSX so we really have no fallback available. + static constexpr GAL_TYPE GAL_FALLBACK = GAL_TYPE_OPENGL; +#else + static constexpr GAL_TYPE GAL_FALLBACK = GAL_TYPE_CAIRO; +#endif + /** * Create a drawing panel that is contained inside \p aParentWindow. * diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 11e4308aa3..ef41f5451d 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -96,12 +96,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetIcon( icon ); // Create GAL canvas -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif + m_canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, GetGalDisplayOptions(), m_canvasType ); diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 2ccf045a42..3a7a6ba8e5 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -255,14 +255,10 @@ void DIALOG_PAD_PROPERTIES::enablePrimitivePage( bool aEnable ) void DIALOG_PAD_PROPERTIES::prepareCanvas() { // Initialize the canvas to display the pad -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif - m_padPreviewGAL = new PCB_DRAW_PANEL_GAL( m_boardViewPanel, -1, wxDefaultPosition, wxDefaultSize, - m_parent->GetGalDisplayOptions(), backend ); + m_padPreviewGAL = new PCB_DRAW_PANEL_GAL( m_boardViewPanel, -1, wxDefaultPosition, + wxDefaultSize, + m_parent->GetGalDisplayOptions(), + EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); m_padPreviewSizer->Add( m_padPreviewGAL, 12, wxEXPAND | wxALL, 5 ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 448bb2b3f4..23976bf84d 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -126,14 +126,10 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false ); // Create GAL canvas -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif - PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), backend ); + PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), + m_FrameSize, + GetGalDisplayOptions(), + EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); SetCanvas( gal_drawPanel ); PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions(); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index a5e1e548be..b243b2b6a5 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -235,9 +235,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); +#ifndef __WXMAC__ prefsMenu->AppendSeparator(); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif //--MenuBar ----------------------------------------------------------- // diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 24edede5c4..8a1f53fd1f 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -445,9 +445,11 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); +#ifndef __WXMAC__ prefsMenu->AppendSeparator(); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif //--MenuBar ----------------------------------------------------------- diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index dc7ab21da2..06e70eaf7f 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -424,12 +424,16 @@ void PCB_DRAW_PANEL_GAL::OnShow() } catch( const std::runtime_error& e ) { - // Fallback to software renderer DisplayError( GetParent(), e.what() ); - SwitchBackend( GAL_TYPE_CAIRO ); - if( frame ) - frame->ActivateGalCanvas(); + // Use the fallback if we have one + if( GAL_FALLBACK != m_backend ) + { + SwitchBackend( GAL_FALLBACK ); + + if( frame ) + frame->ActivateGalCanvas(); + } } if( frame ) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index fe252bbcb1..365827484f 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -195,7 +195,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Create GAL canvas auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, GetGalDisplayOptions(), - EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); + EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); SetCanvas( canvas );