Remove canvas-switching from OSX.

The Cairo renderer doesn't work on Retina displays.

Fixes https://gitlab.com/kicad/code/kicad/issues/4788
This commit is contained in:
Jeff Young 2020-08-31 18:47:44 +01:00
parent 452171e055
commit 2697fc3864
20 changed files with 86 additions and 76 deletions

View File

@ -233,13 +233,19 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
} }
catch( std::runtime_error& err ) 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" ),
DisplayInfoMessage( m_parent, wxString( err.what() ) );
_( "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 #ifdef PROFILE
@ -398,10 +404,19 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
} }
else else
{ {
aGalType = GAL_TYPE_CAIRO; if( GAL_FALLBACK != aGalType )
DisplayInfoMessage( m_parent, {
_( "Could not use OpenGL, falling back to software rendering" ), errormsg ); aGalType = GAL_FALLBACK;
new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this ); 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; break;
} }

View File

@ -42,7 +42,6 @@
#include <settings/common_settings.h> #include <settings/common_settings.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <title_block.h> #include <title_block.h>
#include <tool/action_manager.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/grid_menu.h> #include <tool/grid_menu.h>
@ -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() 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; EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings(); 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 // Legacy canvas no longer supported. Switch to Cairo, and on the first instantiation
// the user will be prompted to switch to OpenGL // the user will be prompted to switch to OpenGL
if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
{ canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
#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
}
return canvasType; return canvasType;
} }

View File

@ -45,7 +45,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
{ {
// Make Coverity happy: // Make Coverity happy:
m_LibTree.column_width = 360; 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: // Build parameters list:
m_params.emplace_back( new PARAM<int>( "find_replace.flags", &m_FindReplace.flags, 1 ) ); m_params.emplace_back( new PARAM<int>( "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<wxString>( "find_replace.replace_history", m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
&m_FindReplace.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<int>( "graphics.canvas_type", m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ); &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) );
#else
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
#endif
m_params.emplace_back( new PARAM<float>( m_params.emplace_back( new PARAM<float>(
"graphics.highlight_factor", &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) ); "graphics.highlight_factor", &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );

View File

@ -555,22 +555,14 @@ TOOL_ACTION ACTIONS::updateSchematicFromPcb( "common.Control.updateSchematicFrom
TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics", TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics",
AS_GLOBAL, AS_GLOBAL,
#ifdef __WXMAC__
MD_ALT + WXK_F11,
#else
WXK_F11, WXK_F11,
#endif
LEGACY_HK_NAME( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ), LEGACY_HK_NAME( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
_( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ), _( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ),
tools_xpm ); tools_xpm );
TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics", TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics",
AS_GLOBAL, AS_GLOBAL,
#ifdef __WXMAC__
MD_ALT + WXK_F12,
#else
WXK_F12, WXK_F12,
#endif
LEGACY_HK_NAME( "Switch to Modern Toolset with software graphics (fall-back)" ), LEGACY_HK_NAME( "Switch to Modern Toolset with software graphics (fall-back)" ),
_( "Standard Graphics" ), _( "Use software graphics (fall-back)" ), _( "Standard Graphics" ), _( "Use software graphics (fall-back)" ),
tools_xpm ); tools_xpm );

View File

@ -522,8 +522,10 @@ int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent )
{ {
if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) ) if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) )
m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ); m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
#ifndef __WXMAC__
else if( aEvent.IsAction( &ACTIONS::standardGraphics ) ) else if( aEvent.IsAction( &ACTIONS::standardGraphics ) )
m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
#endif
else else
wxFAIL_MSG( "Unknown canvas type" ); wxFAIL_MSG( "Unknown canvas type" );

View File

@ -78,14 +78,9 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
// Create GAL canvas before loading settings // 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, 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 ); SetCanvas( gal_drawPanel );
// Don't show the default board solder mask clearance. Only the // Don't show the default board solder mask clearance. Only the

View File

@ -160,9 +160,11 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
#ifndef __WXMAC__
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
#endif
//-- Menubar ------------------------------------------------------------- //-- Menubar -------------------------------------------------------------

View File

@ -268,9 +268,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
#ifndef __WXMAC__
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
#endif
//-- Menubar ------------------------------------------------------------- //-- Menubar -------------------------------------------------------------

View File

@ -304,7 +304,7 @@ void SCH_BASE_FRAME::createCanvas()
// Allows only a CAIRO or OPENGL canvas: // Allows only a CAIRO or OPENGL canvas:
if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL 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; m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
} }

View File

@ -192,12 +192,16 @@ void SCH_DRAW_PANEL::OnShow()
} }
catch( const std::runtime_error& e ) catch( const std::runtime_error& e )
{ {
// Fallback to software renderer
DisplayInfoMessage( frame, e.what() ); DisplayInfoMessage( frame, e.what() );
SwitchBackend( GAL_TYPE_CAIRO );
if( frame ) // Use fallback if one is available
frame->ActivateGalCanvas(); if( GAL_FALLBACK != m_backend )
{
SwitchBackend( GAL_FALLBACK );
if( frame )
frame->ActivateGalCanvas();
}
} }
} }

View File

@ -48,9 +48,11 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = aCanvasType; EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = aCanvasType;
// Allows only a CAIRO or OPENGL canvas: // Allows only a CAIRO or OPENGL canvas:
if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL && if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL
canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) && canvasType != EDA_DRAW_PANEL_GAL::GAL_FALLBACK )
{
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
}
m_preview = new SCH_PREVIEW_PANEL( aParent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), m_preview = new SCH_PREVIEW_PANEL( aParent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
m_galDisplayOptions, canvasType ); m_galDisplayOptions, canvasType );

View File

@ -239,9 +239,11 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
preferencesMenu->AppendSeparator(); preferencesMenu->AppendSeparator();
AddMenuLanguageList( preferencesMenu, selTool ); AddMenuLanguageList( preferencesMenu, selTool );
#ifndef __WXMAC__
preferencesMenu->AppendSeparator(); preferencesMenu->AppendSeparator();
preferencesMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); preferencesMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
preferencesMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); preferencesMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
#endif
//-- Menubar ------------------------------------------------------------- //-- Menubar -------------------------------------------------------------

View File

@ -63,6 +63,13 @@ public:
GAL_TYPE_LAST ///< Sentinel, do not use as a parameter 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. * Create a drawing panel that is contained inside \p aParentWindow.
* *

View File

@ -96,12 +96,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetIcon( icon ); SetIcon( icon );
// Create GAL canvas // Create GAL canvas
#ifdef __WXMAC__ m_canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
// 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
auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), m_canvasType ); GetGalDisplayOptions(), m_canvasType );

View File

@ -255,14 +255,10 @@ void DIALOG_PAD_PROPERTIES::enablePrimitivePage( bool aEnable )
void DIALOG_PAD_PROPERTIES::prepareCanvas() void DIALOG_PAD_PROPERTIES::prepareCanvas()
{ {
// Initialize the canvas to display the pad // Initialize the canvas to display the pad
#ifdef __WXMAC__ m_padPreviewGAL = new PCB_DRAW_PANEL_GAL( m_boardViewPanel, -1, wxDefaultPosition,
// Cairo renderer doesn't handle Retina displays wxDefaultSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; m_parent->GetGalDisplayOptions(),
#else EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
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_padPreviewSizer->Add( m_padPreviewGAL, 12, wxEXPAND | wxALL, 5 ); m_padPreviewSizer->Add( m_padPreviewGAL, 12, wxEXPAND | wxALL, 5 );

View File

@ -126,14 +126,10 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false ); GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
// Create GAL canvas // Create GAL canvas
#ifdef __WXMAC__ PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
// Cairo renderer doesn't handle Retina displays m_FrameSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; GetGalDisplayOptions(),
#else EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
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 );
SetCanvas( gal_drawPanel ); SetCanvas( gal_drawPanel );
PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions(); PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions();

View File

@ -235,9 +235,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
#ifndef __WXMAC__
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
#endif
//--MenuBar ----------------------------------------------------------- //--MenuBar -----------------------------------------------------------
// //

View File

@ -445,9 +445,11 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
#ifndef __WXMAC__
prefsMenu->AppendSeparator(); prefsMenu->AppendSeparator();
prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
#endif
//--MenuBar ----------------------------------------------------------- //--MenuBar -----------------------------------------------------------

View File

@ -424,12 +424,16 @@ void PCB_DRAW_PANEL_GAL::OnShow()
} }
catch( const std::runtime_error& e ) catch( const std::runtime_error& e )
{ {
// Fallback to software renderer
DisplayError( GetParent(), e.what() ); DisplayError( GetParent(), e.what() );
SwitchBackend( GAL_TYPE_CAIRO );
if( frame ) // Use the fallback if we have one
frame->ActivateGalCanvas(); if( GAL_FALLBACK != m_backend )
{
SwitchBackend( GAL_FALLBACK );
if( frame )
frame->ActivateGalCanvas();
}
} }
if( frame ) if( frame )

View File

@ -195,7 +195,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Create GAL canvas // Create GAL canvas
auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), GetGalDisplayOptions(),
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
SetCanvas( canvas ); SetCanvas( canvas );