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>
This commit is contained in:
parent
fce84f76f0
commit
9815ebf24b
@ -50,6 +50,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QColorSpace>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
@ -77,7 +78,7 @@ int main( int argc, char ** argv )
|
||||
format.setDepthBufferSize(24);
|
||||
format.setStencilBufferSize(8);
|
||||
if (parser.isSet(srgbOption))
|
||||
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
||||
format.setColorSpace(QColorSpace::SRgb);
|
||||
if (parser.isSet(multipleSampleOption))
|
||||
format.setSamples(4);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
@ -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,15 +732,36 @@ int QSurfaceFormat::swapInterval() const
|
||||
blending to be performed in the given color space instead of using the
|
||||
standard linear operations.
|
||||
|
||||
\since 6.0
|
||||
|
||||
\sa colorSpace()
|
||||
*/
|
||||
void QSurfaceFormat::setColorSpace(const QColorSpace &colorSpace)
|
||||
{
|
||||
if (d->colorSpace != colorSpace) {
|
||||
detach();
|
||||
d->colorSpace = colorSpace;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
Sets the colorspace to one of the predefined values.
|
||||
|
||||
\since 5.10
|
||||
|
||||
\sa colorSpace()
|
||||
*/
|
||||
void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
|
||||
{
|
||||
if (d->colorSpace != colorSpace) {
|
||||
detach();
|
||||
d->colorSpace = colorSpace;
|
||||
switch (colorSpace) {
|
||||
case DefaultColorSpace:
|
||||
setColorSpace(QColorSpace());
|
||||
break;
|
||||
case sRGBColorSpace:
|
||||
setColorSpace(QColorSpace::SRgb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -751,7 +772,7 @@ void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
|
||||
|
||||
\sa setColorSpace()
|
||||
*/
|
||||
QSurfaceFormat::ColorSpace QSurfaceFormat::colorSpace() const
|
||||
const QColorSpace &QSurfaceFormat::colorSpace() const
|
||||
{
|
||||
return d->colorSpace;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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])
|
||||
|
@ -520,7 +520,7 @@ int main(int argc, char **argv)
|
||||
if (scFlags.testFlag(QRhiSwapChain::NoVSync))
|
||||
fmt.setSwapInterval(0);
|
||||
if (scFlags.testFlag(QRhiSwapChain::sRGB))
|
||||
fmt.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
||||
fmt.setColorSpace(QColorSpace::SRgb);
|
||||
// Exception: The alpha size is not necessarily OpenGL specific.
|
||||
if (transparentBackground)
|
||||
fmt.setAlphaBufferSize(8);
|
||||
|
Loading…
x
Reference in New Issue
Block a user