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