diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-14 17:30:59 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-15 01:41:13 +0200 |
commit | 9815ebf24b5aa148a416ee3b159088f0092d2715 (patch) | |
tree | b86cf5ddb2ddebe72d6f4ae5040e77342fa459e7 /src/gui/kernel | |
parent | fce84f76f04957e51f1d92129236733d9bf7d08a (diff) |
Switch QSurfaceFormat::colorSpace to a QColorSpace
Allows more flexibility in the future.
Change-Id: Idcf2d8ddaee268a7b5d55379ccb42dd9b3c33abf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 31 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.h | 10 |
2 files changed, 34 insertions, 7 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index c3048518da..366e68ebe3 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -42,6 +42,7 @@ #include <QtCore/qatomic.h> #include <QtCore/QDebug> #include <QOpenGLContext> +#include <QtGui/qcolorspace.h> #include <QtGui/qguiapplication.h> #ifdef major @@ -73,7 +74,6 @@ public: , major(2) , minor(0) , swapInterval(1) // default to vsync - , colorSpace(QSurfaceFormat::DefaultColorSpace) { } @@ -112,7 +112,7 @@ public: int major; int minor; int swapInterval; - QSurfaceFormat::ColorSpace colorSpace; + QColorSpace colorSpace; }; /*! @@ -732,11 +732,11 @@ int QSurfaceFormat::swapInterval() const blending to be performed in the given color space instead of using the standard linear operations. - \since 5.10 + \since 6.0 \sa colorSpace() */ -void QSurfaceFormat::setColorSpace(ColorSpace colorSpace) +void QSurfaceFormat::setColorSpace(const QColorSpace &colorSpace) { if (d->colorSpace != colorSpace) { detach(); @@ -745,13 +745,34 @@ void QSurfaceFormat::setColorSpace(ColorSpace colorSpace) } /*! + \overload + + Sets the colorspace to one of the predefined values. + + \since 5.10 + + \sa colorSpace() + */ +void QSurfaceFormat::setColorSpace(ColorSpace colorSpace) +{ + switch (colorSpace) { + case DefaultColorSpace: + setColorSpace(QColorSpace()); + break; + case sRGBColorSpace: + setColorSpace(QColorSpace::SRgb); + break; + } +} + +/*! \return the color space. \since 5.10 \sa setColorSpace() */ -QSurfaceFormat::ColorSpace QSurfaceFormat::colorSpace() const +const QColorSpace &QSurfaceFormat::colorSpace() const { return d->colorSpace; } diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index fce3c49136..20d666b4b8 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE - +class QColorSpace; class QOpenGLContext; class QSurfaceFormatPrivate; @@ -85,11 +85,13 @@ public: }; Q_ENUM(OpenGLContextProfile) +#if QT_DEPRECATED_SINCE(6,0) enum ColorSpace { DefaultColorSpace, sRGBColorSpace }; Q_ENUM(ColorSpace) +#endif QSurfaceFormat(); /*implicit*/ QSurfaceFormat(FormatOptions options); @@ -146,8 +148,12 @@ public: int swapInterval() const; void setSwapInterval(int interval); - ColorSpace colorSpace() const; + const QColorSpace &colorSpace() const; + void setColorSpace(const QColorSpace &colorSpace); +#if QT_DEPRECATED_SINCE(6,0) + Q_DECL_DEPRECATED_X("Use setColorSpace(QColorSpace) instead.") void setColorSpace(ColorSpace colorSpace); +#endif static void setDefaultFormat(const QSurfaceFormat &format); static QSurfaceFormat defaultFormat(); |