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 <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QColorSpace>
|
||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
@ -77,7 +78,7 @@ int main( int argc, char ** argv )
|
|||||||
format.setDepthBufferSize(24);
|
format.setDepthBufferSize(24);
|
||||||
format.setStencilBufferSize(8);
|
format.setStencilBufferSize(8);
|
||||||
if (parser.isSet(srgbOption))
|
if (parser.isSet(srgbOption))
|
||||||
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
format.setColorSpace(QColorSpace::SRgb);
|
||||||
if (parser.isSet(multipleSampleOption))
|
if (parser.isSet(multipleSampleOption))
|
||||||
format.setSamples(4);
|
format.setSamples(4);
|
||||||
QSurfaceFormat::setDefaultFormat(format);
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include <QtCore/qatomic.h>
|
#include <QtCore/qatomic.h>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
|
#include <QtGui/qcolorspace.h>
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
|
|
||||||
#ifdef major
|
#ifdef major
|
||||||
@ -73,7 +74,6 @@ public:
|
|||||||
, major(2)
|
, major(2)
|
||||||
, minor(0)
|
, minor(0)
|
||||||
, swapInterval(1) // default to vsync
|
, swapInterval(1) // default to vsync
|
||||||
, colorSpace(QSurfaceFormat::DefaultColorSpace)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
int swapInterval;
|
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
|
blending to be performed in the given color space instead of using the
|
||||||
standard linear operations.
|
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
|
\since 5.10
|
||||||
|
|
||||||
\sa colorSpace()
|
\sa colorSpace()
|
||||||
*/
|
*/
|
||||||
void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
|
void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
|
||||||
{
|
{
|
||||||
if (d->colorSpace != colorSpace) {
|
switch (colorSpace) {
|
||||||
detach();
|
case DefaultColorSpace:
|
||||||
d->colorSpace = colorSpace;
|
setColorSpace(QColorSpace());
|
||||||
|
break;
|
||||||
|
case sRGBColorSpace:
|
||||||
|
setColorSpace(QColorSpace::SRgb);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +772,7 @@ void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
|
|||||||
|
|
||||||
\sa setColorSpace()
|
\sa setColorSpace()
|
||||||
*/
|
*/
|
||||||
QSurfaceFormat::ColorSpace QSurfaceFormat::colorSpace() const
|
const QColorSpace &QSurfaceFormat::colorSpace() const
|
||||||
{
|
{
|
||||||
return d->colorSpace;
|
return d->colorSpace;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QColorSpace;
|
||||||
class QOpenGLContext;
|
class QOpenGLContext;
|
||||||
class QSurfaceFormatPrivate;
|
class QSurfaceFormatPrivate;
|
||||||
|
|
||||||
@ -85,11 +85,13 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(OpenGLContextProfile)
|
Q_ENUM(OpenGLContextProfile)
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6,0)
|
||||||
enum ColorSpace {
|
enum ColorSpace {
|
||||||
DefaultColorSpace,
|
DefaultColorSpace,
|
||||||
sRGBColorSpace
|
sRGBColorSpace
|
||||||
};
|
};
|
||||||
Q_ENUM(ColorSpace)
|
Q_ENUM(ColorSpace)
|
||||||
|
#endif
|
||||||
|
|
||||||
QSurfaceFormat();
|
QSurfaceFormat();
|
||||||
/*implicit*/ QSurfaceFormat(FormatOptions options);
|
/*implicit*/ QSurfaceFormat(FormatOptions options);
|
||||||
@ -146,8 +148,12 @@ public:
|
|||||||
int swapInterval() const;
|
int swapInterval() const;
|
||||||
void setSwapInterval(int interval);
|
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);
|
void setColorSpace(ColorSpace colorSpace);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void setDefaultFormat(const QSurfaceFormat &format);
|
static void setDefaultFormat(const QSurfaceFormat &format);
|
||||||
static QSurfaceFormat defaultFormat();
|
static QSurfaceFormat defaultFormat();
|
||||||
|
@ -40,15 +40,16 @@
|
|||||||
// We have to include this before the X11 headers dragged in by
|
// We have to include this before the X11 headers dragged in by
|
||||||
// qglxconvenience_p.h.
|
// qglxconvenience_p.h.
|
||||||
#include <QtCore/qbytearray.h>
|
#include <QtCore/qbytearray.h>
|
||||||
#include <QtCore/qscopedpointer.h>
|
|
||||||
|
|
||||||
#include <QtCore/qmetatype.h>
|
#include <QtCore/qmetatype.h>
|
||||||
|
#include <QtCore/qscopedpointer.h>
|
||||||
#include <QtCore/qtextstream.h>
|
#include <QtCore/qtextstream.h>
|
||||||
|
#include <QtGui/qcolorspace.h>
|
||||||
#include "qglxconvenience_p.h"
|
#include "qglxconvenience_p.h"
|
||||||
|
|
||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
#include <QtCore/qvarlengtharray.h>
|
#include <QtCore/qvarlengtharray.h>
|
||||||
|
|
||||||
|
|
||||||
#include <GL/glxext.h>
|
#include <GL/glxext.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -126,7 +127,7 @@ QList<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit, int fla
|
|||||||
<< GLX_SAMPLES_ARB
|
<< GLX_SAMPLES_ARB
|
||||||
<< format.samples();
|
<< 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
|
spec << GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
|
||||||
<< True;
|
<< True;
|
||||||
|
|
||||||
@ -217,7 +218,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
|
|||||||
for (int i = 0; i < confcount; i++) {
|
for (int i = 0; i < confcount; i++) {
|
||||||
GLXFBConfig candidate = configs[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;
|
int srgbCapable = 0;
|
||||||
glXGetFBConfigAttrib(display, candidate, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable);
|
glXGetFBConfigAttrib(display, candidate, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable);
|
||||||
if (!srgbCapable)
|
if (!srgbCapable)
|
||||||
@ -335,7 +336,10 @@ void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display,
|
|||||||
glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
|
glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
|
||||||
format->setSamples(sampleCount);
|
format->setSamples(sampleCount);
|
||||||
}
|
}
|
||||||
format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace);
|
if (srgbCapable)
|
||||||
|
format->setColorSpace(QColorSpace::SRgb);
|
||||||
|
else
|
||||||
|
format->setColorSpace(QColorSpace());
|
||||||
|
|
||||||
format->setStereo(stereo);
|
format->setStereo(stereo);
|
||||||
}
|
}
|
||||||
@ -374,7 +378,10 @@ void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display,
|
|||||||
glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount);
|
glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount);
|
||||||
format->setSamples(sampleCount);
|
format->setSamples(sampleCount);
|
||||||
}
|
}
|
||||||
format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace);
|
if (srgbCapable)
|
||||||
|
format->setColorSpace(QColorSpace::SRgb);
|
||||||
|
else
|
||||||
|
format->setColorSpace(QColorSpace());
|
||||||
|
|
||||||
format->setStereo(stereo);
|
format->setStereo(stereo);
|
||||||
}
|
}
|
||||||
@ -455,8 +462,8 @@ bool qglx_reduceFormat(QSurfaceFormat *format)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format->colorSpace() == QSurfaceFormat::sRGBColorSpace) {
|
if (format->colorSpace() == QColorSpace::SRgb) {
|
||||||
format->setColorSpace(QSurfaceFormat::DefaultColorSpace);
|
format->setColorSpace(QColorSpace());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,7 +1663,7 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
|
|||||||
|
|
||||||
applyContentBorderThickness(nsWindow);
|
applyContentBorderThickness(nsWindow);
|
||||||
|
|
||||||
if (format().colorSpace() == QSurfaceFormat::sRGBColorSpace)
|
if (format().colorSpace() == QColorSpace::SRgb)
|
||||||
nsWindow.colorSpace = NSColorSpace.sRGBColorSpace;
|
nsWindow.colorSpace = NSColorSpace.sRGBColorSpace;
|
||||||
|
|
||||||
return nsWindow;
|
return nsWindow;
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/qsysinfo.h>
|
#include <QtCore/qsysinfo.h>
|
||||||
|
#include <QtGui/qcolorspace.h>
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
|
||||||
@ -588,7 +589,7 @@ static int choosePixelFormat(HDC hdc,
|
|||||||
iAttributes[i++] = FALSE;
|
iAttributes[i++] = FALSE;
|
||||||
}
|
}
|
||||||
// must be the last
|
// must be the last
|
||||||
bool srgbRequested = format.colorSpace() == QSurfaceFormat::sRGBColorSpace;
|
bool srgbRequested = format.colorSpace() == QColorSpace::SRgb;
|
||||||
int srgbValuePosition = 0;
|
int srgbValuePosition = 0;
|
||||||
if (srgbRequested) {
|
if (srgbRequested) {
|
||||||
srgbValuePosition = i;
|
srgbValuePosition = i;
|
||||||
@ -710,10 +711,10 @@ static QSurfaceFormat
|
|||||||
if (hasSampleBuffers) {
|
if (hasSampleBuffers) {
|
||||||
result.setSamples(iValues[13]);
|
result.setSamples(iValues[13]);
|
||||||
if (hasSrgbSupport && iValues[14])
|
if (hasSrgbSupport && iValues[14])
|
||||||
result.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
result.setColorSpace(QColorSpace::SRgb);
|
||||||
} else {
|
} else {
|
||||||
if (hasSrgbSupport && iValues[12])
|
if (hasSrgbSupport && iValues[12])
|
||||||
result.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
result.setColorSpace(QColorSpace::SRgb);
|
||||||
}
|
}
|
||||||
if (additionalIn) {
|
if (additionalIn) {
|
||||||
if (iValues[7])
|
if (iValues[7])
|
||||||
|
@ -520,7 +520,7 @@ int main(int argc, char **argv)
|
|||||||
if (scFlags.testFlag(QRhiSwapChain::NoVSync))
|
if (scFlags.testFlag(QRhiSwapChain::NoVSync))
|
||||||
fmt.setSwapInterval(0);
|
fmt.setSwapInterval(0);
|
||||||
if (scFlags.testFlag(QRhiSwapChain::sRGB))
|
if (scFlags.testFlag(QRhiSwapChain::sRGB))
|
||||||
fmt.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
fmt.setColorSpace(QColorSpace::SRgb);
|
||||||
// Exception: The alpha size is not necessarily OpenGL specific.
|
// Exception: The alpha size is not necessarily OpenGL specific.
|
||||||
if (transparentBackground)
|
if (transparentBackground)
|
||||||
fmt.setAlphaBufferSize(8);
|
fmt.setAlphaBufferSize(8);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user