1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qsgsoftwareadaptation_p.h" |
5 | #include "qsgsoftwarecontext_p.h" |
6 | #include "qsgsoftwarerenderloop_p.h" |
7 | #include "qsgsoftwarethreadedrenderloop_p.h" |
8 | |
9 | #include <private/qguiapplication_p.h> |
10 | #include <qpa/qplatformintegration.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | QSGSoftwareAdaptation::QSGSoftwareAdaptation(QObject *parent) |
15 | : QSGContextPlugin(parent) |
16 | { |
17 | } |
18 | |
19 | QStringList QSGSoftwareAdaptation::keys() const |
20 | { |
21 | return QStringList() << QLatin1String("software") << QLatin1String( "softwarecontext"); |
22 | } |
23 | |
24 | QSGContext *QSGSoftwareAdaptation::create(const QString &) const |
25 | { |
26 | if (!instance) |
27 | instance = new QSGSoftwareContext(); |
28 | return instance; |
29 | } |
30 | |
31 | QSGContextFactoryInterface::Flags QSGSoftwareAdaptation::flags(const QString &) const |
32 | { |
33 | // Claim we support adaptable shader effects, then return null for the |
34 | // shader effect node. The result is shader effects not being rendered, |
35 | // with the application working fine in all other respects. |
36 | return QSGContextFactoryInterface::SupportsShaderEffectNode; |
37 | } |
38 | |
39 | QSGRenderLoop *QSGSoftwareAdaptation::createWindowManager() |
40 | { |
41 | #if QT_CONFIG(thread) |
42 | static bool threaded = false; |
43 | static bool envChecked = false; |
44 | if (!envChecked) { |
45 | envChecked = true; |
46 | threaded = qgetenv(varName: "QSG_RENDER_LOOP") == "threaded"; |
47 | } |
48 | |
49 | if (threaded) |
50 | return new QSGSoftwareThreadedRenderLoop; |
51 | #endif |
52 | |
53 | return new QSGSoftwareRenderLoop(); |
54 | } |
55 | |
56 | QSGSoftwareContext *QSGSoftwareAdaptation::instance = nullptr; |
57 | |
58 | QT_END_NAMESPACE |
59 |