diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-10-22 11:48:08 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:10 +0100 |
commit | 99bff8cf8f199cd5899134f12b499ce4ee9a4e82 (patch) | |
tree | f4c346d85d531aad00cc1667c871fdc69b6a70b4 /cui | |
parent | fb6a2d3afb67481565c666c10eee0a875808d803 (diff) |
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
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optgdlg.cxx | 139 | ||||
-rw-r--r-- | cui/source/options/optgdlg.hxx | 8 | ||||
-rw-r--r-- | cui/uiconfig/ui/optviewpage.ui | 56 |
3 files changed, 203 insertions, 0 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 <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; 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<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); 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 @@ <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> |