From 99bff8cf8f199cd5899134f12b499ce4ee9a4e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 22 Oct 2019 11:48:08 +0200 Subject: [PATCH] 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 --- cui/source/options/optgdlg.cxx | 139 ++++++++++++++++++ cui/source/options/optgdlg.hxx | 8 + cui/uiconfig/ui/optviewpage.ui | 56 +++++++ include/svtools/restartdialog.hxx | 3 + .../schema/org/openoffice/Office/Common.xcs | 15 ++ solenv/sanitizers/ui/svt.suppr | 1 + svtools/source/dialogs/restartdialog.cxx | 3 + svtools/uiconfig/ui/restartdialog.ui | 15 ++ vcl/inc/strings.hrc | 1 + vcl/skia/SkiaHelper.cxx | 10 +- vcl/source/app/svapp.cxx | 5 +- 11 files changed, 251 insertions(+), 5 deletions(-) diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 17d3c6456967..549513e7a69c 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -75,6 +75,7 @@ #if HAVE_FEATURE_OPENGL #include #endif +#include #include "optgdlg.hxx" #include #include @@ -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 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 OfaViewTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ) { return std::make_unique(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; diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index 7e83ec55d851..491b817c25a6 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -31,6 +31,7 @@ namespace vcl { namespace svt { class OpenGLCfg; + class SkiaCfg; } class OfaMiscTabPage : public SfxTabPage @@ -90,6 +91,7 @@ private: std::unique_ptr pCanvasSettings; std::unique_ptr mpDrawinglayerOpt; std::unique_ptr mpOpenGLConfig; + std::unique_ptr mpSkiaConfig; std::vector mInstalledIconThemes; @@ -113,9 +115,13 @@ private: std::unique_ptr m_xUseAntiAliase; std::unique_ptr m_xUseOpenGL; std::unique_ptr m_xForceOpenGL; + std::unique_ptr m_xUseSkia; + std::unique_ptr m_xForceSkia; std::unique_ptr m_xOpenGLStatusEnabled; std::unique_ptr m_xOpenGLStatusDisabled; + std::unique_ptr m_xSkiaStatusEnabled; + std::unique_ptr m_xSkiaStatusDisabled; std::unique_ptr m_xMousePosLB; std::unique_ptr 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); diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui index 188a3f9e2d09..f6c260351f7c 100644 --- a/cui/uiconfig/ui/optviewpage.ui +++ b/cui/uiconfig/ui/optviewpage.ui @@ -563,6 +563,62 @@ 5 + + + Use Skia for all rendering + True + True + False + True + 0 + True + + + 0 + 6 + + + + + Ignore Skia blacklist + True + True + False + Requires restart. Enabling this may expose driver bugs + 12 + True + 0 + True + + + 0 + 7 + + + + + False + 12 + Skia is currently enabled. + 0 + + + 0 + 8 + + + + + False + 12 + Skia is currently disabled. + 0 + + + 0 + 9 + + diff --git a/include/svtools/restartdialog.hxx b/include/svtools/restartdialog.hxx index 464e2ee2ec7f..6a5bc21a8c6d 100644 --- a/include/svtools/restartdialog.hxx +++ b/include/svtools/restartdialog.hxx @@ -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, diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index cebb7d7ec0ef..c8bdec0fd74e 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -865,6 +865,21 @@ false + + + Specifies if Skia rendering should be used in VCL backends + supporting it. + + false + + + + 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. + + false + Defines if the user interface animations (like "walking ant" diff --git a/solenv/sanitizers/ui/svt.suppr b/solenv/sanitizers/ui/svt.suppr index 9acf97962bcc..4b1b491f93e4 100644 --- a/solenv/sanitizers/ui/svt.suppr +++ b/solenv/sanitizers/ui/svt.suppr @@ -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 diff --git a/svtools/source/dialogs/restartdialog.cxx b/svtools/source/dialogs/restartdialog.cxx index 23a7f592f54e..419b0e55da93 100644 --- a/svtools/source/dialogs/restartdialog.cxx +++ b/svtools/source/dialogs/restartdialog.cxx @@ -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; diff --git a/svtools/uiconfig/ui/restartdialog.ui b/svtools/uiconfig/ui/restartdialog.ui index 618e739a497b..6f66108db398 100644 --- a/svtools/uiconfig/ui/restartdialog.ui +++ b/svtools/uiconfig/ui/restartdialog.ui @@ -287,6 +287,21 @@ 14 + + + False + True + For the Skia changes to take effect, %PRODUCTNAME must be restarted. + True + 50 + 0 + + + False + True + 15 + + False diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc index 7e936fc711a2..d8f73a587722 100644 --- a/vcl/inc/strings.hrc +++ b/vcl/inc/strings.hrc @@ -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") diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx index 278d19bd8d52..bc643bd546b1 100644 --- a/vcl/skia/SkiaHelper.cxx +++ b/vcl/skia/SkiaHelper.cxx @@ -10,6 +10,8 @@ #include #include +#include +#include #include @@ -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; } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 3dcfc82ec00a..4b97754bebbe 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -49,6 +49,7 @@ #if HAVE_FEATURE_OPENGL #include #endif +#include #include #include @@ -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( "; " );