/src/qt/qtbase/src/gui/kernel/qsurfaceformat.h
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef QSURFACEFORMAT_H |
4 | | #define QSURFACEFORMAT_H |
5 | | |
6 | | #include <QtGui/qtguiglobal.h> |
7 | | #include <QtCore/qobjectdefs.h> |
8 | | |
9 | | QT_BEGIN_NAMESPACE |
10 | | |
11 | | class QColorSpace; |
12 | | class QOpenGLContext; |
13 | | class QSurfaceFormatPrivate; |
14 | | |
15 | | class Q_GUI_EXPORT QSurfaceFormat |
16 | | { |
17 | | Q_GADGET |
18 | | public: |
19 | | enum FormatOption { |
20 | | StereoBuffers = 0x0001, |
21 | | DebugContext = 0x0002, |
22 | | DeprecatedFunctions = 0x0004, |
23 | | ResetNotification = 0x0008, |
24 | | ProtectedContent = 0x0010 |
25 | | }; |
26 | | Q_ENUM(FormatOption) |
27 | | Q_DECLARE_FLAGS(FormatOptions, FormatOption) |
28 | | |
29 | | enum SwapBehavior { |
30 | | DefaultSwapBehavior, |
31 | | SingleBuffer, |
32 | | DoubleBuffer, |
33 | | TripleBuffer |
34 | | }; |
35 | | Q_ENUM(SwapBehavior) |
36 | | |
37 | | enum RenderableType { |
38 | | DefaultRenderableType = 0x0, |
39 | | OpenGL = 0x1, |
40 | | OpenGLES = 0x2, |
41 | | OpenVG = 0x4 |
42 | | }; |
43 | | Q_ENUM(RenderableType) |
44 | | |
45 | | enum OpenGLContextProfile { |
46 | | NoProfile, |
47 | | CoreProfile, |
48 | | CompatibilityProfile |
49 | | }; |
50 | | Q_ENUM(OpenGLContextProfile) |
51 | | |
52 | | #if QT_DEPRECATED_SINCE(6,0) |
53 | | enum ColorSpace { |
54 | | DefaultColorSpace, |
55 | | sRGBColorSpace |
56 | | }; |
57 | | Q_ENUM(ColorSpace) |
58 | | #endif |
59 | | |
60 | | enum ColorComponentType { |
61 | | FixedColorComponentType, |
62 | | FloatColorComponentType |
63 | | }; |
64 | | Q_ENUM(ColorComponentType) |
65 | | |
66 | | QSurfaceFormat(); |
67 | | Q_IMPLICIT QSurfaceFormat(FormatOptions options); |
68 | | QSurfaceFormat(const QSurfaceFormat &other); |
69 | | QSurfaceFormat &operator=(const QSurfaceFormat &other); |
70 | | ~QSurfaceFormat(); |
71 | | |
72 | | void setDepthBufferSize(int size); |
73 | | int depthBufferSize() const; |
74 | | |
75 | | void setStencilBufferSize(int size); |
76 | | int stencilBufferSize() const; |
77 | | |
78 | | void setRedBufferSize(int size); |
79 | | int redBufferSize() const; |
80 | | void setGreenBufferSize(int size); |
81 | | int greenBufferSize() const; |
82 | | void setBlueBufferSize(int size); |
83 | | int blueBufferSize() const; |
84 | | void setAlphaBufferSize(int size); |
85 | | int alphaBufferSize() const; |
86 | | |
87 | | void setColorComponentType(ColorComponentType type); |
88 | | ColorComponentType colorComponentType() const; |
89 | | |
90 | | void setSamples(int numSamples); |
91 | | int samples() const; |
92 | | |
93 | | void setSwapBehavior(SwapBehavior behavior); |
94 | | SwapBehavior swapBehavior() const; |
95 | | |
96 | | bool hasAlpha() const; |
97 | | |
98 | | void setProfile(OpenGLContextProfile profile); |
99 | | OpenGLContextProfile profile() const; |
100 | | |
101 | | void setRenderableType(RenderableType type); |
102 | | RenderableType renderableType() const; |
103 | | |
104 | | void setMajorVersion(int majorVersion); |
105 | | int majorVersion() const; |
106 | | |
107 | | void setMinorVersion(int minorVersion); |
108 | | int minorVersion() const; |
109 | | |
110 | | std::pair<int, int> version() const; |
111 | | void setVersion(int major, int minor); |
112 | | |
113 | | bool stereo() const; |
114 | | void setStereo(bool enable); |
115 | | |
116 | | void setOptions(QSurfaceFormat::FormatOptions options); |
117 | | void setOption(FormatOption option, bool on = true); |
118 | | bool testOption(FormatOption option) const; |
119 | | QSurfaceFormat::FormatOptions options() const; |
120 | | |
121 | | int swapInterval() const; |
122 | | void setSwapInterval(int interval); |
123 | | |
124 | | const QColorSpace &colorSpace() const; |
125 | | void setColorSpace(const QColorSpace &colorSpace); |
126 | | #if QT_DEPRECATED_SINCE(6,0) |
127 | | Q_DECL_DEPRECATED_X("Use setColorSpace(QColorSpace) instead.") |
128 | | void setColorSpace(ColorSpace colorSpace); |
129 | | #endif |
130 | | |
131 | | static void setDefaultFormat(const QSurfaceFormat &format); |
132 | | static QSurfaceFormat defaultFormat(); |
133 | | |
134 | | private: |
135 | | QSurfaceFormatPrivate *d; |
136 | | |
137 | | void detach(); |
138 | | bool equals(const QSurfaceFormat &other) const noexcept; |
139 | | |
140 | | friend inline bool operator==(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept |
141 | 0 | { return lhs.equals(rhs); } |
142 | | friend inline bool operator!=(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept |
143 | 0 | { return !lhs.equals(rhs); } |
144 | | #ifndef QT_NO_DEBUG_STREAM |
145 | | friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &); |
146 | | #endif |
147 | | }; |
148 | | |
149 | | #ifndef QT_NO_DEBUG_STREAM |
150 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &); |
151 | | #endif |
152 | | |
153 | | Q_DECLARE_OPERATORS_FOR_FLAGS(QSurfaceFormat::FormatOptions) |
154 | | |
155 | | inline bool QSurfaceFormat::stereo() const |
156 | 0 | { |
157 | 0 | return testOption(QSurfaceFormat::StereoBuffers); |
158 | 0 | } |
159 | | |
160 | | QT_END_NAMESPACE |
161 | | |
162 | | #endif //QSURFACEFORMAT_H |