From 16e93759134a05a52ef218c4a5ce0f3ea67b0221 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 8 Dec 2020 10:44:52 +0100 Subject: remove isVCLOpenGLEnabled() settings, add DisableOpenGL option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- canvas/source/opengl/ogl_spritecanvas.cxx | 3 + comphelper/source/misc/backupfilehelper.cxx | 6 +- include/vcl/opengl/OpenGLHelper.hxx | 13 +-- include/vcl/opengl/OpenGLWrapper.hxx | 7 -- .../registry/data/org/openoffice/Office/Common.xcu | 5 - .../schema/org/openoffice/Office/Common.xcs | 13 +-- .../source/engine/opengl/TransitionerImpl.cxx | 2 + vcl/README.vars | 6 +- vcl/source/opengl/OpenGLHelper.cxx | 101 ++------------------- 9 files changed, 26 insertions(+), 130 deletions(-) diff --git a/canvas/source/opengl/ogl_spritecanvas.cxx b/canvas/source/opengl/ogl_spritecanvas.cxx index de5caf716778..d55625b47668 100644 --- a/canvas/source/opengl/ogl_spritecanvas.cxx +++ b/canvas/source/opengl/ogl_spritecanvas.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #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 const& args) { + if( !OpenGLHelper::supportsOpenGL()) + return nullptr; auto p = new oglcanvas::SpriteCanvas(args, context); cppu::acquire(p); p->initialize(); diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index d07442b8f39c..fcde7879255b 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -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", diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx index f4742d268b49..a0e2d8436564 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -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 diff --git a/include/vcl/opengl/OpenGLWrapper.hxx b/include/vcl/opengl/OpenGLWrapper.hxx index 23237804e79b..3711b3fd4ba2 100644 --- a/include/vcl/opengl/OpenGLWrapper.hxx +++ b/include/vcl/opengl/OpenGLWrapper.hxx @@ -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 }; diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index e4c3fca51f7e..cb53de0292a5 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -50,11 +50,6 @@ - - false - false - false - false false diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 02e62d950ed2..2f961f0532a2 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -850,18 +850,9 @@ Contains settings for VCL. - + - Specifies if OpenGL rendering should be used in VCL backends - supporting it. - - false - - - - 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. + Specifies if all OpenGL usage should be disabled. false diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index 41a95994062e..3565e6ef104e 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -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' diff --git a/vcl/README.vars b/vcl/README.vars index 68361ce78d77..4b2e326d67ef 100644 --- a/vcl/README.vars +++ b/vcl/README.vars @@ -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 ---- diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index fce2ac1afb11..90786adfd5ec 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -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 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( -- cgit