macOS: Don't require setting all three color buffer sizes in QSurfaceFormat

Change-Id: Iaa6eb4d64f549a31aa5c53145e8b37facec4ea78
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-07-31 14:48:49 +02:00
parent a22bb694ce
commit 455963ce49
2 changed files with 9 additions and 14 deletions

View File

@ -554,10 +554,6 @@ int QSurfaceFormat::alphaBufferSize() const
/*!
Set the desired \a size in bits of the red channel of the color buffer.
\note On Mac OSX, be sure to set the buffer size of all color channels,
otherwise this setting will have no effect. If one of the buffer sizes is not set,
the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setRedBufferSize(int size)
{
@ -569,10 +565,6 @@ void QSurfaceFormat::setRedBufferSize(int size)
/*!
Set the desired \a size in bits of the green channel of the color buffer.
\note On Mac OSX, be sure to set the buffer size of all color channels,
otherwise this setting will have no effect. If one of the buffer sizes is not set,
the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setGreenBufferSize(int size)
{
@ -584,10 +576,6 @@ void QSurfaceFormat::setGreenBufferSize(int size)
/*!
Set the desired \a size in bits of the blue channel of the color buffer.
\note On Mac OSX, be sure to set the buffer size of all color channels,
otherwise this setting will have no effect. If one of the buffer sizes is not set,
the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setBlueBufferSize(int size)
{

View File

@ -197,8 +197,15 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface
attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize();
if (format.alphaBufferSize() > 0)
attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize();
if (format.redBufferSize() > 0 && format.greenBufferSize() > 0 && format.blueBufferSize() > 0) {
const int colorSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize();
auto rbz = format.redBufferSize();
auto gbz = format.greenBufferSize();
auto bbz = format.blueBufferSize();
if (rbz > 0 || gbz > 0 || bbz > 0) {
auto fallbackSize = qMax(rbz, qMax(gbz, bbz));
auto colorSize = (rbz > 0 ? rbz : fallbackSize)
+ (gbz > 0 ? gbz : fallbackSize)
+ (bbz > 0 ? bbz : fallbackSize);
attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy;
}