| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/glxconvenience/qglxconvenience.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | // We have to include this before the X11 headers dragged in by | - | ||||||||||||
| 35 | // qglxconvenience_p.h. | - | ||||||||||||
| 36 | #include <QtCore/QByteArray> | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #include "qglxconvenience_p.h" | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include <QtCore/QVector> | - | ||||||||||||
| 41 | #include <QtCore/QVarLengthArray> | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #ifndef QT_NO_XRENDER | - | ||||||||||||
| 44 | #include <X11/extensions/Xrender.h> | - | ||||||||||||
| 45 | #endif | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #include <GL/glxext.h> | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | enum { | - | ||||||||||||
| 50 | XFocusOut = FocusOut, | - | ||||||||||||
| 51 | XFocusIn = FocusIn, | - | ||||||||||||
| 52 | XKeyPress = KeyPress, | - | ||||||||||||
| 53 | XKeyRelease = KeyRelease, | - | ||||||||||||
| 54 | XNone = None, | - | ||||||||||||
| 55 | XRevertToParent = RevertToParent, | - | ||||||||||||
| 56 | XGrayScale = GrayScale, | - | ||||||||||||
| 57 | XCursorShape = CursorShape | - | ||||||||||||
| 58 | }; | - | ||||||||||||
| 59 | #undef FocusOut | - | ||||||||||||
| 60 | #undef FocusIn | - | ||||||||||||
| 61 | #undef KeyPress | - | ||||||||||||
| 62 | #undef KeyRelease | - | ||||||||||||
| 63 | #undef None | - | ||||||||||||
| 64 | #undef RevertToParent | - | ||||||||||||
| 65 | #undef GrayScale | - | ||||||||||||
| 66 | #undef CursorShape | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | #ifdef FontChange | - | ||||||||||||
| 69 | #undef FontChange | - | ||||||||||||
| 70 | #endif | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit) | - | ||||||||||||
| 73 | { | - | ||||||||||||
| 74 | QVector<int> spec(48); | - | ||||||||||||
| 75 | int i = 0; | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | spec[i++] = GLX_LEVEL; | - | ||||||||||||
| 78 | spec[i++] = 0; | - | ||||||||||||
| 79 | spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit; | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; | - | ||||||||||||
| 82 | - | |||||||||||||
| 83 | spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
| 40-4102 | ||||||||||||
| 84 | spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
| 40-4102 | ||||||||||||
| 85 | spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
| 40-4102 | ||||||||||||
| 86 | if (format.hasAlpha()) {
| 4-4138 | ||||||||||||
| 87 | spec[i++] = GLX_ALPHA_SIZE; spec[i++] = format.alphaBufferSize(); | - | ||||||||||||
| 88 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QSurfaceFormat::SingleBuffer ? True : False;
| 0-4142 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
| 0-4142 | ||||||||||||
| 93 | - | |||||||||||||
| 94 | if (format.depthBufferSize() > 0) {
| 24-4118 | ||||||||||||
| 95 | spec[i++] = GLX_DEPTH_SIZE; spec[i++] = format.depthBufferSize(); | - | ||||||||||||
| 96 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||
| 97 | - | |||||||||||||
| 98 | if (format.stencilBufferSize() > 0) {
| 24-4118 | ||||||||||||
| 99 | spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
| 0-24 | ||||||||||||
| 100 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||
| 101 | - | |||||||||||||
| 102 | if (format.samples() > 1) {
| 0-4142 | ||||||||||||
| 103 | spec[i++] = GLX_SAMPLE_BUFFERS_ARB; | - | ||||||||||||
| 104 | spec[i++] = 1; | - | ||||||||||||
| 105 | spec[i++] = GLX_SAMPLES_ARB; | - | ||||||||||||
| 106 | spec[i++] = format.samples(); | - | ||||||||||||
| 107 | } never executed: end of block | 0 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | spec[i++] = XNone; | - | ||||||||||||
| 110 | return spec; executed 4142 times by 120 tests: return spec;Executed by:
| 4142 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit) | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | // Allow forcing LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. | - | ||||||||||||
| 116 | // This is most useful with drivers that only support OpenGL 1. | - | ||||||||||||
| 117 | // We need OpenGL 2, but the user probably doesn't want | - | ||||||||||||
| 118 | // LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps. | - | ||||||||||||
| 119 | static bool checkedForceSoftwareOpenGL = false; | - | ||||||||||||
| 120 | static bool forceSoftwareOpenGL = false; | - | ||||||||||||
| 121 | if (!checkedForceSoftwareOpenGL) {
| 122-4020 | ||||||||||||
| 122 | // If LIBGL_ALWAYS_SOFTWARE is already set, don't mess with it. | - | ||||||||||||
| 123 | // We want to unset LIBGL_ALWAYS_SOFTWARE at the end so it does not | - | ||||||||||||
| 124 | // get inherited by other processes, of course only if it wasn't | - | ||||||||||||
| 125 | // already set before. | - | ||||||||||||
| 126 | if (!qEnvironmentVariableIsEmpty("QT_XCB_FORCE_SOFTWARE_OPENGL")
| 0-122 | ||||||||||||
| 127 | && !qEnvironmentVariableIsSet("LIBGL_ALWAYS_SOFTWARE"))
| 0 | ||||||||||||
| 128 | forceSoftwareOpenGL = true; never executed: forceSoftwareOpenGL = true; | 0 | ||||||||||||
| 129 | - | |||||||||||||
| 130 | checkedForceSoftwareOpenGL = true; | - | ||||||||||||
| 131 | } executed 122 times by 120 tests: end of blockExecuted by:
| 122 | ||||||||||||
| 132 | - | |||||||||||||
| 133 | if (forceSoftwareOpenGL)
| 0-4142 | ||||||||||||
| 134 | qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArrayLiteral("1")); never executed: qputenv("LIBGL_ALWAYS_SOFTWARE", ([]() -> QByteArray { enum { Size = sizeof("1") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "1" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()));never executed: return ba; | 0 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | bool reduced = true; | - | ||||||||||||
| 137 | GLXFBConfig chosenConfig = 0; | - | ||||||||||||
| 138 | QSurfaceFormat reducedFormat = format; | - | ||||||||||||
| 139 | while (!chosenConfig && reduced) {
| 0-4142 | ||||||||||||
| 140 | QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); | - | ||||||||||||
| 141 | int confcount = 0; | - | ||||||||||||
| 142 | GLXFBConfig *configs; | - | ||||||||||||
| 143 | configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); | - | ||||||||||||
| 144 | if (confcount)
| 0-4142 | ||||||||||||
| 145 | { | - | ||||||||||||
| 146 | for (int i = 0; i < confcount; i++) {
| 0-4194 | ||||||||||||
| 147 | chosenConfig = configs[i]; | - | ||||||||||||
| 148 | // Make sure we try to get an ARGB visual if the format asked for an alpha: | - | ||||||||||||
| 149 | if (reducedFormat.hasAlpha()) {
| 56-4138 | ||||||||||||
| 150 | int alphaSize; | - | ||||||||||||
| 151 | glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); | - | ||||||||||||
| 152 | if (alphaSize > 0) {
| 0-56 | ||||||||||||
| 153 | XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig); | - | ||||||||||||
| 154 | bool hasAlpha = false; | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | #if !defined(QT_NO_XRENDER) | - | ||||||||||||
| 157 | XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual); | - | ||||||||||||
| 158 | hasAlpha = pictFormat->direct.alphaMask > 0; | - | ||||||||||||
| 159 | #else | - | ||||||||||||
| 160 | hasAlpha = visual->depth == 32; | - | ||||||||||||
| 161 | #endif | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | XFree(visual); | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | if (hasAlpha)
| 4-52 | ||||||||||||
| 166 | break; executed 4 times by 2 tests: break;Executed by:
| 4 | ||||||||||||
| 167 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||
| 168 | } else { executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||
| 169 | break; // Just choose the first in the list if there's no alpha requested executed 4138 times by 120 tests: break;Executed by:
| 4138 | ||||||||||||
| 170 | } | - | ||||||||||||
| 171 | } | - | ||||||||||||
| 172 | - | |||||||||||||
| 173 | XFree(configs); | - | ||||||||||||
| 174 | } executed 4142 times by 120 tests: end of blockExecuted by:
| 4142 | ||||||||||||
| 175 | if (!chosenConfig)
| 0-4142 | ||||||||||||
| 176 | reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); never executed: reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); | 0 | ||||||||||||
| 177 | } executed 4142 times by 120 tests: end of blockExecuted by:
| 4142 | ||||||||||||
| 178 | - | |||||||||||||
| 179 | // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it | - | ||||||||||||
| 180 | if (forceSoftwareOpenGL)
| 0-4142 | ||||||||||||
| 181 | qunsetenv("LIBGL_ALWAYS_SOFTWARE"); never executed: qunsetenv("LIBGL_ALWAYS_SOFTWARE"); | 0 | ||||||||||||
| 182 | - | |||||||||||||
| 183 | return chosenConfig; executed 4142 times by 120 tests: return chosenConfig;Executed by:
| 4142 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *format) | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | Q_ASSERT(format); | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | XVisualInfo *visualInfo = 0; | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | GLXFBConfig config = qglx_findConfig(display,screen,*format); | - | ||||||||||||
| 193 | if (config) {
| 0-4059 | ||||||||||||
| 194 | visualInfo = glXGetVisualFromFBConfig(display, config); | - | ||||||||||||
| 195 | qglx_surfaceFormatFromGLXFBConfig(format, display, config); | - | ||||||||||||
| 196 | } executed 4059 times by 118 tests: end of blockExecuted by:
| 4059 | ||||||||||||
| 197 | - | |||||||||||||
| 198 | // attempt to fall back to glXChooseVisual | - | ||||||||||||
| 199 | bool reduced = true; | - | ||||||||||||
| 200 | QSurfaceFormat reducedFormat = *format; | - | ||||||||||||
| 201 | while (!visualInfo && reduced) {
| 0-4059 | ||||||||||||
| 202 | QVarLengthArray<int, 13> attribs; | - | ||||||||||||
| 203 | attribs.append(GLX_RGBA); | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | if (reducedFormat.redBufferSize() > 0) {
| 0 | ||||||||||||
| 206 | attribs.append(GLX_RED_SIZE); | - | ||||||||||||
| 207 | attribs.append(reducedFormat.redBufferSize()); | - | ||||||||||||
| 208 | } never executed: end of block | 0 | ||||||||||||
| 209 | - | |||||||||||||
| 210 | if (reducedFormat.greenBufferSize() > 0) {
| 0 | ||||||||||||
| 211 | attribs.append(GLX_GREEN_SIZE); | - | ||||||||||||
| 212 | attribs.append(reducedFormat.greenBufferSize()); | - | ||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||
| 214 | - | |||||||||||||
| 215 | if (reducedFormat.blueBufferSize() > 0) {
| 0 | ||||||||||||
| 216 | attribs.append(GLX_BLUE_SIZE); | - | ||||||||||||
| 217 | attribs.append(reducedFormat.blueBufferSize()); | - | ||||||||||||
| 218 | } never executed: end of block | 0 | ||||||||||||
| 219 | - | |||||||||||||
| 220 | if (reducedFormat.stencilBufferSize() > 0) {
| 0 | ||||||||||||
| 221 | attribs.append(GLX_STENCIL_SIZE); | - | ||||||||||||
| 222 | attribs.append(reducedFormat.stencilBufferSize()); | - | ||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||
| 224 | - | |||||||||||||
| 225 | if (reducedFormat.depthBufferSize() > 0) {
| 0 | ||||||||||||
| 226 | attribs.append(GLX_DEPTH_SIZE); | - | ||||||||||||
| 227 | attribs.append(reducedFormat.depthBufferSize()); | - | ||||||||||||
| 228 | } never executed: end of block | 0 | ||||||||||||
| 229 | - | |||||||||||||
| 230 | if (reducedFormat.swapBehavior() != QSurfaceFormat::SingleBuffer)
| 0 | ||||||||||||
| 231 | attribs.append(GLX_DOUBLEBUFFER); never executed: attribs.append(5); | 0 | ||||||||||||
| 232 | - | |||||||||||||
| 233 | attribs.append(XNone); | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | visualInfo = glXChooseVisual(display, screen, attribs.data()); | - | ||||||||||||
| 236 | if (visualInfo)
| 0 | ||||||||||||
| 237 | *format = reducedFormat; never executed: *format = reducedFormat; | 0 | ||||||||||||
| 238 | - | |||||||||||||
| 239 | reducedFormat = qglx_reduceSurfaceFormat(reducedFormat, &reduced); | - | ||||||||||||
| 240 | } never executed: end of block | 0 | ||||||||||||
| 241 | - | |||||||||||||
| 242 | return visualInfo; executed 4059 times by 118 tests: return visualInfo;Executed by:
| 4059 | ||||||||||||
| 243 | } | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config) | - | ||||||||||||
| 246 | { | - | ||||||||||||
| 247 | int redSize = 0; | - | ||||||||||||
| 248 | int greenSize = 0; | - | ||||||||||||
| 249 | int blueSize = 0; | - | ||||||||||||
| 250 | int alphaSize = 0; | - | ||||||||||||
| 251 | int depthSize = 0; | - | ||||||||||||
| 252 | int stencilSize = 0; | - | ||||||||||||
| 253 | int sampleBuffers = 0; | - | ||||||||||||
| 254 | int sampleCount = 0; | - | ||||||||||||
| 255 | int stereo = 0; | - | ||||||||||||
| 256 | - | |||||||||||||
| 257 | glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); | - | ||||||||||||
| 258 | glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); | - | ||||||||||||
| 259 | glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); | - | ||||||||||||
| 260 | glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); | - | ||||||||||||
| 261 | glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); | - | ||||||||||||
| 262 | glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); | - | ||||||||||||
| 263 | glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleBuffers); | - | ||||||||||||
| 264 | glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); | - | ||||||||||||
| 265 | - | |||||||||||||
| 266 | format->setRedBufferSize(redSize); | - | ||||||||||||
| 267 | format->setGreenBufferSize(greenSize); | - | ||||||||||||
| 268 | format->setBlueBufferSize(blueSize); | - | ||||||||||||
| 269 | format->setAlphaBufferSize(alphaSize); | - | ||||||||||||
| 270 | format->setDepthBufferSize(depthSize); | - | ||||||||||||
| 271 | format->setStencilBufferSize(stencilSize); | - | ||||||||||||
| 272 | if (sampleBuffers) {
| 0-4142 | ||||||||||||
| 273 | glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); | - | ||||||||||||
| 274 | format->setSamples(sampleCount); | - | ||||||||||||
| 275 | } never executed: end of block | 0 | ||||||||||||
| 276 | - | |||||||||||||
| 277 | format->setStereo(stereo); | - | ||||||||||||
| 278 | } executed 4142 times by 120 tests: end of blockExecuted by:
| 4142 | ||||||||||||
| 279 | - | |||||||||||||
| 280 | void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display, XVisualInfo *visualInfo) | - | ||||||||||||
| 281 | { | - | ||||||||||||
| 282 | int redSize = 0; | - | ||||||||||||
| 283 | int greenSize = 0; | - | ||||||||||||
| 284 | int blueSize = 0; | - | ||||||||||||
| 285 | int alphaSize = 0; | - | ||||||||||||
| 286 | int depthSize = 0; | - | ||||||||||||
| 287 | int stencilSize = 0; | - | ||||||||||||
| 288 | int sampleBuffers = 0; | - | ||||||||||||
| 289 | int sampleCount = 0; | - | ||||||||||||
| 290 | int stereo = 0; | - | ||||||||||||
| 291 | - | |||||||||||||
| 292 | glXGetConfig(display, visualInfo, GLX_RED_SIZE, &redSize); | - | ||||||||||||
| 293 | glXGetConfig(display, visualInfo, GLX_GREEN_SIZE, &greenSize); | - | ||||||||||||
| 294 | glXGetConfig(display, visualInfo, GLX_BLUE_SIZE, &blueSize); | - | ||||||||||||
| 295 | glXGetConfig(display, visualInfo, GLX_ALPHA_SIZE, &alphaSize); | - | ||||||||||||
| 296 | glXGetConfig(display, visualInfo, GLX_DEPTH_SIZE, &depthSize); | - | ||||||||||||
| 297 | glXGetConfig(display, visualInfo, GLX_STENCIL_SIZE, &stencilSize); | - | ||||||||||||
| 298 | glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleBuffers); | - | ||||||||||||
| 299 | glXGetConfig(display, visualInfo, GLX_STEREO, &stereo); | - | ||||||||||||
| 300 | - | |||||||||||||
| 301 | format->setRedBufferSize(redSize); | - | ||||||||||||
| 302 | format->setGreenBufferSize(greenSize); | - | ||||||||||||
| 303 | format->setBlueBufferSize(blueSize); | - | ||||||||||||
| 304 | format->setAlphaBufferSize(alphaSize); | - | ||||||||||||
| 305 | format->setDepthBufferSize(depthSize); | - | ||||||||||||
| 306 | format->setStencilBufferSize(stencilSize); | - | ||||||||||||
| 307 | if (sampleBuffers) {
| 0 | ||||||||||||
| 308 | glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount); | - | ||||||||||||
| 309 | format->setSamples(sampleCount); | - | ||||||||||||
| 310 | } never executed: end of block | 0 | ||||||||||||
| 311 | - | |||||||||||||
| 312 | format->setStereo(stereo); | - | ||||||||||||
| 313 | } never executed: end of block | 0 | ||||||||||||
| 314 | - | |||||||||||||
| 315 | QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced) | - | ||||||||||||
| 316 | { | - | ||||||||||||
| 317 | QSurfaceFormat retFormat = format; | - | ||||||||||||
| 318 | *reduced = true; | - | ||||||||||||
| 319 | - | |||||||||||||
| 320 | if (retFormat.redBufferSize() > 1) {
| 0 | ||||||||||||
| 321 | retFormat.setRedBufferSize(1); | - | ||||||||||||
| 322 | } else if (retFormat.greenBufferSize() > 1) { never executed: end of block
| 0 | ||||||||||||
| 323 | retFormat.setGreenBufferSize(1); | - | ||||||||||||
| 324 | } else if (retFormat.blueBufferSize() > 1) { never executed: end of block
| 0 | ||||||||||||
| 325 | retFormat.setBlueBufferSize(1); | - | ||||||||||||
| 326 | } else if (retFormat.samples() > 1) { never executed: end of block
| 0 | ||||||||||||
| 327 | retFormat.setSamples(qMin(retFormat.samples() / 2, 16)); | - | ||||||||||||
| 328 | } else if (retFormat.stereo()) { never executed: end of block
| 0 | ||||||||||||
| 329 | retFormat.setStereo(false); | - | ||||||||||||
| 330 | }else if (retFormat.stencilBufferSize() > 0) { never executed: end of block
| 0 | ||||||||||||
| 331 | retFormat.setStencilBufferSize(0); | - | ||||||||||||
| 332 | }else if (retFormat.hasAlpha()) { never executed: end of block
| 0 | ||||||||||||
| 333 | retFormat.setAlphaBufferSize(0); | - | ||||||||||||
| 334 | }else if (retFormat.depthBufferSize() > 0) { never executed: end of block
| 0 | ||||||||||||
| 335 | retFormat.setDepthBufferSize(0); | - | ||||||||||||
| 336 | }else if (retFormat.swapBehavior() != QSurfaceFormat::SingleBuffer) { never executed: end of block
| 0 | ||||||||||||
| 337 | retFormat.setSwapBehavior(QSurfaceFormat::SingleBuffer); | - | ||||||||||||
| 338 | }else{ never executed: end of block | 0 | ||||||||||||
| 339 | *reduced = false; | - | ||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||
| 341 | return retFormat; never executed: return retFormat; | 0 | ||||||||||||
| 342 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |