File indexing completed on 2024-05-19 05:31:53

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 #include <QDebug>
0011 #include <kwin_export.h>
0012 
0013 namespace KWin
0014 {
0015 
0016 class KWIN_EXPORT AbstractOpenGLContextAttributeBuilder
0017 {
0018 public:
0019     virtual ~AbstractOpenGLContextAttributeBuilder()
0020     {
0021     }
0022 
0023     void setVersion(int major, int minor = 0)
0024     {
0025         m_versionRequested = true;
0026         m_majorVersion = major;
0027         m_minorVersion = minor;
0028     }
0029 
0030     bool isVersionRequested() const
0031     {
0032         return m_versionRequested;
0033     }
0034 
0035     int majorVersion() const
0036     {
0037         return m_majorVersion;
0038     }
0039 
0040     int minorVersion() const
0041     {
0042         return m_minorVersion;
0043     }
0044 
0045     void setRobust(bool robust)
0046     {
0047         m_robust = robust;
0048     }
0049 
0050     bool isRobust() const
0051     {
0052         return m_robust;
0053     }
0054 
0055     void setForwardCompatible(bool forward)
0056     {
0057         m_forwardCompatible = forward;
0058     }
0059 
0060     bool isForwardCompatible() const
0061     {
0062         return m_forwardCompatible;
0063     }
0064 
0065     void setCoreProfile(bool core)
0066     {
0067         m_coreProfile = core;
0068         if (m_coreProfile) {
0069             setCompatibilityProfile(false);
0070         }
0071     }
0072 
0073     bool isCoreProfile() const
0074     {
0075         return m_coreProfile;
0076     }
0077 
0078     void setCompatibilityProfile(bool compatibility)
0079     {
0080         m_compatibilityProfile = compatibility;
0081         if (m_compatibilityProfile) {
0082             setCoreProfile(false);
0083         }
0084     }
0085 
0086     bool isCompatibilityProfile() const
0087     {
0088         return m_compatibilityProfile;
0089     }
0090 
0091     void setResetOnVideoMemoryPurge(bool reset)
0092     {
0093         m_resetOnVideoMemoryPurge = reset;
0094     }
0095 
0096     bool isResetOnVideoMemoryPurge() const
0097     {
0098         return m_resetOnVideoMemoryPurge;
0099     }
0100 
0101     void setHighPriority(bool highPriority)
0102     {
0103         m_highPriority = highPriority;
0104     }
0105 
0106     bool isHighPriority() const
0107     {
0108         return m_highPriority;
0109     }
0110 
0111     virtual std::vector<int> build() const = 0;
0112 
0113     QDebug operator<<(QDebug dbg) const;
0114 
0115 private:
0116     bool m_versionRequested = false;
0117     int m_majorVersion = 0;
0118     int m_minorVersion = 0;
0119     bool m_robust = false;
0120     bool m_forwardCompatible = false;
0121     bool m_coreProfile = false;
0122     bool m_compatibilityProfile = false;
0123     bool m_resetOnVideoMemoryPurge = false;
0124     bool m_highPriority = false;
0125 };
0126 
0127 inline QDebug operator<<(QDebug dbg, const AbstractOpenGLContextAttributeBuilder *attribs)
0128 {
0129     return attribs->operator<<(dbg);
0130 }
0131 
0132 }