Krita Source Code Documentation
Loading...
Searching...
No Matches
KisOpenGLModeProber.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Alvin Wong <alvinhochun@gmail.com>
3 * SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
4 * SPDX-FileCopyrightText: 2023 L. E. Segovia <amy@amyspark.me>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KISOPENGLMODEPROBER_H
10#define KISOPENGLMODEPROBER_H
11
12#include "kritaui_export.h"
13#include "kis_config.h"
14#include <QSurfaceFormat>
15#include <boost/optional.hpp>
16#include "kis_opengl.h"
17
18class KoColorProfile;
20
21class KRITAUI_EXPORT KisOpenGLModeProber
22{
23public:
24 class Result;
25
26public:
29
31
32 bool useHDRMode() const;
33 QSurfaceFormat surfaceformatInUse() const;
34
35 const KoColorProfile *rootSurfaceColorProfile() const;
36
37 boost::optional<Result> probeFormat(const KisOpenGL::RendererConfig &rendererConfig,
38 bool adjustGlobalState = true);
39 static bool fuzzyCompareColorSpaces(const KisSurfaceColorSpaceWrapper &lhs,
41 static QString angleRendererToString(KisOpenGL::AngleRenderer renderer);
42
43public:
44 static void initSurfaceFormatFromConfig(std::pair<KisSurfaceColorSpaceWrapper, int> rootSurfaceFormat,
45 QSurfaceFormat *format);
46 static bool isFormatHDR(const QSurfaceFormat &format);
47};
48
50public:
51 Result(QOpenGLContext &context);
52
53 int glMajorVersion() const {
54 return m_glMajorVersion;
55 }
56
57 int glMinorVersion() const {
58 return m_glMinorVersion;
59 }
60
64
65 bool isOpenGLES() const {
66 return m_isOpenGLES;
67 }
68
69 QString rendererString() const {
70 return m_rendererString;
71 }
72
73 QString driverVersionString() const {
75 }
76
77 bool isSupportedVersion() const {
78 // Technically we could support GLES2 (I added the extensions for
79 // floating point surfaces). But given that Dmitry required VAOs
80 // on GLES, I've kept the check mostly as-is.
81 // Note:
82 // - we've not supported OpenGL 2.1 for a Long time (commit e0d9a4feba0d4b5e70dddece8b76f38a6043fc88)
83 return (m_isOpenGLES && m_glMajorVersion >= 3) || ((m_glMajorVersion * 100 + m_glMinorVersion) >= 303);
84 }
85
86 bool supportsLoD() const {
87 return m_supportsLod;
88 }
89
90 bool supportsVAO() const {
101 return (m_glMajorVersion * 100 + m_glMinorVersion) >= 300;
102 }
103
104 bool hasOpenGL3() const {
105 return (m_glMajorVersion * 100 + m_glMinorVersion) >= 302;
106 }
107
108 bool supportsFenceSync() const {
109 return m_glMajorVersion >= 3;
110 }
111
112 bool supportsFBO() const {
113 return m_supportsFBO;
114 }
115
118 }
119
123
124#ifdef Q_OS_WIN
125 // This is only for detecting whether ANGLE is being used.
126 // For detecting generic OpenGL ES please check isOpenGLES
127 bool isUsingAngle() const {
128 return m_rendererString.startsWith("ANGLE", Qt::CaseInsensitive);
129 }
130#endif
131
132 QString shadingLanguageString() const
133 {
135 }
136
137 QString vendorString() const
138 {
139 return m_vendorString;
140 }
141
142 QSurfaceFormat format() const
143 {
144 return m_format;
145 }
146
147 QSet<QByteArray> extensions() const
148 {
149 return m_extensions;
150 }
151
152private:
156 bool m_isOpenGLES = false;
157 bool m_supportsFBO = false;
160 bool m_supportsLod = false;
165 QSurfaceFormat m_format;
166 QSet<QByteArray> m_extensions;
167};
168
169#endif // KISOPENGLMODEPROBER_H
PythonPluginManager * instance
QSet< QByteArray > extensions() const
Result(QOpenGLContext &context)
QSurfaceFormat format() const