[Libreoffice-commits] core.git: 2 commits - cui/source cui/uiconfig officecfg/registry vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 10 09:10:37 UTC 2020


 cui/source/options/optgdlg.cxx                             |   43 ++++++++++++-
 cui/source/options/optgdlg.hxx                             |    2 
 cui/uiconfig/ui/optviewpage.ui                             |   21 +++++-
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    8 ++
 vcl/skia/SkiaHelper.cxx                                    |   12 +++
 vcl/skia/zone.cxx                                          |    5 -
 6 files changed, 85 insertions(+), 6 deletions(-)

New commits:
commit 67770fc41f409e9d7e179b34eb84434ed237a6ce
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Feb 7 15:55:21 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Feb 10 10:10:17 2020 +0100

    if OpenGL is forced, do not enable Skia in order to allow GL
    
    Change-Id: I013db819b66252a25e0a6fddd8e777c3d8d36372
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88210
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index cdbb2c0b7977..39588aedcf53 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -122,6 +122,12 @@ bool isVCLSkiaEnabled()
     {
         bRet = true;
     }
+    else if (getenv("SAL_FORCEGL"))
+    {
+        // Skia usage is checked before GL usage, so if GL is forced (and Skia is not), do not
+        // enable Skia in order to allow GL.
+        bRet = false;
+    }
     else if (bSupportsVCLSkia)
     {
         static bool bEnableSkiaEnv = !!getenv("SAL_ENABLESKIA");
commit 90b02dd4a465f312a6b9c27ff572b5a304e857de
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Feb 7 15:36:26 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Feb 10 10:10:01 2020 +0100

    in case of Skia problems force raster mode, don't disable it all
    
    Skia's CPU-based raster mode should be safe (at least from driver problems),
    so it should be enough to make the failsafe mechanism just disable Vulkan
    use.
    Also add UI option controlling forced raster rendering.
    
    Change-Id: I6be1745782816e5468e55635ae5613b6a6afded6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88206
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index e10f743361c8..fb73341b9897 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -188,6 +188,7 @@ class SkiaCfg
 private:
     bool mbUseSkia;
     bool mbForceSkia;
+    bool mbForceSkiaRaster;
     bool mbModified;
 
 public:
@@ -196,9 +197,11 @@ public:
 
     bool useSkia() const;
     bool forceSkia() const;
+    bool forceSkiaRaster() const;
 
     void setUseSkia(bool bSkia);
     void setForceSkia(bool bSkia);
+    void setForceSkiaRaster(bool bSkia);
 
     void reset();
 };
@@ -213,6 +216,7 @@ void SkiaCfg::reset()
 {
     mbUseSkia = officecfg::Office::Common::VCL::UseSkia::get();
     mbForceSkia = officecfg::Office::Common::VCL::ForceSkia::get();
+    mbForceSkiaRaster = officecfg::Office::Common::VCL::ForceSkiaRaster::get();
     mbModified = false;
 }
 
@@ -227,6 +231,8 @@ SkiaCfg::~SkiaCfg()
                 officecfg::Office::Common::VCL::UseSkia::set(mbUseSkia, batch);
             if (!officecfg::Office::Common::VCL::ForceSkia::isReadOnly())
                 officecfg::Office::Common::VCL::ForceSkia::set(mbForceSkia, batch);
+            if (!officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly())
+                officecfg::Office::Common::VCL::ForceSkiaRaster::set(mbForceSkiaRaster, batch);
             batch->commit();
         }
         catch (...)
@@ -245,6 +251,11 @@ bool SkiaCfg::forceSkia() const
     return mbForceSkia;
 }
 
+bool SkiaCfg::forceSkiaRaster() const
+{
+    return mbForceSkiaRaster;
+}
+
 void SkiaCfg::setUseSkia(bool bSkia)
 {
     if (bSkia != mbUseSkia)
@@ -263,6 +274,15 @@ void SkiaCfg::setForceSkia(bool bSkia)
     }
 }
 
+void SkiaCfg::setForceSkiaRaster(bool bSkia)
+{
+    if (mbForceSkiaRaster != bSkia)
+    {
+        mbForceSkiaRaster = bSkia;
+        mbModified = true;
+    }
+}
+
 }
 
 // class OfaMiscTabPage --------------------------------------------------
@@ -759,6 +779,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
     , 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_xForceSkiaRaster(m_xBuilder->weld_check_button("forceskiaraster"))
     , m_xOpenGLStatusEnabled(m_xBuilder->weld_label("openglenabled"))
     , m_xOpenGLStatusDisabled(m_xBuilder->weld_label("opengldisabled"))
     , m_xSkiaStatusEnabled(m_xBuilder->weld_label("skiaenabled"))
@@ -774,6 +795,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
         m_xOpenGLStatusDisabled->hide();
         m_xUseSkia->hide();
         m_xForceSkia->hide();
+        m_xForceSkiaRaster->hide();
         m_xSkiaStatusEnabled->hide();
         m_xSkiaStatusDisabled->hide();
         m_xMenuIconBox->hide();
@@ -791,6 +813,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
 
     m_xForceOpenGL->connect_toggled(LINK(this, OfaViewTabPage, OnForceOpenGLToggled));
     m_xForceSkia->connect_toggled(LINK(this, OfaViewTabPage, OnForceSkiaToggled));
+    m_xForceSkiaRaster->connect_toggled(LINK(this, OfaViewTabPage, OnForceSkiaRasterToggled));
 
     // Set known icon themes
     OUString sAutoStr( m_xIconStyleLB->get_text( 0 ) );
@@ -825,6 +848,8 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
         m_xUseSkia->set_sensitive(false);
     if (officecfg::Office::Common::VCL::ForceSkia::isReadOnly())
         m_xForceSkia->set_sensitive(false);
+    if (officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly())
+        m_xForceSkiaRaster->set_sensitive(false);
 
     UpdateOGLStatus();
     UpdateSkiaStatus();
@@ -862,6 +887,15 @@ IMPL_LINK_NOARG(OfaViewTabPage, OnForceSkiaToggled, weld::ToggleButton&, void)
     }
 }
 
+IMPL_LINK_NOARG(OfaViewTabPage, OnForceSkiaRasterToggled, weld::ToggleButton&, void)
+{
+    if (m_xForceSkiaRaster->get_active())
+    {
+        // Forcing Skia raster 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);
@@ -1029,10 +1063,12 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
     }
 
     if (m_xUseSkia->get_state_changed_from_saved() ||
-        m_xForceSkia->get_state_changed_from_saved())
+        m_xForceSkia->get_state_changed_from_saved() ||
+        m_xForceSkiaRaster->get_state_changed_from_saved())
     {
         mpSkiaConfig->setUseSkia(m_xUseSkia->get_active());
         mpSkiaConfig->setForceSkia(m_xForceSkia->get_active());
+        mpSkiaConfig->setForceSkiaRaster(m_xForceSkiaRaster->get_active());
         bModified = true;
     }
 
@@ -1074,7 +1110,8 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
     }
 
     if (m_xUseSkia->get_state_changed_from_saved() ||
-        m_xForceSkia->get_state_changed_from_saved())
+        m_xForceSkia->get_state_changed_from_saved() ||
+        m_xForceSkiaRaster->get_state_changed_from_saved())
     {
         SolarMutexGuard aGuard;
         if( svtools::executeRestartDialog(
@@ -1191,6 +1228,7 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
     m_xForceOpenGL->set_active(mpOpenGLConfig->forceOpenGL());
     m_xUseSkia->set_active(mpSkiaConfig->useSkia());
     m_xForceSkia->set_active(mpSkiaConfig->forceSkia());
+    m_xForceSkiaRaster->set_active(mpSkiaConfig->forceSkiaRaster());
 
 #if defined( UNX )
     m_xFontAntiAliasing->save_state();
@@ -1202,6 +1240,7 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
     m_xForceOpenGL->save_state();
     m_xUseSkia->save_state();
     m_xForceSkia->save_state();
+    m_xForceSkiaRaster->save_state();
 
 #if defined( UNX )
     OnAntialiasingToggled(*m_xFontAntiAliasing);
diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 491b817c25a6..04988f8e57a4 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -117,6 +117,7 @@ private:
     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::CheckButton> m_xForceSkiaRaster;
 
     std::unique_ptr<weld::Label> m_xOpenGLStatusEnabled;
     std::unique_ptr<weld::Label> m_xOpenGLStatusDisabled;
@@ -131,6 +132,7 @@ private:
 #endif
     DECL_LINK(OnForceOpenGLToggled, weld::ToggleButton&, void);
     DECL_LINK(OnForceSkiaToggled, weld::ToggleButton&, void);
+    DECL_LINK(OnForceSkiaRasterToggled, weld::ToggleButton&, void);
     void UpdateOGLStatus();
     void UpdateSkiaStatus();
 
diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui
index 23fd4c4ee63e..a54e5865f7b2 100644
--- a/cui/uiconfig/ui/optviewpage.ui
+++ b/cui/uiconfig/ui/optviewpage.ui
@@ -598,6 +598,23 @@
                         <property name="top_attach">7</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkCheckButton" id="forceskiaraster">
+                        <property name="label" translatable="yes" context="optviewpage|forceskiaraster">Force Skia software rendering</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 will prevent the use of graphics drivers.</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">8</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkLabel" id="skiaenabled">
                         <property name="can_focus">False</property>
@@ -607,7 +624,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">8</property>
+                        <property name="top_attach">9</property>
                       </packing>
                     </child>
                     <child>
@@ -619,7 +636,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">9</property>
+                        <property name="top_attach">10</property>
                       </packing>
                     </child>
                   </object>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 0a880488324d..87839ae3cd9d 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -880,6 +880,14 @@
         </info>
         <value>false</value>
       </prop>
+      <prop oor:name="ForceSkiaRaster" 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 software rendering
+               instead of trying to use the graphics 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"
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 00eafbaf54c4..cdbb2c0b7977 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -77,6 +77,7 @@ static void checkDeviceBlacklisted()
                 break;
             }
             case RenderRaster:
+                SAL_INFO("vcl.skia", "Using Skia raster mode");
                 return; // software, never blacklisted
         }
         done = true;
@@ -160,6 +161,11 @@ static bool initRenderMethodToUse()
             return true;
         }
     }
+    if (officecfg::Office::Common::VCL::ForceSkiaRaster::get())
+    {
+        methodToUse = RenderRaster;
+        return true;
+    }
     methodToUse = RenderVulkan;
     return true;
 }
diff --git a/vcl/skia/zone.cxx b/vcl/skia/zone.cxx
index 82b45620ce1c..ae6d11d502f6 100644
--- a/vcl/skia/zone.cxx
+++ b/vcl/skia/zone.cxx
@@ -27,10 +27,11 @@ void SkiaZone::hardDisable()
     {
         bDisabled = true;
 
-        // Disable Skia support
+        // Instead of disabling Skia as a whole, only force the CPU-based
+        // raster mode, which should be safe as it does not use drivers.
         std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
             comphelper::ConfigurationChanges::create());
-        officecfg::Office::Common::VCL::UseSkia::set(false, xChanges);
+        officecfg::Office::Common::VCL::ForceSkiaRaster::set(true, xChanges);
         xChanges->commit();
 
         // Force synchronous config write


More information about the Libreoffice-commits mailing list