[Libreoffice-commits] core.git: Branch 'feature/skia' - 4 commits - cui/source cui/uiconfig include/svtools officecfg/registry solenv/sanitizers svtools/source svtools/uiconfig vcl/inc vcl/skia vcl/source
Luboš Luňák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 22 09:54:18 UTC 2019
cui/source/options/optgdlg.cxx | 139 +++++++++++++
cui/source/options/optgdlg.hxx | 8
cui/uiconfig/ui/optviewpage.ui | 56 +++++
include/svtools/restartdialog.hxx | 3
officecfg/registry/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/skia/gdiimpl.hxx | 11 +
vcl/inc/strings.hrc | 1
vcl/skia/SkiaHelper.cxx | 10
vcl/skia/gdiimpl.cxx | 40 ++-
vcl/skia/win/gdiimpl.cxx | 24 +-
vcl/skia/x11/gdiimpl.cxx | 15 +
vcl/source/app/svapp.cxx | 5
15 files changed, 322 insertions(+), 24 deletions(-)
New commits:
commit 727a67beda83a7073a66cd6bdf03f6d0f5de1aaa
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 22 11:48:08 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Oct 22 11:53:08 2019 +0200
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
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index fb320a25c289..185603f38e41 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>
@@ -170,6 +171,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 --------------------------------------------------
@@ -505,6 +586,7 @@ CanvasSettings::CanvasSettings() :
bool CanvasSettings::IsHardwareAccelerationAvailable() const
{
#if HAVE_FEATURE_OPENGL
+// TODO SKIA
if (OpenGLWrapper::isVCLOpenGLEnabled() && Application::GetToolkitName() != "gtk3")
mbHWAccelAvailable = false;
@@ -609,6 +691,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"))
@@ -624,8 +707,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"))
{
@@ -635,6 +722,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();
}
@@ -649,6 +740,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 ) );
@@ -679,8 +771,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()
@@ -706,6 +803,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);
@@ -880,6 +986,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
@@ -917,6 +1031,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;
}
@@ -924,6 +1048,7 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
{
SvtMiscOptions aMiscOptions;
mpOpenGLConfig->reset();
+ mpSkiaConfig->reset();
if (aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO)
{
@@ -1022,6 +1147,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();
@@ -1031,6 +1158,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);
@@ -1051,6 +1180,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 33029f1acb4a..7fe333eefeea 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
@@ -83,6 +84,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;
@@ -106,9 +108,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;
@@ -117,7 +123,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 c72eaab3eb09..0159d639b0ea 100644
--- a/cui/uiconfig/ui/optviewpage.ui
+++ b/cui/uiconfig/ui/optviewpage.ui
@@ -125,6 +125,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>
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 0fd0786a77a9..f5a746a6ab6b 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -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"
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 @@
<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>
diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index c561de71c369..65e829648f23 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -126,6 +126,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 <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;
}
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 0b87e0cb3687..3de5548a274e 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -50,6 +50,7 @@
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLWrapper.hxx>
#endif
+#include <vcl/skia/SkiaHelper.hxx>
#include <salinst.hxx>
#include <salframe.hxx>
@@ -1148,12 +1149,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( "; " );
commit d904179eaf436ad7d2ed2eec347d0d1e9f668a9c
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 22 10:51:09 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Oct 22 11:52:35 2019 +0200
make Skia use either Raster or Vulkan, depending on a setting
For now default to raster, SAL_SKIA=vk switches to Vulkan.
Change-Id: Ia0f3ffdd4367eac9871aa977c930c1e6029e1d25
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index af12c994d462..35106dba2ca7 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -219,6 +219,14 @@ protected:
void drawMask(const SalTwoRect& rPosAry, const SkBitmap& rBitmap, Color nMaskColor);
+ // Which Skia backend to use.
+ enum RenderMethod
+ {
+ RenderRaster,
+ RenderVulkan
+ };
+ static RenderMethod renderMethodToUse();
+
SalGraphics& mParent;
/// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mProvider;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f17800402818..07a59c9a7ef8 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -103,6 +103,20 @@ public:
}
};
+SkiaSalGraphicsImpl::RenderMethod SkiaSalGraphicsImpl::renderMethodToUse()
+{
+ static RenderMethod method = [] {
+ if (const char* env = getenv("SAL_SKIA"))
+ { // TODO switch the default later
+ if (strcmp(env, "vk") == 0 || strcmp(env, "vulkan") == 0)
+ return RenderVulkan;
+ }
+ return RenderRaster;
+ }();
+
+ return method;
+}
+
SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvider* pProvider)
: mParent(rParent)
, mProvider(pProvider)
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index c597b89b657e..92af2fcad42f 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -54,8 +54,17 @@ void WinSkiaSalGraphicsImpl::createSurface()
// valid here, but better check.
assert(GetWidth() != 0 && GetHeight() != 0);
sk_app::DisplayParams displayParams;
- mWindowContext
- = sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(), displayParams);
+ switch (renderMethodToUse())
+ {
+ case RenderRaster:
+ mWindowContext = sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(),
+ displayParams);
+ break;
+ case RenderVulkan:
+ mWindowContext = sk_app::window_context_factory::MakeVulkanForWin(mWinParent.gethWnd(),
+ displayParams);
+ break;
+ }
assert(SkToBool(mWindowContext)); // TODO
mSurface = mWindowContext->getBackbufferSurface();
assert(mSurface.get());
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 8521a8fd01ad..36dc8d5ecf13 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -59,7 +59,17 @@ void X11SkiaSalGraphicsImpl::createSurface()
winInfo.fVisualInfo = const_cast<SalVisual*>(&mParent.GetVisual());
winInfo.fWidth = GetWidth();
winInfo.fHeight = GetHeight();
- mWindowContext = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
+ switch (renderMethodToUse())
+ {
+ case RenderRaster:
+ mWindowContext
+ = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
+ break;
+ case RenderVulkan:
+ mWindowContext
+ = sk_app::window_context_factory::MakeVulkanForXlib(winInfo, displayParams);
+ break;
+ }
assert(SkToBool(mWindowContext)); // TODO
mSurface = mWindowContext->getBackbufferSurface();
assert(mSurface.get());
commit 0a3d1dae9ffbed27d2fbc6a2c57e6c8d283917ae
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 22 10:32:01 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Oct 22 11:51:58 2019 +0200
delete Skia WindowContext only after the SkSurface it has created
Because the context deletes memory that is accessed while the surface
is being destroyed.
Change-Id: I6f73baeb604e9ac79d6dd7eb2137791666a64712
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 1ae659e4f3d8..c597b89b657e 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -63,8 +63,8 @@ void WinSkiaSalGraphicsImpl::createSurface()
void WinSkiaSalGraphicsImpl::DeInit()
{
- mWindowContext.reset();
SkiaSalGraphicsImpl::DeInit();
+ mWindowContext.reset();
}
void WinSkiaSalGraphicsImpl::freeResources() {}
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index d84d3235342d..8521a8fd01ad 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -67,8 +67,8 @@ void X11SkiaSalGraphicsImpl::createSurface()
void X11SkiaSalGraphicsImpl::DeInit()
{
- mWindowContext.reset();
SkiaSalGraphicsImpl::DeInit();
+ mWindowContext.reset();
}
void X11SkiaSalGraphicsImpl::freeResources() {}
commit a39e5291e265a19297441806912fc6802f146aeb
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Oct 22 10:10:24 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Oct 22 11:51:51 2019 +0200
allocate Skia SkSurface on demand
Since VCL seems to often do a resize between creating
the SkiaSalGraphicsImpl and actually starting to draw, it's a waste
to create a surface that will be immediately destroyed again.
Change-Id: Ic1f67701042ccae2ad51cb9a3f8646b888f94cc4
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index 463e927c3572..af12c994d462 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -197,6 +197,9 @@ protected:
void postDraw();
virtual void createSurface();
+ // Call to ensure that mSurface is valid. If mSurface is going to be modified,
+ // use preDraw() instead of this.
+ void checkSurface();
void resetSurface();
void setProvider(SalGeometryProvider* provider) { mProvider = provider; }
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ccf4ea7cef34..f17800402818 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -114,7 +114,7 @@ SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvid
SkiaSalGraphicsImpl::~SkiaSalGraphicsImpl() {}
-void SkiaSalGraphicsImpl::Init() { resetSurface(); }
+void SkiaSalGraphicsImpl::Init() {}
void SkiaSalGraphicsImpl::resetSurface()
{
@@ -129,18 +129,14 @@ void SkiaSalGraphicsImpl::resetSurface()
void SkiaSalGraphicsImpl::createSurface()
{
- // TODO
+ // Create surface for offscreen graphics. Subclasses will create GPU-backed
+ // surfaces as appropriate.
mSurface = SkSurface::MakeRasterN32Premul(GetWidth(), GetHeight());
}
void SkiaSalGraphicsImpl::DeInit() { mSurface.reset(); }
-void SkiaSalGraphicsImpl::preDraw()
-{
- // VCL can sometimes resize us without telling us, update the surface if needed.
- if (GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
- resetSurface();
-}
+void SkiaSalGraphicsImpl::preDraw() { checkSurface(); }
void SkiaSalGraphicsImpl::postDraw()
{
@@ -153,6 +149,15 @@ void SkiaSalGraphicsImpl::postDraw()
}
}
+// VCL can sometimes resize us without telling us, update the surface if needed.
+// Also create the surface on demand if it has not been created yet (it is a waste
+// to create it in Init() if it gets recreated later anyway).
+void SkiaSalGraphicsImpl::checkSurface()
+{
+ if (!mSurface || GetWidth() != mSurface->width() || GetHeight() != mSurface->height())
+ resetSurface();
+}
+
static SkIRect toSkIRect(const tools::Rectangle& rectangle)
{
return SkIRect::MakeXYWH(rectangle.Left(), rectangle.Top(), rectangle.GetWidth(),
@@ -182,6 +187,7 @@ bool SkiaSalGraphicsImpl::setClipRegion(const vcl::Region& region)
if (mClipRegion == region)
return true;
mClipRegion = region;
+ checkSurface();
SkCanvas* canvas = mSurface->getCanvas();
// SkCanvas::clipRegion() can only further reduce the clip region,
// but we need to set the given region, which may extend it.
@@ -436,6 +442,7 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG
}
else
src = this;
+ src->checkSurface();
sk_sp<SkImage> image = src->mSurface->makeImageSnapshot(
SkIRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight));
// TODO makeNonTextureImage() ?
@@ -522,6 +529,7 @@ void SkiaSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry, const SkBitmap& rB
std::shared_ptr<SalBitmap> SkiaSalGraphicsImpl::getBitmap(long nX, long nY, long nWidth,
long nHeight)
{
+ checkSurface();
mSurface->getCanvas()->flush();
sk_sp<SkImage> image = mSurface->makeImageSnapshot(SkIRect::MakeXYWH(nX, nY, nWidth, nHeight));
return std::make_shared<SkiaSalBitmap>(*image);
@@ -529,6 +537,7 @@ std::shared_ptr<SalBitmap> SkiaSalGraphicsImpl::getBitmap(long nX, long nY, long
Color SkiaSalGraphicsImpl::getPixel(long nX, long nY)
{
+ checkSurface();
mSurface->getCanvas()->flush();
// TODO this is presumably slow, and possibly won't work with GPU surfaces
SkBitmap bitmap;
@@ -704,6 +713,7 @@ bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolygon,
#ifdef DBG_UTIL
void SkiaSalGraphicsImpl::dump(const char* file) const
{
+ assert(mSurface.get());
mSurface->getCanvas()->flush();
sk_sp<SkImage> image = mSurface->makeImageSnapshot();
sk_sp<SkData> data = image->encodeToData();
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 7af4f6790a61..1ae659e4f3d8 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -49,13 +49,10 @@ void WinSkiaSalGraphicsImpl::createSurface()
{
if (isOffscreen())
return SkiaSalGraphicsImpl::createSurface();
- if (GetWidth() == 0 || GetHeight() == 0)
- {
- // When created, Init() gets called with size (0,0), which is invalid size
- // for Skia. So fake a surface, Init() will get called later again with the correct size.
- mSurface = SkSurface::MakeRasterN32Premul(1, 1);
- return;
- }
+ // When created, Init() gets called with size (0,0), which is invalid size
+ // for Skia. Creating the actual surface is delayed, so the size should be always
+ // valid here, but better check.
+ assert(GetWidth() != 0 && GetHeight() != 0);
sk_app::DisplayParams displayParams;
mWindowContext
= sk_app::window_context_factory::MakeRasterForWin(mWinParent.gethWnd(), displayParams);
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index cdb9a655f758..d84d3235342d 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -62,6 +62,7 @@ void X11SkiaSalGraphicsImpl::createSurface()
mWindowContext = sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
assert(SkToBool(mWindowContext)); // TODO
mSurface = mWindowContext->getBackbufferSurface();
+ assert(mSurface.get());
}
void X11SkiaSalGraphicsImpl::DeInit()
More information about the Libreoffice-commits
mailing list