add GUI and configuration options for Skia

Pretty much a copy&paste of OpenGL. There are no settings for choosing
which backend Skia should use, as the plan is that simply the "best"
one will be selected.

Change-Id: I44fa876ab85de98de482a6ed9f814024334686ce
This commit is contained in:
Luboš Luňák 2019-10-22 11:48:08 +02:00
parent fb6a2d3afb
commit 99bff8cf8f
11 changed files with 251 additions and 5 deletions

View file

@ -75,6 +75,7 @@
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLWrapper.hxx>
#endif
#include <vcl/skia/SkiaHelper.hxx>
#include "optgdlg.hxx"
#include <svtools/apearcfg.hxx>
#include <svtools/optionsdrawinglayer.hxx>
@ -176,6 +177,86 @@ void OpenGLCfg::setForceOpenGL(bool bOpenGL)
}
}
class SkiaCfg
{
private:
bool mbUseSkia;
bool mbForceSkia;
bool mbModified;
public:
SkiaCfg();
~SkiaCfg();
bool useSkia() const;
bool forceSkia() const;
void setUseSkia(bool bSkia);
void setForceSkia(bool bSkia);
void reset();
};
SkiaCfg::SkiaCfg():
mbModified(false)
{
reset();
}
void SkiaCfg::reset()
{
mbUseSkia = officecfg::Office::Common::VCL::UseSkia::get();
mbForceSkia = officecfg::Office::Common::VCL::ForceSkia::get();
mbModified = false;
}
SkiaCfg::~SkiaCfg()
{
if (mbModified)
{
try
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
if (!officecfg::Office::Common::VCL::UseSkia::isReadOnly())
officecfg::Office::Common::VCL::UseSkia::set(mbUseSkia, batch);
if (!officecfg::Office::Common::VCL::ForceSkia::isReadOnly())
officecfg::Office::Common::VCL::ForceSkia::set(mbForceSkia, batch);
batch->commit();
}
catch (...)
{
}
}
}
bool SkiaCfg::useSkia() const
{
return mbUseSkia;
}
bool SkiaCfg::forceSkia() const
{
return mbForceSkia;
}
void SkiaCfg::setUseSkia(bool bSkia)
{
if (bSkia != mbUseSkia)
{
mbUseSkia = bSkia;
mbModified = true;
}
}
void SkiaCfg::setForceSkia(bool bSkia)
{
if (mbForceSkia != bSkia)
{
mbForceSkia = bSkia;
mbModified = true;
}
}
}
// class OfaMiscTabPage --------------------------------------------------
@ -544,6 +625,7 @@ CanvasSettings::CanvasSettings() :
bool CanvasSettings::IsHardwareAccelerationAvailable() const
{
#if HAVE_FEATURE_OPENGL
// TODO SKIA
if (OpenGLWrapper::isVCLOpenGLEnabled() && Application::GetToolkitName() != "gtk3")
mbHWAccelAvailable = false;
@ -648,6 +730,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
, pCanvasSettings(new CanvasSettings)
, mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
, mpOpenGLConfig(new svt::OpenGLCfg)
, mpSkiaConfig(new svt::SkiaCfg)
, m_xIconSizeLB(m_xBuilder->weld_combo_box("iconsize"))
, m_xSidebarIconSizeLB(m_xBuilder->weld_combo_box("sidebariconsize"))
, m_xNotebookbarIconSizeLB(m_xBuilder->weld_combo_box("notebookbariconsize"))
@ -663,8 +746,12 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
, m_xUseAntiAliase(m_xBuilder->weld_check_button("useaa"))
, m_xUseOpenGL(m_xBuilder->weld_check_button("useopengl"))
, m_xForceOpenGL(m_xBuilder->weld_check_button("forceopengl"))
, m_xUseSkia(m_xBuilder->weld_check_button("useskia"))
, m_xForceSkia(m_xBuilder->weld_check_button("forceskia"))
, m_xOpenGLStatusEnabled(m_xBuilder->weld_label("openglenabled"))
, m_xOpenGLStatusDisabled(m_xBuilder->weld_label("opengldisabled"))
, m_xSkiaStatusEnabled(m_xBuilder->weld_label("skiaenabled"))
, m_xSkiaStatusDisabled(m_xBuilder->weld_label("skiadisabled"))
, m_xMousePosLB(m_xBuilder->weld_combo_box("mousepos"))
, m_xMouseMiddleLB(m_xBuilder->weld_combo_box("mousemiddle"))
{
@ -674,6 +761,10 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
m_xForceOpenGL->hide();
m_xOpenGLStatusEnabled->hide();
m_xOpenGLStatusDisabled->hide();
m_xUseSkia->hide();
m_xForceSkia->hide();
m_xSkiaStatusEnabled->hide();
m_xSkiaStatusDisabled->hide();
m_xMenuIconBox->hide();
}
@ -688,6 +779,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
#endif
m_xForceOpenGL->connect_toggled(LINK(this, OfaViewTabPage, OnForceOpenGLToggled));
m_xForceSkia->connect_toggled(LINK(this, OfaViewTabPage, OnForceSkiaToggled));
// Set known icon themes
OUString sAutoStr( m_xIconStyleLB->get_text( 0 ) );
@ -718,8 +810,13 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
m_xUseOpenGL->set_sensitive(false);
if (officecfg::Office::Common::VCL::ForceOpenGL::isReadOnly())
m_xForceOpenGL->set_sensitive(false);
if (officecfg::Office::Common::VCL::UseSkia::isReadOnly())
m_xUseSkia->set_sensitive(false);
if (officecfg::Office::Common::VCL::ForceSkia::isReadOnly())
m_xForceSkia->set_sensitive(false);
UpdateOGLStatus();
UpdateSkiaStatus();
}
OfaViewTabPage::~OfaViewTabPage()
@ -745,6 +842,15 @@ IMPL_LINK_NOARG(OfaViewTabPage, OnForceOpenGLToggled, weld::ToggleButton&, void)
}
}
IMPL_LINK_NOARG(OfaViewTabPage, OnForceSkiaToggled, weld::ToggleButton&, void)
{
if (m_xForceSkia->get_active())
{
// Ignoring the Skia blacklist implies that Skia is on.
m_xUseSkia->set_active(true);
}
}
std::unique_ptr<SfxTabPage> OfaViewTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
{
return std::make_unique<OfaViewTabPage>(pPage, pController, *rAttrSet);
@ -919,6 +1025,14 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
bModified = true;
}
if (m_xUseSkia->get_state_changed_from_saved() ||
m_xForceSkia->get_state_changed_from_saved())
{
mpSkiaConfig->setUseSkia(m_xUseSkia->get_active());
mpSkiaConfig->setForceSkia(m_xForceSkia->get_active());
bModified = true;
}
if( bMenuOptModified )
{
// Set changed settings to the application instance
@ -956,6 +1070,16 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
GetDialogController()->response(RET_OK);
}
if (m_xUseSkia->get_state_changed_from_saved() ||
m_xForceSkia->get_state_changed_from_saved())
{
SolarMutexGuard aGuard;
if( svtools::executeRestartDialog(
comphelper::getProcessComponentContext(), nullptr,
svtools::RESTART_REASON_SKIA))
GetDialogController()->response(RET_OK);
}
return bModified;
}
@ -963,6 +1087,7 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
{
SvtMiscOptions aMiscOptions;
mpOpenGLConfig->reset();
mpSkiaConfig->reset();
if (aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO)
{
@ -1061,6 +1186,8 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
}
m_xUseOpenGL->set_active(mpOpenGLConfig->useOpenGL());
m_xForceOpenGL->set_active(mpOpenGLConfig->forceOpenGL());
m_xUseSkia->set_active(mpSkiaConfig->useSkia());
m_xForceSkia->set_active(mpSkiaConfig->forceSkia());
#if defined( UNX )
m_xFontAntiAliasing->save_state();
@ -1070,6 +1197,8 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
m_xUseOpenGL->save_state();
m_xForceOpenGL->save_state();
m_xUseSkia->save_state();
m_xForceSkia->save_state();
#if defined( UNX )
OnAntialiasingToggled(*m_xFontAntiAliasing);
@ -1090,6 +1219,16 @@ void OfaViewTabPage::UpdateOGLStatus()
m_xOpenGLStatusDisabled->set_visible(!bEnabled);
}
void OfaViewTabPage::UpdateSkiaStatus()
{
if (Application::GetToolkitName() == "gtk3")
return;
// Easier than a custom translation string.
bool bEnabled = SkiaHelper::isVCLSkiaEnabled();
m_xSkiaStatusEnabled->set_visible(bEnabled);
m_xSkiaStatusDisabled->set_visible(!bEnabled);
}
struct LanguageConfig_Impl
{
SvtLanguageOptions aLanguageOptions;

View file

@ -31,6 +31,7 @@ namespace vcl {
namespace svt {
class OpenGLCfg;
class SkiaCfg;
}
class OfaMiscTabPage : public SfxTabPage
@ -90,6 +91,7 @@ private:
std::unique_ptr<CanvasSettings> pCanvasSettings;
std::unique_ptr<SvtOptionsDrawinglayer> mpDrawinglayerOpt;
std::unique_ptr<svt::OpenGLCfg> mpOpenGLConfig;
std::unique_ptr<svt::SkiaCfg> mpSkiaConfig;
std::vector<vcl::IconThemeInfo> mInstalledIconThemes;
@ -113,9 +115,13 @@ private:
std::unique_ptr<weld::CheckButton> m_xUseAntiAliase;
std::unique_ptr<weld::CheckButton> m_xUseOpenGL;
std::unique_ptr<weld::CheckButton> m_xForceOpenGL;
std::unique_ptr<weld::CheckButton> m_xUseSkia;
std::unique_ptr<weld::CheckButton> m_xForceSkia;
std::unique_ptr<weld::Label> m_xOpenGLStatusEnabled;
std::unique_ptr<weld::Label> m_xOpenGLStatusDisabled;
std::unique_ptr<weld::Label> m_xSkiaStatusEnabled;
std::unique_ptr<weld::Label> m_xSkiaStatusDisabled;
std::unique_ptr<weld::ComboBox> m_xMousePosLB;
std::unique_ptr<weld::ComboBox> m_xMouseMiddleLB;
@ -124,7 +130,9 @@ private:
DECL_LINK(OnAntialiasingToggled, weld::ToggleButton&, void);
#endif
DECL_LINK(OnForceOpenGLToggled, weld::ToggleButton&, void);
DECL_LINK(OnForceSkiaToggled, weld::ToggleButton&, void);
void UpdateOGLStatus();
void UpdateSkiaStatus();
public:
OfaViewTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);

View file

@ -563,6 +563,62 @@
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="useskia">
<property name="label" translatable="yes" context="optviewpage|useskia">Use Skia for all rendering</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="forceskia">
<property name="label" translatable="yes" context="optviewpage|forceskia">Ignore Skia blacklist</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes" context="optviewpage|forceskia|tooltip_text">Requires restart. Enabling this may expose driver bugs</property>
<property name="margin_left">12</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="skiaenabled">
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="label" translatable="yes" context="optviewpage|skiaenabled">Skia is currently enabled.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="skiadisabled">
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="label" translatable="yes" context="optviewpage|skiadisabled">Skia is currently disabled.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
</packing>
</child>
</object>
</child>
</object>

View file

@ -57,6 +57,9 @@ enum RestartReason {
// For the OpenGL changes to take effect,
// %PRODUCTNAME must be restarted:
RESTART_REASON_OPENGL,
// For the Skia changes to take effect,
// %PRODUCTNAME must be restarted:
RESTART_REASON_SKIA,
// For the OpenCL changes to take effect,
// %PRODUCTNAME must be restarted:
RESTART_REASON_OPENCL,

View file

@ -865,6 +865,21 @@
</info>
<value>false</value>
</prop>
<prop oor:name="UseSkia" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies if Skia rendering should be used in VCL backends
supporting it.</desc>
</info>
<value>false</value>
</prop>
<prop oor:name="ForceSkia" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies if Skia rendering should be used in VCL backends
supporting it. This one forces the use of Skia even if the
blacklist would block the driver.</desc>
</info>
<value>false</value>
</prop>
<prop oor:name="AnimationsEnabled" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Defines if the user interface animations (like "walking ant"

View file

@ -23,4 +23,5 @@ svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_language_change'] or
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_exp_features'] orphan-label
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_extension_install'] orphan-label
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_opengl'] orphan-label
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_skia'] orphan-label
svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='label'] orphan-label

View file

@ -62,6 +62,9 @@ public:
case svtools::RESTART_REASON_OPENGL:
reason_ = m_xBuilder->weld_widget("reason_opengl");
break;
case svtools::RESTART_REASON_SKIA:
reason_ = m_xBuilder->weld_widget("reason_skia");
break;
case svtools::RESTART_REASON_OPENCL:
reason_ = m_xBuilder->weld_widget("reason_opencl");
break;

View file

@ -287,6 +287,21 @@
<property name="position">14</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="reason_skia">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="label" translatable="yes" context="restartdialog|reason_skia">For the Skia changes to take effect, %PRODUCTNAME must be restarted.</property>
<property name="wrap">True</property>
<property name="max_width_chars">50</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">15</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View file

@ -125,6 +125,7 @@
#define SV_APP_OSVERSION NC_("SV_APP_OSVERSION", "OS: ")
#define SV_APP_UIRENDER NC_("SV_APP_UIRENDER", "UI render: ")
#define SV_APP_GL NC_("SV_APP_GL", "GL")
#define SV_APP_SKIA NC_("SV_APP_SKIA", "Skia")
#define SV_APP_DEFAULT NC_("SV_APP_DEFAULT", "default")
#define SV_MSGBOX_INFO NC_("SV_MSGBOX_INFO", "Information")

View file

@ -10,6 +10,8 @@
#include <vcl/skia/SkiaHelper.hxx>
#include <vcl/svapp.hxx>
#include <desktop/crashreport.hxx>
#include <officecfg/Office/Common.hxx>
#include <config_features.h>
@ -54,8 +56,7 @@ bool SkiaHelper::isVCLSkiaEnabled()
*/
bSet = true;
bForceSkia = !!getenv(
"SAL_FORCESKIA"); // TODO SKIA || officecfg::Office::Common::VCL::ForceOpenGL::get();
bForceSkia = !!getenv("SAL_FORCESKIA") || officecfg::Office::Common::VCL::ForceSkia::get();
bool bRet = false;
bool bSupportsVCLSkia = supportsVCLSkia();
@ -70,7 +71,8 @@ bool SkiaHelper::isVCLSkiaEnabled()
bEnable = bEnableSkiaEnv;
// TODO SKIA if (officecfg::Office::Common::VCL::UseOpenGL::get())
if (officecfg::Office::Common::VCL::UseSkia::get())
bEnable = false;
// Force disable in safe mode
if (Application::IsSafeModeEnabled())
@ -79,7 +81,7 @@ bool SkiaHelper::isVCLSkiaEnabled()
bRet = bEnable;
}
// TODO SKIA CrashReporter::AddKeyValue("UseOpenGL", OUString::boolean(bRet));
CrashReporter::addKeyValue("UseSkia", OUString::boolean(bRet), CrashReporter::Write);
return bRet;
}

View file

@ -49,6 +49,7 @@
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLWrapper.hxx>
#endif
#include <vcl/skia/SkiaHelper.hxx>
#include <salinst.hxx>
#include <salframe.hxx>
@ -1147,12 +1148,14 @@ OUString Application::GetHWOSConfInfo()
aDetails.append( "; " );
aDetails.append( VclResId(SV_APP_UIRENDER) );
// TODO SKIA
#if HAVE_FEATURE_OPENGL
if ( OpenGLWrapper::isVCLOpenGLEnabled() )
aDetails.append( VclResId(SV_APP_GL) );
else
#endif
if ( SkiaHelper::isVCLSkiaEnabled() )
aDetails.append( VclResId(SV_APP_SKIA) );
else
aDetails.append( VclResId(SV_APP_DEFAULT) );
aDetails.append( "; " );