Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:10:21

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