remove isVCLOpenGLEnabled() settings, add DisableOpenGL option

The VCL OpenGL backend code has been removed, so the settings
for it no longer make sense.
But there's still the code for detecting if OpenGL is broken,
and that one makes sense to keep. It turns out other OpenGL code
(such as slideshows) doesn't even use that, so turn this into
a new DisableOpenGL option, make OpenGL-related failsafe code
set and use that, and OpenGL code should use
OpenGLHelper::supportsOpenGL() to make sure OpenGL use is not blocked.

Change-Id: Iec83f204e89bfb0b6eea13be77da8f0f4727a074
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107398
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
This commit is contained in:
Luboš Luňák
2020-12-09 11:46:47 +01:00
parent 8d6c51bc9c
commit 16e9375913
9 changed files with 26 additions and 130 deletions
@@ -14,6 +14,7 @@
#include <osl/mutex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/opengl/OpenGLHelper.hxx>
#include "ogl_canvascustomsprite.hxx"
#include "ogl_spritecanvas.hxx"
@@ -154,6 +155,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_rendering_SpriteCanvas_OGL_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
{
if( !OpenGLHelper::supportsOpenGL())
return nullptr;
auto p = new oglcanvas::SpriteCanvas(args, context);
cppu::acquire(p);
p->initialize();
+2 -4
View File
@@ -1902,12 +1902,10 @@ namespace comphelper
uno::Reference< XElement > xRootElement = xDocument->getDocumentElement();
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
"UseOpenGL", "false"));
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
"ForceOpenGL", "false"));
"DisableOpenGL", "true"));
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/Misc",
"UseOpenCL", "false"));
// Do not disable Skia entirely, just force it's CPU-based raster mode.
// Do not disable Skia entirely, just force its CPU-based raster mode.
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
"ForceSkia", "false"));
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
+4 -9
View File
@@ -21,7 +21,7 @@
/// Helper to do a SAL_INFO as well as a GL log.
#define VCL_GL_INFO(stream) \
do { \
if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \
if (SAL_DETAIL_ENABLE_LOG_INFO) \
{ \
::std::ostringstream detail_stream; \
detail_stream << stream; \
@@ -32,7 +32,7 @@
/// Helper to do a SAL_WARN as well as a GL log.
#define VCL_GL_WARN(stream) \
do { \
if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \
if (SAL_DETAIL_ENABLE_LOG_INFO) \
{ \
::std::ostringstream detail_stream; \
detail_stream << stream; \
@@ -105,14 +105,9 @@ public:
static bool isDeviceDenylisted();
/**
* checks if the system supports all features that are necessary for the OpenGL VCL support
* checks if the system supports all features that are necessary for the OpenGL support
*/
static bool supportsVCLOpenGL();
/**
* Returns true if VCL has OpenGL rendering enabled
*/
static bool isVCLOpenGLEnabled();
static bool supportsOpenGL();
};
#ifdef SAL_LOG_WARN
-7
View File
@@ -20,18 +20,11 @@ struct VCL_DLLPUBLIC OpenGLWrapper
{
OpenGLWrapper() = delete; // Should not be instantiated
/**
* Returns true if VCL has OpenGL rendering enabled
*/
#if HAVE_FEATURE_UI
static bool isVCLOpenGLEnabled();
/**
* Returns the number of times OpenGL buffers have been swapped.
*/
static sal_Int64 getBufferSwapCounter();
#else
static bool isVCLOpenGLEnabled() { return false; }
#endif
};
@@ -50,11 +50,6 @@
</prop>
</node>
<node oor:name="VCL">
<prop oor:name="UseOpenGL" oor:type="xs:boolean">
<value install:module="macosx">false</value>
<value install:module="unx">false</value>
<value install:module="wnt">false</value>
</prop>
<prop oor:name="UseSkia" oor:type="xs:boolean">
<value install:module="macosx">false</value>
<value install:module="unx">false</value>
@@ -850,18 +850,9 @@
<info>
<desc>Contains settings for VCL.</desc>
</info>
<prop oor:name="UseOpenGL" oor:type="xs:boolean" oor:nillable="false">
<prop oor:name="DisableOpenGL" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies if OpenGL rendering should be used in VCL backends
supporting it.</desc>
</info>
<value>false</value>
</prop>
<prop oor:name="ForceOpenGL" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies if OpenGL rendering should be used in VCL backends
supporting it. This one forces the use of OpenGL even if the
denylist would block the OpenGL driver.</desc>
<desc>Specifies if all OpenGL usage should be disabled.</desc>
</info>
<value>false</value>
</prop>
@@ -1179,6 +1179,8 @@ public:
// XTransitionFactory
virtual sal_Bool SAL_CALL hasTransition( sal_Int16 transitionType, sal_Int16 transitionSubType ) override
{
if( !OpenGLHelper::supportsOpenGL())
return false;
// A set of css::animation::TransitionSubType that don't have any meaning (in the SMIL 2.0
// standard) for MISCSHAPEWIPE have been chosen to refer to some of these "fancy" optional
// transitions. (The only subtypes of 'miscShapeWipe' defined in the standard are 'heart'
+3 -3
View File
@@ -19,6 +19,8 @@ VCL_DOUBLEBUFFERING_ENABLE - enable a safe subset of double buffered painting (c
VCL_DEBUG_DISABLE_PDFCOMPRESSION - disable compression in the PDF writer
SAL_DISABLE_WATCHDOG - don't start the thread that watches for broken GL/Vulkan/OpenCL drivers
Gtk+
----
VCL_GTK3_PAINTDEBUG - in debug builds, if set to 1 then holding down shift+0 forces a redraw event, shift+1 repaints everything, and
@@ -33,11 +35,9 @@ EMF_PLUS_DISABLE - use EMF rendering and ignore EMF+ specifics
OpenGL
------
SAL_FORCEGL - force enable OpenGL
SAL_DISABLEGL - disable OpenGL use
SAL_GL_NO_SWAP - disable buffer swapping if set (should show nothing)
SAL_GL_SLEEP_ON_SWAP - sleep for half a second on each swap-buffers.
SAL_DISABLE_WATCHDOG - don't start the thread that watches for broken GL/Vulkan/OpenCL drivers
SAL_DISABLE_GLYPH_CACHING - don't render glyphs through OpenGL textures or Skia surfaces
Skia
----
+10 -91
View File
@@ -784,12 +784,16 @@ bool OpenGLHelper::isDeviceDenylisted()
return bDenylisted;
}
bool OpenGLHelper::supportsVCLOpenGL()
bool OpenGLHelper::supportsOpenGL()
{
static bool bDisableGL = !!getenv("SAL_DISABLEGL");
bool bDenylisted = isDeviceDenylisted();
return !bDisableGL && !bDenylisted;
if( getenv("SAL_DISABLEGL") != nullptr )
return false;
if( isDeviceDenylisted())
return false;
if( officecfg::Office::Common::VCL::DisableOpenGL::get())
return false;
WatchdogThread::start();
return true;
}
namespace
@@ -853,7 +857,7 @@ void OpenGLZone::hardDisable()
// Disable the OpenGL support
std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::VCL::UseOpenGL::set(false, xChanges);
officecfg::Office::Common::VCL::DisableOpenGL::set(true, xChanges);
xChanges->commit();
// Force synchronous config write
@@ -884,91 +888,6 @@ const CrashWatchdogTimingsValues& OpenGLZone::getCrashWatchdogTimingsValues()
return gWatchdogTimings.getWatchdogTimingsValues(eMode);
}
static void reapGlxTest()
{
// Reap the glxtest child, or it'll stay around as a zombie,
// as X11OpenGLDeviceInfo::GetData() will not get called.
static bool bTestReaped = false;
if(!bTestReaped)
{
reap_glxtest_process();
bTestReaped = true;
}
}
bool OpenGLHelper::isVCLOpenGLEnabled()
{
// Skia always takes precedence if enabled
if( SkiaHelper::isVCLSkiaEnabled())
{
reapGlxTest();
return false;
}
/**
* The !bSet part should only be called once! Changing the results in the same
* run will mix OpenGL and normal rendering.
*/
static bool bSet = false;
static bool bEnable = false;
static bool bForceOpenGL = false;
// No hardware rendering, so no OpenGL
if (Application::IsBitmapRendering())
return false;
if (bSet)
{
return bForceOpenGL || bEnable;
}
/*
* There are a number of cases that these environment variables cover:
* * SAL_FORCEGL forces OpenGL independent of any other option
* * SAL_DISABLEGL or a denylisted driver avoid the use of OpenGL if SAL_FORCEGL is not set
*/
bSet = true;
bForceOpenGL = !!getenv("SAL_FORCEGL") || officecfg::Office::Common::VCL::ForceOpenGL::get();
bool bRet = false;
bool bSupportsVCLOpenGL = supportsVCLOpenGL();
// always call supportsVCLOpenGL to de-zombie the glxtest child process on X11
if (bForceOpenGL)
{
bRet = true;
}
else if (bSupportsVCLOpenGL)
{
static bool bEnableGLEnv = !!getenv("SAL_ENABLEGL");
bEnable = bEnableGLEnv;
if (officecfg::Office::Common::VCL::UseOpenGL::get())
bEnable = true;
// Force disable in safe mode
if (Application::IsSafeModeEnabled())
bEnable = false;
bRet = bEnable;
}
if (bRet)
WatchdogThread::start();
else
reapGlxTest();
CrashReporter::addKeyValue("UseOpenGL", OUString::boolean(bRet), CrashReporter::Write);
return bRet;
}
bool OpenGLWrapper::isVCLOpenGLEnabled()
{
return OpenGLHelper::isVCLOpenGLEnabled();
}
void OpenGLHelper::debugMsgStream(std::ostringstream const &pStream)
{
debugMsgPrint(