Further simplification of AA regime

Reduce each (Accel & Fallback) to 3 options: Off, Fast, Good.  Fast AA
in accelerated canvas uses SMAA with tweaks suggested by David Beinder.
Good AA is super-sampled x2.

Cairo is similarly reduced to Off, Fast, Good, which map to the Cairo
options themselves.  Best is removed as it mostly affects text rendering
and not line drawing (as our text is)
This commit is contained in:
Seth Hillbrand 2021-06-08 17:20:41 -07:00
parent f2e5a5d34e
commit ea283625a7
9 changed files with 36 additions and 119 deletions

View File

@ -74,7 +74,7 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
antialiasingLabel->Wrap( -1 );
gbSizer1->Add( antialiasingLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxString m_antialiasingChoices[] = { _("No Antialiasing"), _("Fast Antialiasing"), _("Balanced Antialiasing"), _("High Quality Antialiasing") };
wxString m_antialiasingChoices[] = { _("No Antialiasing"), _("Fast Antialiasing"), _("High Quality Antialiasing") };
int m_antialiasingNChoices = sizeof( m_antialiasingChoices ) / sizeof( wxString );
m_antialiasing = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_antialiasingNChoices, m_antialiasingChoices, 0 );
m_antialiasing->SetSelection( 0 );
@ -84,7 +84,7 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
m_antialiasingFallbackLabel->Wrap( -1 );
gbSizer1->Add( m_antialiasingFallbackLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxString m_antialiasingFallbackChoices[] = { _("No Antialiasing"), _("Fast Antialiasing"), _("Balanced Antialiasing"), _("High Quality Antialiasing") };
wxString m_antialiasingFallbackChoices[] = { _("No Antialiasing"), _("Fast Antialiasing"), _("High Quality Antialiasing") };
int m_antialiasingFallbackNChoices = sizeof( m_antialiasingFallbackChoices ) / sizeof( wxString );
m_antialiasingFallback = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_antialiasingFallbackNChoices, m_antialiasingFallbackChoices, 0 );
m_antialiasingFallback->SetSelection( 0 );

View File

@ -696,7 +696,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;No Antialiasing&quot; &quot;Fast Antialiasing&quot; &quot;Balanced Antialiasing&quot; &quot;High Quality Antialiasing&quot;</property>
<property name="choices">&quot;No Antialiasing&quot; &quot;Fast Antialiasing&quot; &quot;High Quality Antialiasing&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -827,7 +827,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;No Antialiasing&quot; &quot;Fast Antialiasing&quot; &quot;Balanced Antialiasing&quot; &quot;High Quality Antialiasing&quot;</property>
<property name="choices">&quot;No Antialiasing&quot; &quot;Fast Antialiasing&quot; &quot;High Quality Antialiasing&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>

View File

@ -66,7 +66,6 @@ void CAIRO_COMPOSITOR::SetAntialiasingMode( CAIRO_ANTIALIASING_MODE aMode )
{
case CAIRO_ANTIALIASING_MODE::FAST: m_currentAntialiasingMode = CAIRO_ANTIALIAS_FAST; break;
case CAIRO_ANTIALIASING_MODE::GOOD: m_currentAntialiasingMode = CAIRO_ANTIALIAS_GOOD; break;
case CAIRO_ANTIALIASING_MODE::BEST: m_currentAntialiasingMode = CAIRO_ANTIALIAS_BEST; break;
default: m_currentAntialiasingMode = CAIRO_ANTIALIAS_NONE;
}

View File

@ -127,44 +127,16 @@ void draw_fullscreen_primitive()
// ANTIALIASING_SUPERSAMPLING
// =========================
ANTIALIASING_SUPERSAMPLING::ANTIALIASING_SUPERSAMPLING( OPENGL_COMPOSITOR* aCompositor,
SUPERSAMPLING_MODE aMode ) :
ANTIALIASING_SUPERSAMPLING::ANTIALIASING_SUPERSAMPLING( OPENGL_COMPOSITOR* aCompositor ) :
compositor( aCompositor ),
mode( aMode ), ssaaMainBuffer( 0 ), areBuffersCreated( false ), areShadersCreated( false )
ssaaMainBuffer( 0 ), areBuffersCreated( false ), areShadersCreated( false )
{
}
bool ANTIALIASING_SUPERSAMPLING::Init()
{
if( mode == SUPERSAMPLING_MODE::X4 && !areShadersCreated )
{
x4_shader = std::make_unique<SHADER>();
x4_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_VERTEX,
BUILTIN_SHADERS::ssaa_x4_vertex_shader );
x4_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_FRAGMENT,
BUILTIN_SHADERS::ssaa_x4_fragment_shader );
x4_shader->Link();
checkGlError( "linking supersampling x4 shader", __FILE__, __LINE__ );
GLint source_parameter = x4_shader->AddParameter( "source" );
checkGlError( "getting pass 1 colorTex", __FILE__, __LINE__ );
x4_shader->Use();
checkGlError( "using pass 1 shader", __FILE__, __LINE__ );
x4_shader->SetParameter( source_parameter, 0 );
checkGlError( "setting colorTex uniform", __FILE__, __LINE__ );
x4_shader->Deactivate();
checkGlError( "deactivating pass 2 shader", __FILE__, __LINE__ );
areShadersCreated = true;
}
if( areShadersCreated && mode != SUPERSAMPLING_MODE::X4 )
{
x4_shader.reset();
areShadersCreated = false;
}
areShadersCreated = false;
if( !areBuffersCreated )
{
@ -181,8 +153,7 @@ bool ANTIALIASING_SUPERSAMPLING::Init()
VECTOR2U ANTIALIASING_SUPERSAMPLING::GetInternalBufferSize()
{
unsigned int factor = ( mode == SUPERSAMPLING_MODE::X2 ) ? 2 : 4;
return compositor->GetScreenSize() * factor;
return compositor->GetScreenSize() * 2;
}
@ -207,19 +178,7 @@ void ANTIALIASING_SUPERSAMPLING::Present()
glBindTexture( GL_TEXTURE_2D, compositor->GetBufferTexture( ssaaMainBuffer ) );
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
if( mode == SUPERSAMPLING_MODE::X4 )
{
x4_shader->Use();
checkGlError( "activating supersampling x4 shader", __FILE__, __LINE__ );
}
draw_fullscreen_primitive();
if( mode == SUPERSAMPLING_MODE::X4 )
{
x4_shader->Deactivate();
checkGlError( "deactivating supersampling x4 shader", __FILE__, __LINE__ );
}
}
@ -238,10 +197,9 @@ unsigned int ANTIALIASING_SUPERSAMPLING::CreateBuffer()
// ANTIALIASING_SMAA
// ===============================
ANTIALIASING_SMAA::ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor, SMAA_QUALITY aQuality ) :
ANTIALIASING_SMAA::ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor ) :
areBuffersInitialized( false ),
shadersLoaded( false ),
quality( aQuality ),
compositor( aCompositor )
{
smaaBaseBuffer = 0;
@ -303,27 +261,14 @@ void ANTIALIASING_SMAA::loadShaders()
std::string quality_string;
const char* edge_detect_shader;
if( quality == SMAA_QUALITY::CONSERVATIVE )
{
// trades imperfect AA of shallow angles for a near artifact-free reproduction of fine features
// jaggies are smoothed over max 5px (original step + 2px in both directions)
quality_string = "#define SMAA_THRESHOLD 0.1\n"
"#define SMAA_MAX_SEARCH_STEPS 1\n"
"#define SMAA_MAX_SEARCH_STEPS_DIAG 2\n"
"#define SMAA_DISABLE_CORNER_DETECTION\n";
edge_detect_shader = BUILTIN_SHADERS::smaa_pass_1_fragment_shader_luma;
}
else
{
// jaggies are smoothed over max 17px (original step + 8px in both directions)
quality_string = "#define SMAA_THRESHOLD 0.05\n"
"#define SMAA_MAX_SEARCH_STEPS 4\n"
"#define SMAA_MAX_SEARCH_STEPS_DIAG 4\n"
"#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 1.5\n"
"#define SMAA_CORNER_ROUNDING 10\n";
edge_detect_shader = BUILTIN_SHADERS::smaa_pass_1_fragment_shader_color;
}
// trades imperfect AA of shallow angles for a near artifact-free reproduction of fine features
// jaggies are smoothed over max 5px (original step + 2px in both directions)
quality_string = "#define SMAA_THRESHOLD 0.005\n"
"#define SMAA_MAX_SEARCH_STEPS 1\n"
"#define SMAA_MAX_SEARCH_STEPS_DIAG 2\n"
"#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 1.5\n"
"#define SMAA_CORNER_ROUNDING 0\n";
edge_detect_shader = BUILTIN_SHADERS::smaa_pass_1_fragment_shader_luma;
// set up shaders
std::string vert_preamble( R"SHADER(

View File

@ -70,16 +70,11 @@ namespace KIGFX {
OPENGL_COMPOSITOR* compositor;
};
enum class SUPERSAMPLING_MODE {
X2,
X4
};
class ANTIALIASING_SUPERSAMPLING : public OPENGL_PRESENTOR
{
public:
ANTIALIASING_SUPERSAMPLING( OPENGL_COMPOSITOR* aCompositor, SUPERSAMPLING_MODE aMode );
ANTIALIASING_SUPERSAMPLING( OPENGL_COMPOSITOR* aCompositor );
bool Init() override;
unsigned int CreateBuffer() override;
@ -93,25 +88,17 @@ namespace KIGFX {
private:
OPENGL_COMPOSITOR* compositor;
SUPERSAMPLING_MODE mode;
unsigned int ssaaMainBuffer;
bool areBuffersCreated;
bool areShadersCreated;
std::unique_ptr<SHADER> x4_shader;
};
enum class SMAA_QUALITY
{
CONSERVATIVE,
AGGRESSIVE
};
class ANTIALIASING_SMAA : public OPENGL_PRESENTOR
{
public:
ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor, SMAA_QUALITY aQuality );
ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor );
bool Init() override;
unsigned int CreateBuffer () override;
@ -148,7 +135,6 @@ namespace KIGFX {
std::unique_ptr<SHADER> pass_3_shader;
GLint pass_3_metrics;
SMAA_QUALITY quality;
OPENGL_COMPOSITOR* compositor;
};

View File

@ -93,23 +93,15 @@ void OPENGL_COMPOSITOR::Initialize()
switch( m_currentAntialiasingMode )
{
case OPENGL_ANTIALIASING_MODE::NONE:
case OPENGL_ANTIALIASING_MODE::SMAA:
m_antialiasing = std::make_unique<ANTIALIASING_SMAA>( this );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING:
m_antialiasing = std::make_unique<ANTIALIASING_SUPERSAMPLING>( this );
break;
default:
m_antialiasing = std::make_unique<ANTIALIASING_NONE>( this );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_CONSERVATIVE:
m_antialiasing = std::make_unique<ANTIALIASING_SMAA>( this, SMAA_QUALITY::CONSERVATIVE );
break;
case OPENGL_ANTIALIASING_MODE::SUBSAMPLE_AGGRESSIVE:
m_antialiasing = std::make_unique<ANTIALIASING_SMAA>( this, SMAA_QUALITY::AGGRESSIVE );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X2:
m_antialiasing =
std::make_unique<ANTIALIASING_SUPERSAMPLING>( this, SUPERSAMPLING_MODE::X2 );
break;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X4:
m_antialiasing =
std::make_unique<ANTIALIASING_SUPERSAMPLING>( this, SUPERSAMPLING_MODE::X4 );
break;
}
VECTOR2U dims = m_antialiasing->GetInternalBufferSize();
@ -432,11 +424,12 @@ void OPENGL_COMPOSITOR::clean()
int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor() const
{
switch( m_currentAntialiasingMode )
switch ( m_currentAntialiasingMode )
{
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X2: return 2;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X4: return 4;
default: return 1;
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING:
return 2;
default:
return 1;
}
}
@ -444,8 +437,7 @@ VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset() const
{
switch( m_currentAntialiasingMode )
{
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X2: return VECTOR2D( 0.5, -0.5 );
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING_X4: return VECTOR2D( 0.25, -0.25 );
case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING: return VECTOR2D( 0.5, -0.5 );
default: return VECTOR2D( 0, 0 );
}
}

View File

@ -247,10 +247,10 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
MOUSE_DRAG_ACTION::NONE ) );
m_params.emplace_back( new PARAM<int>( "graphics.opengl_antialiasing_mode",
&m_Graphics.opengl_aa_mode, 0, 0, 3 ) );
&m_Graphics.opengl_aa_mode, 0, 0, 2 ) );
m_params.emplace_back( new PARAM<int>( "graphics.cairo_antialiasing_mode",
&m_Graphics.cairo_aa_mode, 0, 0, 3 ) );
&m_Graphics.cairo_aa_mode, 0, 0, 2 ) );
m_params.emplace_back( new PARAM<int>( "system.autosave_interval",
&m_System.autosave_interval, 600 ) );

View File

@ -86,8 +86,6 @@ public:
return CAIRO_ANTIALIASING_MODE::FAST;
case CAIRO_ANTIALIAS_GOOD:
return CAIRO_ANTIALIASING_MODE::GOOD;
case CAIRO_ANTIALIAS_BEST:
return CAIRO_ANTIALIASING_MODE::BEST;
default:
return CAIRO_ANTIALIASING_MODE::NONE;
}

View File

@ -48,10 +48,8 @@ namespace KIGFX
enum class OPENGL_ANTIALIASING_MODE
{
NONE,
SUBSAMPLE_CONSERVATIVE,
SUBSAMPLE_AGGRESSIVE,
SUPERSAMPLING_X2,
SUPERSAMPLING_X4,
SMAA,
SUPERSAMPLING,
};
enum class CAIRO_ANTIALIASING_MODE
@ -59,7 +57,6 @@ namespace KIGFX
NONE,
FAST,
GOOD,
BEST,
};
enum class GRID_SNAPPING