| 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) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 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 https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://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 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | // We have to include this before the X11 headers dragged in by | - | ||||||||||||
| 41 | // qglxconvenience_p.h. | - | ||||||||||||
| 42 | #include <QtCore/QByteArray> | - | ||||||||||||
| 43 | #include <QtCore/QScopedPointer> | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | #include "qglxconvenience_p.h" | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #include <QtCore/QVector> | - | ||||||||||||
| 48 | #include <QtCore/QVarLengthArray> | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | #ifndef QT_NO_XRENDER | - | ||||||||||||
| 51 | #include <X11/extensions/Xrender.h> | - | ||||||||||||
| 52 | #endif | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | #include <GL/glxext.h> | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | enum { | - | ||||||||||||
| 57 | XFocusOut = FocusOut, | - | ||||||||||||
| 58 | XFocusIn = FocusIn, | - | ||||||||||||
| 59 | XKeyPress = KeyPress, | - | ||||||||||||
| 60 | XKeyRelease = KeyRelease, | - | ||||||||||||
| 61 | XNone = None, | - | ||||||||||||
| 62 | XRevertToParent = RevertToParent, | - | ||||||||||||
| 63 | XGrayScale = GrayScale, | - | ||||||||||||
| 64 | XCursorShape = CursorShape | - | ||||||||||||
| 65 | }; | - | ||||||||||||
| 66 | #undef FocusOut | - | ||||||||||||
| 67 | #undef FocusIn | - | ||||||||||||
| 68 | #undef KeyPress | - | ||||||||||||
| 69 | #undef KeyRelease | - | ||||||||||||
| 70 | #undef None | - | ||||||||||||
| 71 | #undef RevertToParent | - | ||||||||||||
| 72 | #undef GrayScale | - | ||||||||||||
| 73 | #undef CursorShape | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | #ifdef FontChange | - | ||||||||||||
| 76 | #undef FontChange | - | ||||||||||||
| 77 | #endif | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit) | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | QVector<int> spec; | - | ||||||||||||
| 82 | - | |||||||||||||
| 83 | spec << GLX_LEVEL | - | ||||||||||||
| 84 | << 0 | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | << GLX_RENDER_TYPE | - | ||||||||||||
| 87 | << GLX_RGBA_BIT | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | << GLX_RED_SIZE | - | ||||||||||||
| 90 | << qMax(1, format.redBufferSize()) | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | << GLX_GREEN_SIZE | - | ||||||||||||
| 93 | << qMax(1, format.greenBufferSize()) | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | << GLX_BLUE_SIZE | - | ||||||||||||
| 96 | << qMax(1, format.blueBufferSize()) | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | << GLX_ALPHA_SIZE | - | ||||||||||||
| 99 | << qMax(0, format.alphaBufferSize()); | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | if (format.swapBehavior() != QSurfaceFormat::SingleBuffer) 
 | 0-4057 | ||||||||||||
| 102 | spec << GLX_DOUBLEBUFFER executed 4057 times by 120 tests:  spec << 5 << 1;Executed by: 
 | 4057 | ||||||||||||
| 103 | << True; executed 4057 times by 120 tests:  spec << 5 << 1;Executed by: 
 | 4057 | ||||||||||||
| 104 | - | |||||||||||||
| 105 | if (format.stereo()) 
 | 0-4057 | ||||||||||||
| 106 | spec << GLX_STEREO never executed:  spec << 6 << 1; | 0 | ||||||||||||
| 107 | << True; never executed:  spec << 6 << 1; | 0 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | if (format.depthBufferSize() != -1) 
 | 64-3993 | ||||||||||||
| 110 | spec << GLX_DEPTH_SIZE executed 64 times by 7 tests:  spec << 12 << format.depthBufferSize();Executed by: 
 | 64 | ||||||||||||
| 111 | << format.depthBufferSize(); executed 64 times by 7 tests:  spec << 12 << format.depthBufferSize();Executed by: 
 | 64 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | if (format.stencilBufferSize() != -1) 
 | 64-3993 | ||||||||||||
| 114 | spec << GLX_STENCIL_SIZE executed 64 times by 7 tests:  spec << 13 << format.stencilBufferSize();Executed by: 
 | 64 | ||||||||||||
| 115 | << format.stencilBufferSize(); executed 64 times by 7 tests:  spec << 13 << format.stencilBufferSize();Executed by: 
 | 64 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | if (format.samples() > 1) 
 | 0-4057 | ||||||||||||
| 118 | spec << GLX_SAMPLE_BUFFERS_ARB never executed:  spec << 100000 << 1 << 100001 << format.samples(); | 0 | ||||||||||||
| 119 | << 1 never executed:  spec << 100000 << 1 << 100001 << format.samples(); | 0 | ||||||||||||
| 120 | << GLX_SAMPLES_ARB never executed:  spec << 100000 << 1 << 100001 << format.samples(); | 0 | ||||||||||||
| 121 | << format.samples(); never executed:  spec << 100000 << 1 << 100001 << format.samples(); | 0 | ||||||||||||
| 122 | - | |||||||||||||
| 123 | spec << GLX_DRAWABLE_TYPE | - | ||||||||||||
| 124 | << drawableBit | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | << XNone; | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 | return spec; executed 4057 times by 120 tests:  return spec;Executed by: 
 | 4057 | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | namespace { | - | ||||||||||||
| 132 | struct QXcbSoftwareOpenGLEnforcer { | - | ||||||||||||
| 133 | QXcbSoftwareOpenGLEnforcer() { | - | ||||||||||||
| 134 | // Allow forcing LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. | - | ||||||||||||
| 135 | // This is most useful with drivers that only support OpenGL 1. | - | ||||||||||||
| 136 | // We need OpenGL 2, but the user probably doesn't want | - | ||||||||||||
| 137 | // LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps. | - | ||||||||||||
| 138 | - | |||||||||||||
| 139 | if (!checkedForceSoftwareOpenGL) { 
 | 124-3933 | ||||||||||||
| 140 | // If LIBGL_ALWAYS_SOFTWARE is already set, don't mess with it. | - | ||||||||||||
| 141 | // We want to unset LIBGL_ALWAYS_SOFTWARE at the end so it does not | - | ||||||||||||
| 142 | // get inherited by other processes, of course only if it wasn't | - | ||||||||||||
| 143 | // already set before. | - | ||||||||||||
| 144 | if (!qEnvironmentVariableIsEmpty("QT_XCB_FORCE_SOFTWARE_OPENGL") 
 | 0-124 | ||||||||||||
| 145 | && !qEnvironmentVariableIsSet("LIBGL_ALWAYS_SOFTWARE")) 
 | 0 | ||||||||||||
| 146 | forceSoftwareOpenGL = true; never executed:  forceSoftwareOpenGL = true; | 0 | ||||||||||||
| 147 | - | |||||||||||||
| 148 | checkedForceSoftwareOpenGL = true; | - | ||||||||||||
| 149 | } executed 124 times by 120 tests:  end of blockExecuted by: 
 | 124 | ||||||||||||
| 150 | - | |||||||||||||
| 151 | if (forceSoftwareOpenGL) 
 | 0-4057 | ||||||||||||
| 152 | 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 | ||||||||||||
| 153 | } executed 4057 times by 120 tests:  end of blockExecuted by: 
 | 4057 | ||||||||||||
| 154 | - | |||||||||||||
| 155 | ~QXcbSoftwareOpenGLEnforcer() { | - | ||||||||||||
| 156 | // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it | - | ||||||||||||
| 157 | if (forceSoftwareOpenGL) 
 | 0-4057 | ||||||||||||
| 158 | qunsetenv("LIBGL_ALWAYS_SOFTWARE"); never executed:  qunsetenv("LIBGL_ALWAYS_SOFTWARE"); | 0 | ||||||||||||
| 159 | } executed 4057 times by 120 tests:  end of blockExecuted by: 
 | 4057 | ||||||||||||
| 160 | - | |||||||||||||
| 161 | static bool checkedForceSoftwareOpenGL; | - | ||||||||||||
| 162 | static bool forceSoftwareOpenGL; | - | ||||||||||||
| 163 | }; | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | bool QXcbSoftwareOpenGLEnforcer::checkedForceSoftwareOpenGL = false; | - | ||||||||||||
| 166 | bool QXcbSoftwareOpenGLEnforcer::forceSoftwareOpenGL = false; | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | template <class T> | - | ||||||||||||
| 169 | struct QXlibScopedPointerDeleter { | - | ||||||||||||
| 170 | static inline void cleanup(T *pointer) { | - | ||||||||||||
| 171 | XFree(pointer); | - | ||||||||||||
| 172 | } executed 8166 times by 120 tests:  end of blockExecuted by: 
 | 8166 | ||||||||||||
| 173 | }; | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | template <class T> | - | ||||||||||||
| 176 | using QXlibPointer = QScopedPointer<T, QXlibScopedPointerDeleter<T>>; | - | ||||||||||||
| 177 | - | |||||||||||||
| 178 | template <class T> | - | ||||||||||||
| 179 | using QXlibArrayPointer = QScopedArrayPointer<T, QXlibScopedPointerDeleter<T>>; | - | ||||||||||||
| 180 | } | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format, bool highestPixelFormat, int drawableBit) | - | ||||||||||||
| 183 | { | - | ||||||||||||
| 184 | QXcbSoftwareOpenGLEnforcer softwareOpenGLEnforcer; | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | GLXFBConfig config = 0; | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | do { | - | ||||||||||||
| 189 | const QVector<int> spec = qglx_buildSpec(format, drawableBit); | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | int confcount = 0; | - | ||||||||||||
| 192 | QXlibArrayPointer<GLXFBConfig> configs(glXChooseFBConfig(display, screen, spec.constData(), &confcount)); | - | ||||||||||||
| 193 | - | |||||||||||||
| 194 | if (!config && confcount > 0) { 
 
 | 0-4057 | ||||||||||||
| 195 | config = configs[0]; | - | ||||||||||||
| 196 | if (highestPixelFormat && !format.hasAlpha()) 
 
 | 0-4057 | ||||||||||||
| 197 | break; never executed:  break; | 0 | ||||||||||||
| 198 | } executed 4057 times by 120 tests:  end of blockExecuted by: 
 | 4057 | ||||||||||||
| 199 | - | |||||||||||||
| 200 | const int requestedRed = qMax(0, format.redBufferSize()); | - | ||||||||||||
| 201 | const int requestedGreen = qMax(0, format.greenBufferSize()); | - | ||||||||||||
| 202 | const int requestedBlue = qMax(0, format.blueBufferSize()); | - | ||||||||||||
| 203 | const int requestedAlpha = qMax(0, format.alphaBufferSize()); | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | for (int i = 0; i < confcount; i++) { 
 | 0-4109 | ||||||||||||
| 206 | GLXFBConfig candidate = configs[i]; | - | ||||||||||||
| 207 | - | |||||||||||||
| 208 | QXlibPointer<XVisualInfo> visual(glXGetVisualFromFBConfig(display, candidate)); | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | const int actualRed = qPopulationCount(visual->red_mask); | - | ||||||||||||
| 211 | const int actualGreen = qPopulationCount(visual->green_mask); | - | ||||||||||||
| 212 | const int actualBlue = qPopulationCount(visual->blue_mask); | - | ||||||||||||
| 213 | const int actualAlpha = visual->depth - actualRed - actualGreen - actualBlue; | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | if (requestedRed && actualRed != requestedRed) 
 
 | 0-4109 | ||||||||||||
| 216 | continue; never executed:  continue; | 0 | ||||||||||||
| 217 | if (requestedGreen && actualGreen != requestedGreen) 
 
 | 0-4109 | ||||||||||||
| 218 | continue; never executed:  continue; | 0 | ||||||||||||
| 219 | if (requestedBlue && actualBlue != requestedBlue) 
 
 | 0-4109 | ||||||||||||
| 220 | continue; never executed:  continue; | 0 | ||||||||||||
| 221 | if (requestedAlpha && actualAlpha != requestedAlpha) 
 
 | 4-4053 | ||||||||||||
| 222 | continue; executed 52 times by 2 tests:  continue;Executed by: 
 | 52 | ||||||||||||
| 223 | - | |||||||||||||
| 224 | return candidate; executed 4057 times by 120 tests:  return candidate;Executed by: 
 | 4057 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | } while (qglx_reduceFormat(&format)); never executed:  end of block
 | 0 | ||||||||||||
| 227 | - | |||||||||||||
| 228 | return config; never executed:  return config; | 0 | ||||||||||||
| 229 | } | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *format, int drawableBit) | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | Q_ASSERT(format); | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | XVisualInfo *visualInfo = 0; | - | ||||||||||||
| 236 | - | |||||||||||||
| 237 | GLXFBConfig config = qglx_findConfig(display, screen, *format, false, drawableBit); | - | ||||||||||||
| 238 | if (config) 
 | 0-3974 | ||||||||||||
| 239 | visualInfo = glXGetVisualFromFBConfig(display, config); executed 3974 times by 118 tests:  visualInfo = glXGetVisualFromFBConfig(display, config);Executed by: 
 | 3974 | ||||||||||||
| 240 | - | |||||||||||||
| 241 | if (visualInfo) { 
 | 0-3974 | ||||||||||||
| 242 | qglx_surfaceFormatFromGLXFBConfig(format, display, config); | - | ||||||||||||
| 243 | return visualInfo; executed 3974 times by 118 tests:  return visualInfo;Executed by: 
 | 3974 | ||||||||||||
| 244 | } | - | ||||||||||||
| 245 | - | |||||||||||||
| 246 | // attempt to fall back to glXChooseVisual | - | ||||||||||||
| 247 | do { | - | ||||||||||||
| 248 | QVector<int> attribs = qglx_buildSpec(*format, drawableBit); | - | ||||||||||||
| 249 | visualInfo = glXChooseVisual(display, screen, attribs.data()); | - | ||||||||||||
| 250 | - | |||||||||||||
| 251 | if (visualInfo) { 
 | 0 | ||||||||||||
| 252 | qglx_surfaceFormatFromVisualInfo(format, display, visualInfo); | - | ||||||||||||
| 253 | return visualInfo; never executed:  return visualInfo; | 0 | ||||||||||||
| 254 | } | - | ||||||||||||
| 255 | } while (qglx_reduceFormat(format)); never executed:  end of block
 | 0 | ||||||||||||
| 256 | - | |||||||||||||
| 257 | return visualInfo; never executed:  return visualInfo; | 0 | ||||||||||||
| 258 | } | - | ||||||||||||
| 259 | - | |||||||||||||
| 260 | void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config) | - | ||||||||||||
| 261 | { | - | ||||||||||||
| 262 | int redSize = 0; | - | ||||||||||||
| 263 | int greenSize = 0; | - | ||||||||||||
| 264 | int blueSize = 0; | - | ||||||||||||
| 265 | int alphaSize = 0; | - | ||||||||||||
| 266 | int depthSize = 0; | - | ||||||||||||
| 267 | int stencilSize = 0; | - | ||||||||||||
| 268 | int sampleBuffers = 0; | - | ||||||||||||
| 269 | int sampleCount = 0; | - | ||||||||||||
| 270 | int stereo = 0; | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); | - | ||||||||||||
| 273 | glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); | - | ||||||||||||
| 274 | glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); | - | ||||||||||||
| 275 | glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); | - | ||||||||||||
| 276 | glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); | - | ||||||||||||
| 277 | glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); | - | ||||||||||||
| 278 | glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleBuffers); | - | ||||||||||||
| 279 | glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | format->setRedBufferSize(redSize); | - | ||||||||||||
| 282 | format->setGreenBufferSize(greenSize); | - | ||||||||||||
| 283 | format->setBlueBufferSize(blueSize); | - | ||||||||||||
| 284 | format->setAlphaBufferSize(alphaSize); | - | ||||||||||||
| 285 | format->setDepthBufferSize(depthSize); | - | ||||||||||||
| 286 | format->setStencilBufferSize(stencilSize); | - | ||||||||||||
| 287 | if (sampleBuffers) { 
 | 0-4057 | ||||||||||||
| 288 | glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); | - | ||||||||||||
| 289 | format->setSamples(sampleCount); | - | ||||||||||||
| 290 | } never executed:  end of block | 0 | ||||||||||||
| 291 | - | |||||||||||||
| 292 | format->setStereo(stereo); | - | ||||||||||||
| 293 | } executed 4057 times by 120 tests:  end of blockExecuted by: 
 | 4057 | ||||||||||||
| 294 | - | |||||||||||||
| 295 | void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display, XVisualInfo *visualInfo) | - | ||||||||||||
| 296 | { | - | ||||||||||||
| 297 | int redSize = 0; | - | ||||||||||||
| 298 | int greenSize = 0; | - | ||||||||||||
| 299 | int blueSize = 0; | - | ||||||||||||
| 300 | int alphaSize = 0; | - | ||||||||||||
| 301 | int depthSize = 0; | - | ||||||||||||
| 302 | int stencilSize = 0; | - | ||||||||||||
| 303 | int sampleBuffers = 0; | - | ||||||||||||
| 304 | int sampleCount = 0; | - | ||||||||||||
| 305 | int stereo = 0; | - | ||||||||||||
| 306 | - | |||||||||||||
| 307 | glXGetConfig(display, visualInfo, GLX_RED_SIZE, &redSize); | - | ||||||||||||
| 308 | glXGetConfig(display, visualInfo, GLX_GREEN_SIZE, &greenSize); | - | ||||||||||||
| 309 | glXGetConfig(display, visualInfo, GLX_BLUE_SIZE, &blueSize); | - | ||||||||||||
| 310 | glXGetConfig(display, visualInfo, GLX_ALPHA_SIZE, &alphaSize); | - | ||||||||||||
| 311 | glXGetConfig(display, visualInfo, GLX_DEPTH_SIZE, &depthSize); | - | ||||||||||||
| 312 | glXGetConfig(display, visualInfo, GLX_STENCIL_SIZE, &stencilSize); | - | ||||||||||||
| 313 | glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleBuffers); | - | ||||||||||||
| 314 | glXGetConfig(display, visualInfo, GLX_STEREO, &stereo); | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | format->setRedBufferSize(redSize); | - | ||||||||||||
| 317 | format->setGreenBufferSize(greenSize); | - | ||||||||||||
| 318 | format->setBlueBufferSize(blueSize); | - | ||||||||||||
| 319 | format->setAlphaBufferSize(alphaSize); | - | ||||||||||||
| 320 | format->setDepthBufferSize(depthSize); | - | ||||||||||||
| 321 | format->setStencilBufferSize(stencilSize); | - | ||||||||||||
| 322 | if (sampleBuffers) { 
 | 0 | ||||||||||||
| 323 | glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount); | - | ||||||||||||
| 324 | format->setSamples(sampleCount); | - | ||||||||||||
| 325 | } never executed:  end of block | 0 | ||||||||||||
| 326 | - | |||||||||||||
| 327 | format->setStereo(stereo); | - | ||||||||||||
| 328 | } never executed:  end of block | 0 | ||||||||||||
| 329 | - | |||||||||||||
| 330 | bool qglx_reduceFormat(QSurfaceFormat *format) | - | ||||||||||||
| 331 | { | - | ||||||||||||
| 332 | Q_ASSERT(format); | - | ||||||||||||
| 333 | - | |||||||||||||
| 334 | if (format->redBufferSize() > 1) { 
 | 0 | ||||||||||||
| 335 | format->setRedBufferSize(1); | - | ||||||||||||
| 336 | return true; never executed:  return true; | 0 | ||||||||||||
| 337 | } | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | if (format->greenBufferSize() > 1) { 
 | 0 | ||||||||||||
| 340 | format->setGreenBufferSize(1); | - | ||||||||||||
| 341 | return true; never executed:  return true; | 0 | ||||||||||||
| 342 | } | - | ||||||||||||
| 343 | - | |||||||||||||
| 344 | if (format->blueBufferSize() > 1) { 
 | 0 | ||||||||||||
| 345 | format->setBlueBufferSize(1); | - | ||||||||||||
| 346 | return true; never executed:  return true; | 0 | ||||||||||||
| 347 | } | - | ||||||||||||
| 348 | - | |||||||||||||
| 349 | if (format->swapBehavior() != QSurfaceFormat::SingleBuffer){ 
 | 0 | ||||||||||||
| 350 | format->setSwapBehavior(QSurfaceFormat::SingleBuffer); | - | ||||||||||||
| 351 | return true; never executed:  return true; | 0 | ||||||||||||
| 352 | } | - | ||||||||||||
| 353 | - | |||||||||||||
| 354 | if (format->samples() > 1) { 
 | 0 | ||||||||||||
| 355 | format->setSamples(qMin(16, format->samples() / 2)); | - | ||||||||||||
| 356 | return true; never executed:  return true; | 0 | ||||||||||||
| 357 | } | - | ||||||||||||
| 358 | - | |||||||||||||
| 359 | if (format->depthBufferSize() >= 32) { 
 | 0 | ||||||||||||
| 360 | format->setDepthBufferSize(24); | - | ||||||||||||
| 361 | return true; never executed:  return true; | 0 | ||||||||||||
| 362 | } | - | ||||||||||||
| 363 | - | |||||||||||||
| 364 | if (format->depthBufferSize() > 1) { 
 | 0 | ||||||||||||
| 365 | format->setDepthBufferSize(1); | - | ||||||||||||
| 366 | return true; never executed:  return true; | 0 | ||||||||||||
| 367 | } | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | if (format->depthBufferSize() > 0) { 
 | 0 | ||||||||||||
| 370 | format->setDepthBufferSize(0); | - | ||||||||||||
| 371 | return true; never executed:  return true; | 0 | ||||||||||||
| 372 | } | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | if (format->hasAlpha()) { 
 | 0 | ||||||||||||
| 375 | format->setAlphaBufferSize(0); | - | ||||||||||||
| 376 | return true; never executed:  return true; | 0 | ||||||||||||
| 377 | } | - | ||||||||||||
| 378 | - | |||||||||||||
| 379 | if (format->stencilBufferSize() > 1) { 
 | 0 | ||||||||||||
| 380 | format->setStencilBufferSize(1); | - | ||||||||||||
| 381 | return true; never executed:  return true; | 0 | ||||||||||||
| 382 | } | - | ||||||||||||
| 383 | - | |||||||||||||
| 384 | if (format->stencilBufferSize() > 0) { 
 | 0 | ||||||||||||
| 385 | format->setStencilBufferSize(0); | - | ||||||||||||
| 386 | return true; never executed:  return true; | 0 | ||||||||||||
| 387 | } | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | if (format->stereo()) { 
 | 0 | ||||||||||||
| 390 | format->setStereo(false); | - | ||||||||||||
| 391 | return true; never executed:  return true; | 0 | ||||||||||||
| 392 | } | - | ||||||||||||
| 393 | - | |||||||||||||
| 394 | return false; never executed:  return false; | 0 | ||||||||||||
| 395 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |