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 | |
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')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 31 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.h | 10 | ||||
-rw-r--r-- | src/gui/opengl/platform/unix/qglxconvenience.cpp | 23 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsglcontext.cpp | 7 |
5 files changed, 54 insertions, 19 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(); diff --git a/src/gui/opengl/platform/unix/qglxconvenience.cpp b/src/gui/opengl/platform/unix/qglxconvenience.cpp index 94781aac3d..fd6f1639a3 100644 --- a/src/gui/opengl/platform/unix/qglxconvenience.cpp +++ b/src/gui/opengl/platform/unix/qglxconvenience.cpp @@ -40,15 +40,16 @@ // We have to include this before the X11 headers dragged in by // qglxconvenience_p.h. #include <QtCore/qbytearray.h> -#include <QtCore/qscopedpointer.h> - #include <QtCore/qmetatype.h> +#include <QtCore/qscopedpointer.h> #include <QtCore/qtextstream.h> +#include <QtGui/qcolorspace.h> #include "qglxconvenience_p.h" #include <QtCore/qloggingcategory.h> #include <QtCore/qvarlengtharray.h> + #include <GL/glxext.h> enum { @@ -126,7 +127,7 @@ QList<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit, int fla << GLX_SAMPLES_ARB << format.samples(); - if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QSurfaceFormat::sRGBColorSpace) + if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QColorSpace::SRgb) spec << GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB << True; @@ -217,7 +218,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format for (int i = 0; i < confcount; i++) { GLXFBConfig candidate = configs[i]; - if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QSurfaceFormat::sRGBColorSpace) { + if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QColorSpace::SRgb) { int srgbCapable = 0; glXGetFBConfigAttrib(display, candidate, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable); if (!srgbCapable) @@ -335,7 +336,10 @@ void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); format->setSamples(sampleCount); } - format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace); + if (srgbCapable) + format->setColorSpace(QColorSpace::SRgb); + else + format->setColorSpace(QColorSpace()); format->setStereo(stereo); } @@ -374,7 +378,10 @@ void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display, glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount); format->setSamples(sampleCount); } - format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace); + if (srgbCapable) + format->setColorSpace(QColorSpace::SRgb); + else + format->setColorSpace(QColorSpace()); format->setStereo(stereo); } @@ -455,8 +462,8 @@ bool qglx_reduceFormat(QSurfaceFormat *format) return true; } - if (format->colorSpace() == QSurfaceFormat::sRGBColorSpace) { - format->setColorSpace(QSurfaceFormat::DefaultColorSpace); + if (format->colorSpace() == QColorSpace::SRgb) { + format->setColorSpace(QColorSpace()); return true; } diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 93b7169237..651ae0495d 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1663,7 +1663,7 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel) applyContentBorderThickness(nsWindow); - if (format().colorSpace() == QSurfaceFormat::sRGBColorSpace) + if (format().colorSpace() == QColorSpace::SRgb) nsWindow.colorSpace = NSColorSpace.sRGBColorSpace; return nsWindow; diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index aa93b85289..8c41cc135d 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -44,6 +44,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qsysinfo.h> +#include <QtGui/qcolorspace.h> #include <QtGui/qguiapplication.h> #include <qpa/qplatformnativeinterface.h> @@ -588,7 +589,7 @@ static int choosePixelFormat(HDC hdc, iAttributes[i++] = FALSE; } // must be the last - bool srgbRequested = format.colorSpace() == QSurfaceFormat::sRGBColorSpace; + bool srgbRequested = format.colorSpace() == QColorSpace::SRgb; int srgbValuePosition = 0; if (srgbRequested) { srgbValuePosition = i; @@ -710,10 +711,10 @@ static QSurfaceFormat if (hasSampleBuffers) { result.setSamples(iValues[13]); if (hasSrgbSupport && iValues[14]) - result.setColorSpace(QSurfaceFormat::sRGBColorSpace); + result.setColorSpace(QColorSpace::SRgb); } else { if (hasSrgbSupport && iValues[12]) - result.setColorSpace(QSurfaceFormat::sRGBColorSpace); + result.setColorSpace(QColorSpace::SRgb); } if (additionalIn) { if (iValues[7]) |