diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-07-31 14:48:49 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-08-02 18:59:24 +0200 |
commit | 455963ce4996055e1f9a9a3c8d0d6a1abf64cd89 (patch) | |
tree | 18476639d799f1426b7c7ea3a1e0b4fa9659afa3 /src | |
parent | a22bb694ce27b16b3ad672b09700937362b9a320 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 12 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 11 |
2 files changed, 9 insertions, 14 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 1a814ec21f..4e2bcad50f 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -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) { diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index e45ea7efd3..d91b2cabaf 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -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; } |