tdf#163340 replace list on paste
[LibreOffice.git] / vcl / skia / zone.cxx
blobf954173662fffb3129f96b8fb2cbe4e77b11cbe4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <skia/zone.hxx>
12 #include <officecfg/Office/Common.hxx>
13 #include <com/sun/star/util/XFlushable.hpp>
14 #include <com/sun/star/configuration/theDefaultProvider.hpp>
16 #include <sal/log.hxx>
17 #include <o3tl/unreachable.hxx>
19 #include <vcl/skia/SkiaHelper.hxx>
21 #include <config_skia.h>
23 using namespace SkiaHelper;
25 /**
26 * Called from a signal handler or watchdog thread if we get
27 * a crash or hang in some driver.
29 void SkiaZone::hardDisable()
31 // protect ourselves from double calling etc.
32 static bool bDisabled = false;
33 if (bDisabled)
34 return;
36 bDisabled = true;
38 // Instead of disabling Skia as a whole, only force the CPU-based
39 // raster mode, which should be safe as it does not use drivers.
40 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
41 comphelper::ConfigurationChanges::create());
42 officecfg::Office::Common::VCL::ForceSkiaRaster::set(true, xChanges);
43 xChanges->commit();
45 // Force synchronous config write
46 css::uno::Reference<css::util::XFlushable>(
47 css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()),
48 css::uno::UNO_QUERY_THROW)
49 ->flush();
52 void SkiaZone::checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues)
54 SAL_INFO("vcl.watchdog", "Skia watchdog - unchanged "
55 << nUnchanged << " enter count " << enterCount()
56 << " breakpoints mid: " << aTimingValues.mnDisableEntries
57 << " max " << aTimingValues.mnAbortAfter);
60 const CrashWatchdogTimingsValues& SkiaZone::getCrashWatchdogTimingsValues()
62 switch (renderMethodToUse())
64 case RenderVulkan:
65 case RenderMetal:
67 #if defined(SK_RELEASE)
68 static const CrashWatchdogTimingsValues gpuValues = { 6, 20 }; /* 1.5s, 5s */
69 #elif defined(SK_DEBUG)
70 static const CrashWatchdogTimingsValues gpuValues = { 60, 200 }; /* 15s, 50s */
71 #else
72 #error Unknown Skia debug/release setting.
73 #endif
74 return gpuValues;
76 case RenderRaster:
78 // CPU-based operations with large images may take a noticeably long time,
79 // so use large values. CPU-based rendering shouldn't use any unstable drivers anyway.
80 static const CrashWatchdogTimingsValues rasterValues = { 600, 2000 }; /* 150s, 500s */
81 return rasterValues;
84 O3TL_UNREACHABLE;
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */