summaryrefslogtreecommitdiff
path: root/vcl/skia/SkiaHelper.cxx
blob: 278d19bd8d525bba15603be63aa6dc122c1c4f89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <vcl/skia/SkiaHelper.hxx>

#include <vcl/svapp.hxx>

#include <config_features.h>

#if !HAVE_FEATURE_SKIA
bool SkiaHelper::isVCLSkiaEnabled() { return false; }

#else

static bool supportsVCLSkia()
{
    static bool bDisableSkia = !!getenv("SAL_DISABLESKIA");
    bool bBlacklisted = false; // TODO isDeviceBlacklisted();

    return !bDisableSkia && !bBlacklisted;
}

bool SkiaHelper::isVCLSkiaEnabled()
{
    /**
     * The !bSet part should only be called once! Changing the results in the same
     * run will mix Skia and normal rendering.
     */

    static bool bSet = false;
    static bool bEnable = false;
    static bool bForceSkia = false;

    // No hardware rendering, so no Skia
    // TODO SKIA
    if (Application::IsBitmapRendering())
        return false;

    if (bSet)
    {
        return bForceSkia || bEnable;
    }

    /*
     * There are a number of cases that these environment variables cover:
     *  * SAL_FORCESKIA forces Skia independent of any other option
     *  * SAL_DISABLESKIA avoids the use of Skia if SAL_FORCESKIA is not set
     */

    bSet = true;
    bForceSkia = !!getenv(
        "SAL_FORCESKIA"); // TODO SKIA || officecfg::Office::Common::VCL::ForceOpenGL::get();

    bool bRet = false;
    bool bSupportsVCLSkia = supportsVCLSkia();
    // TODO SKIA always call supportsVCLOpenGL to de-zombie the glxtest child process on X11
    if (bForceSkia)
    {
        bRet = true;
    }
    else if (bSupportsVCLSkia)
    {
        static bool bEnableSkiaEnv = !!getenv("SAL_ENABLESKIA");

        bEnable = bEnableSkiaEnv;

        // TODO SKIA        if (officecfg::Office::Common::VCL::UseOpenGL::get())

        // Force disable in safe mode
        if (Application::IsSafeModeEnabled())
            bEnable = false;

        bRet = bEnable;
    }

    // TODO SKIA    CrashReporter::AddKeyValue("UseOpenGL", OUString::boolean(bRet));

    return bRet;
}

#endif // HAVE_FEATURE_SKIA

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
r format of hyperlinksMiklos Vajna 2017-09-25EPUB export: don't leak when exceptions are thrownMiklos Vajna 2017-09-08EPUB export: inherit text properties in spans from paragraphMiklos Vajna 2017-09-08EPUB export: fix double escaped NBSPMiklos Vajna 2017-09-07EPUB export: handle span-level line breakMiklos Vajna 2017-09-07EPUB export: handle line breakMiklos Vajna 2017-09-07EPUB export: handle nested spansMiklos Vajna 2017-09-06EPUB export: handle style parents for named stylesMiklos Vajna 2017-09-06EPUB export: pull out FillStyle() from XMLSpan/ParaContextMiklos Vajna 2017-09-06EPUB export: handle text properties from text stylesMiklos Vajna 2017-09-05EPUB export: handle text properties from paragraph stylesMiklos Vajna 2017-09-05EPUB export: handle paragraph properties from paragraph stylesMiklos Vajna 2017-08-30EPUB export: support char props on text outside a spanMiklos Vajna 2017-08-29EPUB export: initial character properties as direct formattingMiklos Vajna 2017-08-25EPUB export: add support for page breaksMiklos Vajna 2017-08-17EPUB export: handle inline imagesMiklos Vajna 2017-08-17EPUB export: implement link supportMiklos Vajna 2017-08-15EPUB export: initial index supportMiklos Vajna 2017-08-15EPUB export: initial span supportMiklos Vajna 2017-08-11EPUB export: rework to use context classesMiklos Vajna