Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:08:16

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 #ifndef QSURFACEFORMAT_H
0004 #define QSURFACEFORMAT_H
0005 
0006 #include <QtGui/qtguiglobal.h>
0007 #include <QtCore/qpair.h>
0008 #include <QtCore/qobjectdefs.h>
0009 
0010 QT_BEGIN_NAMESPACE
0011 
0012 class QColorSpace;
0013 class QOpenGLContext;
0014 class QSurfaceFormatPrivate;
0015 
0016 class Q_GUI_EXPORT QSurfaceFormat
0017 {
0018     Q_GADGET
0019 public:
0020     enum FormatOption {
0021         StereoBuffers            = 0x0001,
0022         DebugContext             = 0x0002,
0023         DeprecatedFunctions      = 0x0004,
0024         ResetNotification        = 0x0008,
0025         ProtectedContent         = 0x0010
0026     };
0027     Q_ENUM(FormatOption)
0028     Q_DECLARE_FLAGS(FormatOptions, FormatOption)
0029 
0030     enum SwapBehavior {
0031         DefaultSwapBehavior,
0032         SingleBuffer,
0033         DoubleBuffer,
0034         TripleBuffer
0035     };
0036     Q_ENUM(SwapBehavior)
0037 
0038     enum RenderableType {
0039         DefaultRenderableType = 0x0,
0040         OpenGL                = 0x1,
0041         OpenGLES              = 0x2,
0042         OpenVG                = 0x4
0043     };
0044     Q_ENUM(RenderableType)
0045 
0046     enum OpenGLContextProfile {
0047         NoProfile,
0048         CoreProfile,
0049         CompatibilityProfile
0050     };
0051     Q_ENUM(OpenGLContextProfile)
0052 
0053 #if QT_DEPRECATED_SINCE(6,0)
0054     enum ColorSpace {
0055         DefaultColorSpace,
0056         sRGBColorSpace
0057     };
0058     Q_ENUM(ColorSpace)
0059 #endif
0060 
0061     QSurfaceFormat();
0062     Q_IMPLICIT QSurfaceFormat(FormatOptions options);
0063     QSurfaceFormat(const QSurfaceFormat &other);
0064     QSurfaceFormat &operator=(const QSurfaceFormat &other);
0065     ~QSurfaceFormat();
0066 
0067     void setDepthBufferSize(int size);
0068     int depthBufferSize() const;
0069 
0070     void setStencilBufferSize(int size);
0071     int stencilBufferSize() const;
0072 
0073     void setRedBufferSize(int size);
0074     int redBufferSize() const;
0075     void setGreenBufferSize(int size);
0076     int greenBufferSize() const;
0077     void setBlueBufferSize(int size);
0078     int blueBufferSize() const;
0079     void setAlphaBufferSize(int size);
0080     int alphaBufferSize() const;
0081 
0082     void setSamples(int numSamples);
0083     int samples() const;
0084 
0085     void setSwapBehavior(SwapBehavior behavior);
0086     SwapBehavior swapBehavior() const;
0087 
0088     bool hasAlpha() const;
0089 
0090     void setProfile(OpenGLContextProfile profile);
0091     OpenGLContextProfile profile() const;
0092 
0093     void setRenderableType(RenderableType type);
0094     RenderableType renderableType() const;
0095 
0096     void setMajorVersion(int majorVersion);
0097     int majorVersion() const;
0098 
0099     void setMinorVersion(int minorVersion);
0100     int minorVersion() const;
0101 
0102     QPair<int, int> version() const;
0103     void setVersion(int major, int minor);
0104 
0105     bool stereo() const;
0106     void setStereo(bool enable);
0107 
0108     void setOptions(QSurfaceFormat::FormatOptions options);
0109     void setOption(FormatOption option, bool on = true);
0110     bool testOption(FormatOption option) const;
0111     QSurfaceFormat::FormatOptions options() const;
0112 
0113     int swapInterval() const;
0114     void setSwapInterval(int interval);
0115 
0116     const QColorSpace &colorSpace() const;
0117     void setColorSpace(const QColorSpace &colorSpace);
0118 #if QT_DEPRECATED_SINCE(6,0)
0119     Q_DECL_DEPRECATED_X("Use setColorSpace(QColorSpace) instead.")
0120     void setColorSpace(ColorSpace colorSpace);
0121 #endif
0122 
0123     static void setDefaultFormat(const QSurfaceFormat &format);
0124     static QSurfaceFormat defaultFormat();
0125 
0126 private:
0127     QSurfaceFormatPrivate *d;
0128 
0129     void detach();
0130     bool equals(const QSurfaceFormat &other) const noexcept;
0131 
0132     friend inline bool operator==(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept
0133     { return lhs.equals(rhs); }
0134     friend inline bool operator!=(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept
0135     { return !lhs.equals(rhs); }
0136 #ifndef QT_NO_DEBUG_STREAM
0137     friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
0138 #endif
0139 };
0140 
0141 #ifndef QT_NO_DEBUG_STREAM
0142 Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
0143 #endif
0144 
0145 Q_DECLARE_OPERATORS_FOR_FLAGS(QSurfaceFormat::FormatOptions)
0146 
0147 inline bool QSurfaceFormat::stereo() const
0148 {
0149     return testOption(QSurfaceFormat::StereoBuffers);
0150 }
0151 
0152 QT_END_NAMESPACE
0153 
0154 #endif //QSURFACEFORMAT_H