| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/eglconvenience/qeglconvenience.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 | #include <QByteArray> | - | ||||||||||||
| 41 | #include <QOpenGLContext> | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 44 | #include <sys/ioctl.h> | - | ||||||||||||
| 45 | #include <linux/fb.h> | - | ||||||||||||
| 46 | #endif | - | ||||||||||||
| 47 | #include <private/qmath_p.h> | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | #include "qeglconvenience_p.h" | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | #ifndef EGL_OPENGL_ES3_BIT_KHR | - | ||||||||||||
| 52 | #define EGL_OPENGL_ES3_BIT_KHR 0x0040 | - | ||||||||||||
| 53 | #endif | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | int redSize = format.redBufferSize(); | - | ||||||||||||
| 60 | int greenSize = format.greenBufferSize(); | - | ||||||||||||
| 61 | int blueSize = format.blueBufferSize(); | - | ||||||||||||
| 62 | int alphaSize = format.alphaBufferSize(); | - | ||||||||||||
| 63 | int depthSize = format.depthBufferSize(); | - | ||||||||||||
| 64 | int stencilSize = format.stencilBufferSize(); | - | ||||||||||||
| 65 | int sampleCount = format.samples(); | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | QVector<EGLint> configAttributes; | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | // Map default, unspecified values (-1) to 0. This is important due to sorting rule #3 | - | ||||||||||||
| 70 | // in section 3.4.1 of the spec and allows picking a potentially faster 16-bit config | - | ||||||||||||
| 71 | // over 32-bit ones when there is no explicit request for the color channel sizes: | - | ||||||||||||
| 72 | // | - | ||||||||||||
| 73 | // The red/green/blue sizes have a sort priority of 3, so they are sorted by | - | ||||||||||||
| 74 | // first. (unless a caveat like SLOW or NON_CONFORMANT is present) The sort order is | - | ||||||||||||
| 75 | // Special and described as "by larger _total_ number of color bits.". So EGL will put | - | ||||||||||||
| 76 | // 32-bit configs in the list before the 16-bit configs. However, the spec also goes | - | ||||||||||||
| 77 | // on to say "If the requested number of bits in attrib_list for a particular | - | ||||||||||||
| 78 | // component is 0, then the number of bits for that component is not considered". This | - | ||||||||||||
| 79 | // part of the spec also seems to imply that setting the red/green/blue bits to zero | - | ||||||||||||
| 80 | // means none of the components are considered and EGL disregards the entire sorting | - | ||||||||||||
| 81 | // rule. It then looks to the next highest priority rule, which is | - | ||||||||||||
| 82 | // EGL_BUFFER_SIZE. Despite the selection criteria being "AtLeast" for | - | ||||||||||||
| 83 | // EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are put in the | - | ||||||||||||
| 84 | // list before 32-bit configs. | - | ||||||||||||
| 85 | // | - | ||||||||||||
| 86 | // This also means that explicitly specifying a size like 565 will still result in | - | ||||||||||||
| 87 | // having larger (888) configs first in the returned list. We need to handle this | - | ||||||||||||
| 88 | // ourselves later by manually filtering the list, instead of just blindly taking the | - | ||||||||||||
| 89 | // first config from it. | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | configAttributes.append(EGL_RED_SIZE); | - | ||||||||||||
| 92 | configAttributes.append(redSize > 0 ? redSize : 0); | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | configAttributes.append(EGL_GREEN_SIZE); | - | ||||||||||||
| 95 | configAttributes.append(greenSize > 0 ? greenSize : 0); | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | configAttributes.append(EGL_BLUE_SIZE); | - | ||||||||||||
| 98 | configAttributes.append(blueSize > 0 ? blueSize : 0); | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | configAttributes.append(EGL_ALPHA_SIZE); | - | ||||||||||||
| 101 | configAttributes.append(alphaSize > 0 ? alphaSize : 0); | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | configAttributes.append(EGL_DEPTH_SIZE); | - | ||||||||||||
| 104 | configAttributes.append(depthSize > 0 ? depthSize : 0); | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | configAttributes.append(EGL_STENCIL_SIZE); | - | ||||||||||||
| 107 | configAttributes.append(stencilSize > 0 ? stencilSize : 0); | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | configAttributes.append(EGL_SAMPLES); | - | ||||||||||||
| 110 | configAttributes.append(sampleCount > 0 ? sampleCount : 0); | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | configAttributes.append(EGL_SAMPLE_BUFFERS); | - | ||||||||||||
| 113 | configAttributes.append(sampleCount > 0); | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | return configAttributes; never executed: return configAttributes; | 0 | ||||||||||||
| 116 | } | - | ||||||||||||
| 117 | - | |||||||||||||
| 118 | bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes) | - | ||||||||||||
| 119 | { | - | ||||||||||||
| 120 | int i = -1; | - | ||||||||||||
| 121 | // Reduce the complexity of a configuration request to ask for less | - | ||||||||||||
| 122 | // because the previous request did not result in success. Returns | - | ||||||||||||
| 123 | // true if the complexity was reduced, or false if no further | - | ||||||||||||
| 124 | // reductions in complexity are possible. | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); | - | ||||||||||||
| 127 | if (i >= 0) {
| 0 | ||||||||||||
| 128 | configAttributes->remove(i,2); | - | ||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||
| 130 | - | |||||||||||||
| 131 | #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT | - | ||||||||||||
| 132 | // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't | - | ||||||||||||
| 133 | // find a config which supports pre-multiplied formats, remove the flag on the surface type: | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | i = configAttributes->indexOf(EGL_SURFACE_TYPE); | - | ||||||||||||
| 136 | if (i >= 0) {
| 0 | ||||||||||||
| 137 | EGLint surfaceType = configAttributes->at(i +1); | - | ||||||||||||
| 138 | if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) {
| 0 | ||||||||||||
| 139 | surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT; | - | ||||||||||||
| 140 | configAttributes->replace(i+1,surfaceType); | - | ||||||||||||
| 141 | return true; never executed: return true; | 0 | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | } never executed: end of block | 0 | ||||||||||||
| 144 | #endif | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | // EGL chooses configs with the highest color depth over | - | ||||||||||||
| 147 | // those with smaller (but faster) lower color depths. One | - | ||||||||||||
| 148 | // way around this is to set EGL_BUFFER_SIZE to 16, which | - | ||||||||||||
| 149 | // trumps the others. Of course, there may not be a 16-bit | - | ||||||||||||
| 150 | // config available, so it's the first restraint we remove. | - | ||||||||||||
| 151 | i = configAttributes->indexOf(EGL_BUFFER_SIZE); | - | ||||||||||||
| 152 | if (i >= 0) {
| 0 | ||||||||||||
| 153 | if (configAttributes->at(i+1) == 16) {
| 0 | ||||||||||||
| 154 | configAttributes->remove(i,2); | - | ||||||||||||
| 155 | return true; never executed: return true; | 0 | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | } never executed: end of block | 0 | ||||||||||||
| 158 | - | |||||||||||||
| 159 | i = configAttributes->indexOf(EGL_SAMPLES); | - | ||||||||||||
| 160 | if (i >= 0) {
| 0 | ||||||||||||
| 161 | EGLint value = configAttributes->value(i+1, 0); | - | ||||||||||||
| 162 | if (value > 1)
| 0 | ||||||||||||
| 163 | configAttributes->replace(i+1, qMin(EGLint(16), value / 2)); never executed: configAttributes->replace(i+1, qMin(EGLint(16), value / 2)); | 0 | ||||||||||||
| 164 | else | - | ||||||||||||
| 165 | configAttributes->remove(i, 2); never executed: configAttributes->remove(i, 2); | 0 | ||||||||||||
| 166 | return true; never executed: return true; | 0 | ||||||||||||
| 167 | } | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS); | - | ||||||||||||
| 170 | if (i >= 0) {
| 0 | ||||||||||||
| 171 | configAttributes->remove(i,2); | - | ||||||||||||
| 172 | return true; never executed: return true; | 0 | ||||||||||||
| 173 | } | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | i = configAttributes->indexOf(EGL_DEPTH_SIZE); | - | ||||||||||||
| 176 | if (i >= 0) {
| 0 | ||||||||||||
| 177 | if (configAttributes->at(i + 1) >= 32)
| 0 | ||||||||||||
| 178 | configAttributes->replace(i + 1, 24); never executed: configAttributes->replace(i + 1, 24); | 0 | ||||||||||||
| 179 | else if (configAttributes->at(i + 1) > 1)
| 0 | ||||||||||||
| 180 | configAttributes->replace(i + 1, 1); never executed: configAttributes->replace(i + 1, 1); | 0 | ||||||||||||
| 181 | else | - | ||||||||||||
| 182 | configAttributes->remove(i, 2); never executed: configAttributes->remove(i, 2); | 0 | ||||||||||||
| 183 | return true; never executed: return true; | 0 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | i = configAttributes->indexOf(EGL_ALPHA_SIZE); | - | ||||||||||||
| 187 | if (i >= 0) {
| 0 | ||||||||||||
| 188 | configAttributes->remove(i,2); | - | ||||||||||||
| 189 | #if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) | - | ||||||||||||
| 190 | i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA); | - | ||||||||||||
| 191 | if (i >= 0) {
| 0 | ||||||||||||
| 192 | configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB); | - | ||||||||||||
| 193 | configAttributes->replace(i+1,true); | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||
| 196 | #endif | - | ||||||||||||
| 197 | return true; never executed: return true; | 0 | ||||||||||||
| 198 | } | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | i = configAttributes->indexOf(EGL_STENCIL_SIZE); | - | ||||||||||||
| 201 | if (i >= 0) {
| 0 | ||||||||||||
| 202 | if (configAttributes->at(i + 1) > 1)
| 0 | ||||||||||||
| 203 | configAttributes->replace(i + 1, 1); never executed: configAttributes->replace(i + 1, 1); | 0 | ||||||||||||
| 204 | else | - | ||||||||||||
| 205 | configAttributes->remove(i, 2); never executed: configAttributes->remove(i, 2); | 0 | ||||||||||||
| 206 | return true; never executed: return true; | 0 | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | #ifdef EGL_BIND_TO_TEXTURE_RGB | - | ||||||||||||
| 210 | i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB); | - | ||||||||||||
| 211 | if (i >= 0) {
| 0 | ||||||||||||
| 212 | configAttributes->remove(i,2); | - | ||||||||||||
| 213 | return true; never executed: return true; | 0 | ||||||||||||
| 214 | } | - | ||||||||||||
| 215 | #endif | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | return false; never executed: return false; | 0 | ||||||||||||
| 218 | } | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | QEglConfigChooser::QEglConfigChooser(EGLDisplay display) | - | ||||||||||||
| 221 | : m_display(display) | - | ||||||||||||
| 222 | , m_surfaceType(EGL_WINDOW_BIT) | - | ||||||||||||
| 223 | , m_ignore(false) | - | ||||||||||||
| 224 | , m_confAttrRed(0) | - | ||||||||||||
| 225 | , m_confAttrGreen(0) | - | ||||||||||||
| 226 | , m_confAttrBlue(0) | - | ||||||||||||
| 227 | , m_confAttrAlpha(0) | - | ||||||||||||
| 228 | { | - | ||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||
| 230 | - | |||||||||||||
| 231 | QEglConfigChooser::~QEglConfigChooser() | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | } | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | EGLConfig QEglConfigChooser::chooseConfig() | - | ||||||||||||
| 236 | { | - | ||||||||||||
| 237 | QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(m_format); | - | ||||||||||||
| 238 | configureAttributes.append(EGL_SURFACE_TYPE); | - | ||||||||||||
| 239 | configureAttributes.append(surfaceType()); | - | ||||||||||||
| 240 | - | |||||||||||||
| 241 | configureAttributes.append(EGL_RENDERABLE_TYPE); | - | ||||||||||||
| 242 | bool needsES2Plus = false; | - | ||||||||||||
| 243 | switch (m_format.renderableType()) { | - | ||||||||||||
| 244 | case QSurfaceFormat::OpenVG: never executed: case QSurfaceFormat::OpenVG: | 0 | ||||||||||||
| 245 | configureAttributes.append(EGL_OPENVG_BIT); | - | ||||||||||||
| 246 | break; never executed: break; | 0 | ||||||||||||
| 247 | #ifdef EGL_VERSION_1_4 | - | ||||||||||||
| 248 | case QSurfaceFormat::DefaultRenderableType: never executed: case QSurfaceFormat::DefaultRenderableType: | 0 | ||||||||||||
| 249 | #ifndef QT_NO_OPENGL | - | ||||||||||||
| 250 | if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL)
| 0 | ||||||||||||
| 251 | configureAttributes.append(EGL_OPENGL_BIT); never executed: configureAttributes.append(0x0008); | 0 | ||||||||||||
| 252 | else | - | ||||||||||||
| 253 | #endif // QT_NO_OPENGL | - | ||||||||||||
| 254 | needsES2Plus = true; never executed: needsES2Plus = true; | 0 | ||||||||||||
| 255 | break; never executed: break; | 0 | ||||||||||||
| 256 | case QSurfaceFormat::OpenGL: never executed: case QSurfaceFormat::OpenGL: | 0 | ||||||||||||
| 257 | configureAttributes.append(EGL_OPENGL_BIT); | - | ||||||||||||
| 258 | break; never executed: break; | 0 | ||||||||||||
| 259 | #endif | - | ||||||||||||
| 260 | case QSurfaceFormat::OpenGLES: never executed: case QSurfaceFormat::OpenGLES: | 0 | ||||||||||||
| 261 | if (m_format.majorVersion() == 1) {
| 0 | ||||||||||||
| 262 | configureAttributes.append(EGL_OPENGL_ES_BIT); | - | ||||||||||||
| 263 | break; never executed: break; | 0 | ||||||||||||
| 264 | } | - | ||||||||||||
| 265 | // fall through | - | ||||||||||||
| 266 | default: code before this statement never executed: default:never executed: default: | 0 | ||||||||||||
| 267 | needsES2Plus = true; | - | ||||||||||||
| 268 | break; never executed: break; | 0 | ||||||||||||
| 269 | } | - | ||||||||||||
| 270 | if (needsES2Plus) {
| 0 | ||||||||||||
| 271 | if (m_format.majorVersion() >= 3 && q_hasEglExtension(display(), "EGL_KHR_create_context"))
| 0 | ||||||||||||
| 272 | configureAttributes.append(EGL_OPENGL_ES3_BIT_KHR); never executed: configureAttributes.append(0x00000040); | 0 | ||||||||||||
| 273 | else | - | ||||||||||||
| 274 | configureAttributes.append(EGL_OPENGL_ES2_BIT); never executed: configureAttributes.append(0x0004); | 0 | ||||||||||||
| 275 | } | - | ||||||||||||
| 276 | configureAttributes.append(EGL_NONE); | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | EGLConfig cfg = 0; | - | ||||||||||||
| 279 | do { | - | ||||||||||||
| 280 | // Get the number of matching configurations for this set of properties. | - | ||||||||||||
| 281 | EGLint matching = 0; | - | ||||||||||||
| 282 | if (!eglChooseConfig(display(), configureAttributes.constData(), 0, 0, &matching) || !matching)
| 0 | ||||||||||||
| 283 | continue; never executed: continue; | 0 | ||||||||||||
| 284 | - | |||||||||||||
| 285 | // Fetch all of the matching configurations and find the | - | ||||||||||||
| 286 | // first that matches the pixel format we wanted. | - | ||||||||||||
| 287 | int i = configureAttributes.indexOf(EGL_RED_SIZE); | - | ||||||||||||
| 288 | m_confAttrRed = configureAttributes.at(i+1); | - | ||||||||||||
| 289 | i = configureAttributes.indexOf(EGL_GREEN_SIZE); | - | ||||||||||||
| 290 | m_confAttrGreen = configureAttributes.at(i+1); | - | ||||||||||||
| 291 | i = configureAttributes.indexOf(EGL_BLUE_SIZE); | - | ||||||||||||
| 292 | m_confAttrBlue = configureAttributes.at(i+1); | - | ||||||||||||
| 293 | i = configureAttributes.indexOf(EGL_ALPHA_SIZE); | - | ||||||||||||
| 294 | m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1);
| 0 | ||||||||||||
| 295 | - | |||||||||||||
| 296 | QVector<EGLConfig> configs(matching); | - | ||||||||||||
| 297 | eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching); | - | ||||||||||||
| 298 | if (!cfg && matching > 0)
| 0 | ||||||||||||
| 299 | cfg = configs.first(); never executed: cfg = configs.first(); | 0 | ||||||||||||
| 300 | - | |||||||||||||
| 301 | // Filter the list. Due to the EGL sorting rules configs with higher depth are | - | ||||||||||||
| 302 | // placed first when the minimum color channel sizes have been specified (i.e. the | - | ||||||||||||
| 303 | // QSurfaceFormat contains color sizes > 0). To prevent returning a 888 config | - | ||||||||||||
| 304 | // when the QSurfaceFormat explicitly asked for 565, go through the returned | - | ||||||||||||
| 305 | // configs and look for one that exactly matches the requested sizes. When no | - | ||||||||||||
| 306 | // sizes have been given, take the first, which will be a config with the smaller | - | ||||||||||||
| 307 | // (e.g. 16-bit) depth. | - | ||||||||||||
| 308 | for (int i = 0; i < configs.size(); ++i) {
| 0 | ||||||||||||
| 309 | if (filterConfig(configs[i]))
| 0 | ||||||||||||
| 310 | return configs.at(i); never executed: return configs.at(i); | 0 | ||||||||||||
| 311 | } never executed: end of block | 0 | ||||||||||||
| 312 | } while (q_reduceConfigAttributes(&configureAttributes)); never executed: end of block
| 0 | ||||||||||||
| 313 | - | |||||||||||||
| 314 | if (!cfg)
| 0 | ||||||||||||
| 315 | qWarning("Cannot find EGLConfig, returning null config"); never executed: QMessageLogger(__FILE__, 315, __PRETTY_FUNCTION__).warning("Cannot find EGLConfig, returning null config"); | 0 | ||||||||||||
| 316 | return cfg; never executed: return cfg; | 0 | ||||||||||||
| 317 | } | - | ||||||||||||
| 318 | - | |||||||||||||
| 319 | bool QEglConfigChooser::filterConfig(EGLConfig config) const | - | ||||||||||||
| 320 | { | - | ||||||||||||
| 321 | // If we are fine with the highest depth (e.g. RGB888 configs) even when something | - | ||||||||||||
| 322 | // smaller (565) was explicitly requested, do nothing. | - | ||||||||||||
| 323 | if (m_ignore)
| 0 | ||||||||||||
| 324 | return true; never executed: return true; | 0 | ||||||||||||
| 325 | - | |||||||||||||
| 326 | EGLint red = 0; | - | ||||||||||||
| 327 | EGLint green = 0; | - | ||||||||||||
| 328 | EGLint blue = 0; | - | ||||||||||||
| 329 | EGLint alpha = 0; | - | ||||||||||||
| 330 | - | |||||||||||||
| 331 | // Compare only if a size was given. Otherwise just accept. | - | ||||||||||||
| 332 | if (m_confAttrRed)
| 0 | ||||||||||||
| 333 | eglGetConfigAttrib(display(), config, EGL_RED_SIZE, &red); never executed: eglGetConfigAttrib(display(), config, 0x3024, &red); | 0 | ||||||||||||
| 334 | if (m_confAttrGreen)
| 0 | ||||||||||||
| 335 | eglGetConfigAttrib(display(), config, EGL_GREEN_SIZE, &green); never executed: eglGetConfigAttrib(display(), config, 0x3023, &green); | 0 | ||||||||||||
| 336 | if (m_confAttrBlue)
| 0 | ||||||||||||
| 337 | eglGetConfigAttrib(display(), config, EGL_BLUE_SIZE, &blue); never executed: eglGetConfigAttrib(display(), config, 0x3022, &blue); | 0 | ||||||||||||
| 338 | if (m_confAttrAlpha)
| 0 | ||||||||||||
| 339 | eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &alpha); never executed: eglGetConfigAttrib(display(), config, 0x3021, &alpha); | 0 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | return red == m_confAttrRed && green == m_confAttrGreen never executed: return red == m_confAttrRed && green == m_confAttrGreen && blue == m_confAttrBlue && alpha == m_confAttrAlpha; | 0 | ||||||||||||
| 342 | && blue == m_confAttrBlue && alpha == m_confAttrAlpha; never executed: return red == m_confAttrRed && green == m_confAttrGreen && blue == m_confAttrBlue && alpha == m_confAttrAlpha; | 0 | ||||||||||||
| 343 | } | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType) | - | ||||||||||||
| 346 | { | - | ||||||||||||
| 347 | QEglConfigChooser chooser(display); | - | ||||||||||||
| 348 | chooser.setSurfaceFormat(format); | - | ||||||||||||
| 349 | chooser.setSurfaceType(surfaceType); | - | ||||||||||||
| 350 | chooser.setIgnoreColorChannels(highestPixelFormat); | - | ||||||||||||
| 351 | - | |||||||||||||
| 352 | return chooser.chooseConfig(); never executed: return chooser.chooseConfig(); | 0 | ||||||||||||
| 353 | } | - | ||||||||||||
| 354 | - | |||||||||||||
| 355 | QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat) | - | ||||||||||||
| 356 | { | - | ||||||||||||
| 357 | QSurfaceFormat format; | - | ||||||||||||
| 358 | EGLint redSize = 0; | - | ||||||||||||
| 359 | EGLint greenSize = 0; | - | ||||||||||||
| 360 | EGLint blueSize = 0; | - | ||||||||||||
| 361 | EGLint alphaSize = 0; | - | ||||||||||||
| 362 | EGLint depthSize = 0; | - | ||||||||||||
| 363 | EGLint stencilSize = 0; | - | ||||||||||||
| 364 | EGLint sampleCount = 0; | - | ||||||||||||
| 365 | EGLint renderableType = 0; | - | ||||||||||||
| 366 | - | |||||||||||||
| 367 | eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); | - | ||||||||||||
| 368 | eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); | - | ||||||||||||
| 369 | eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); | - | ||||||||||||
| 370 | eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); | - | ||||||||||||
| 371 | eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); | - | ||||||||||||
| 372 | eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); | - | ||||||||||||
| 373 | eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); | - | ||||||||||||
| 374 | eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType); | - | ||||||||||||
| 375 | - | |||||||||||||
| 376 | if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT))
| 0 | ||||||||||||
| 377 | format.setRenderableType(QSurfaceFormat::OpenVG); never executed: format.setRenderableType(QSurfaceFormat::OpenVG); | 0 | ||||||||||||
| 378 | #ifdef EGL_VERSION_1_4 | - | ||||||||||||
| 379 | else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL
| 0 | ||||||||||||
| 380 | && (renderableType & EGL_OPENGL_BIT))
| 0 | ||||||||||||
| 381 | format.setRenderableType(QSurfaceFormat::OpenGL); never executed: format.setRenderableType(QSurfaceFormat::OpenGL); | 0 | ||||||||||||
| 382 | else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
| 0 | ||||||||||||
| 383 | #ifndef QT_NO_OPENGL | - | ||||||||||||
| 384 | && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
| 0 | ||||||||||||
| 385 | #endif | - | ||||||||||||
| 386 | && (renderableType & EGL_OPENGL_BIT))
| 0 | ||||||||||||
| 387 | format.setRenderableType(QSurfaceFormat::OpenGL); never executed: format.setRenderableType(QSurfaceFormat::OpenGL); | 0 | ||||||||||||
| 388 | #endif | - | ||||||||||||
| 389 | else | - | ||||||||||||
| 390 | format.setRenderableType(QSurfaceFormat::OpenGLES); never executed: format.setRenderableType(QSurfaceFormat::OpenGLES); | 0 | ||||||||||||
| 391 | - | |||||||||||||
| 392 | format.setRedBufferSize(redSize); | - | ||||||||||||
| 393 | format.setGreenBufferSize(greenSize); | - | ||||||||||||
| 394 | format.setBlueBufferSize(blueSize); | - | ||||||||||||
| 395 | format.setAlphaBufferSize(alphaSize); | - | ||||||||||||
| 396 | format.setDepthBufferSize(depthSize); | - | ||||||||||||
| 397 | format.setStencilBufferSize(stencilSize); | - | ||||||||||||
| 398 | format.setSamples(sampleCount); | - | ||||||||||||
| 399 | format.setStereo(false); // EGL doesn't support stereo buffers | - | ||||||||||||
| 400 | format.setSwapInterval(referenceFormat.swapInterval()); | - | ||||||||||||
| 401 | - | |||||||||||||
| 402 | // Clear the EGL error state because some of the above may | - | ||||||||||||
| 403 | // have errored out because the attribute is not applicable | - | ||||||||||||
| 404 | // to the surface type. Such errors don't matter. | - | ||||||||||||
| 405 | eglGetError(); | - | ||||||||||||
| 406 | - | |||||||||||||
| 407 | return format; never executed: return format; | 0 | ||||||||||||
| 408 | } | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | bool q_hasEglExtension(EGLDisplay display, const char* extensionName) | - | ||||||||||||
| 411 | { | - | ||||||||||||
| 412 | QList<QByteArray> extensions = | - | ||||||||||||
| 413 | QByteArray(reinterpret_cast<const char *> | - | ||||||||||||
| 414 | (eglQueryString(display, EGL_EXTENSIONS))).split(' '); | - | ||||||||||||
| 415 | return extensions.contains(extensionName); never executed: return extensions.contains(extensionName); | 0 | ||||||||||||
| 416 | } | - | ||||||||||||
| 417 | - | |||||||||||||
| 418 | struct AttrInfo { EGLint attr; const char *name; }; | - | ||||||||||||
| 419 | static struct AttrInfo attrs[] = { | - | ||||||||||||
| 420 | {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, | - | ||||||||||||
| 421 | {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, | - | ||||||||||||
| 422 | {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, | - | ||||||||||||
| 423 | {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, | - | ||||||||||||
| 424 | {EGL_RED_SIZE, "EGL_RED_SIZE"}, | - | ||||||||||||
| 425 | {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, | - | ||||||||||||
| 426 | {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, | - | ||||||||||||
| 427 | {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, | - | ||||||||||||
| 428 | {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, | - | ||||||||||||
| 429 | {EGL_LEVEL, "EGL_LEVEL"}, | - | ||||||||||||
| 430 | {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, | - | ||||||||||||
| 431 | {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, | - | ||||||||||||
| 432 | {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, | - | ||||||||||||
| 433 | {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, | - | ||||||||||||
| 434 | {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, | - | ||||||||||||
| 435 | {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, | - | ||||||||||||
| 436 | {EGL_SAMPLES, "EGL_SAMPLES"}, | - | ||||||||||||
| 437 | {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, | - | ||||||||||||
| 438 | {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, | - | ||||||||||||
| 439 | {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, | - | ||||||||||||
| 440 | {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, | - | ||||||||||||
| 441 | {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, | - | ||||||||||||
| 442 | {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, | - | ||||||||||||
| 443 | {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, | - | ||||||||||||
| 444 | {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, | - | ||||||||||||
| 445 | {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, | - | ||||||||||||
| 446 | {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, | - | ||||||||||||
| 447 | {-1, 0}}; | - | ||||||||||||
| 448 | - | |||||||||||||
| 449 | void q_printEglConfig(EGLDisplay display, EGLConfig config) | - | ||||||||||||
| 450 | { | - | ||||||||||||
| 451 | EGLint index; | - | ||||||||||||
| 452 | for (index = 0; attrs[index].attr != -1; ++index) {
| 0 | ||||||||||||
| 453 | EGLint value; | - | ||||||||||||
| 454 | if (eglGetConfigAttrib(display, config, attrs[index].attr, &value)) {
| 0 | ||||||||||||
| 455 | qDebug("\t%s: %d", attrs[index].name, (int)value); | - | ||||||||||||
| 456 | } never executed: end of block | 0 | ||||||||||||
| 457 | } never executed: end of block | 0 | ||||||||||||
| 458 | } never executed: end of block | 0 | ||||||||||||
| 459 | - | |||||||||||||
| 460 | #ifdef Q_OS_UNIX | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize) | - | ||||||||||||
| 463 | { | - | ||||||||||||
| 464 | #ifndef Q_OS_LINUX | - | ||||||||||||
| 465 | Q_UNUSED(framebufferDevice) | - | ||||||||||||
| 466 | #endif | - | ||||||||||||
| 467 | const int defaultPhysicalDpi = 100; | - | ||||||||||||
| 468 | static QSizeF size; | - | ||||||||||||
| 469 | - | |||||||||||||
| 470 | if (size.isEmpty()) {
| 0 | ||||||||||||
| 471 | // Note: in millimeters | - | ||||||||||||
| 472 | int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); | - | ||||||||||||
| 473 | int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); | - | ||||||||||||
| 474 | - | |||||||||||||
| 475 | if (width && height) {
| 0 | ||||||||||||
| 476 | size.setWidth(width); | - | ||||||||||||
| 477 | size.setHeight(height); | - | ||||||||||||
| 478 | return size; never executed: return size; | 0 | ||||||||||||
| 479 | } | - | ||||||||||||
| 480 | - | |||||||||||||
| 481 | int w = -1; | - | ||||||||||||
| 482 | int h = -1; | - | ||||||||||||
| 483 | QSize screenResolution; | - | ||||||||||||
| 484 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 485 | struct fb_var_screeninfo vinfo; | - | ||||||||||||
| 486 | - | |||||||||||||
| 487 | if (framebufferDevice != -1) {
| 0 | ||||||||||||
| 488 | if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) {
| 0 | ||||||||||||
| 489 | qWarning("eglconvenience: Could not query screen info"); | - | ||||||||||||
| 490 | } else { never executed: end of block | 0 | ||||||||||||
| 491 | w = vinfo.width; | - | ||||||||||||
| 492 | h = vinfo.height; | - | ||||||||||||
| 493 | screenResolution = QSize(vinfo.xres, vinfo.yres); | - | ||||||||||||
| 494 | } never executed: end of block | 0 | ||||||||||||
| 495 | } else | - | ||||||||||||
| 496 | #endif | - | ||||||||||||
| 497 | { | - | ||||||||||||
| 498 | // Use the provided screen size, when available, since some platforms may have their own | - | ||||||||||||
| 499 | // specific way to query it. Otherwise try querying it from the framebuffer. | - | ||||||||||||
| 500 | screenResolution = screenSize.isEmpty() ? q_screenSizeFromFb(framebufferDevice) : screenSize;
| 0 | ||||||||||||
| 501 | } never executed: end of block | 0 | ||||||||||||
| 502 | - | |||||||||||||
| 503 | size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w)); | - | ||||||||||||
| 504 | size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h)); | - | ||||||||||||
| 505 | - | |||||||||||||
| 506 | if (w <= 0 || h <= 0)
| 0 | ||||||||||||
| 507 | qWarning("Unable to query physical screen size, defaulting to %d dpi.\n" never executed: QMessageLogger(__FILE__, 507, __PRETTY_FUNCTION__).warning("Unable to query physical screen size, defaulting to %d dpi.\n" "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); | 0 | ||||||||||||
| 508 | "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " never executed: QMessageLogger(__FILE__, 507, __PRETTY_FUNCTION__).warning("Unable to query physical screen size, defaulting to %d dpi.\n" "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); | 0 | ||||||||||||
| 509 | "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); never executed: QMessageLogger(__FILE__, 507, __PRETTY_FUNCTION__).warning("Unable to query physical screen size, defaulting to %d dpi.\n" "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); | 0 | ||||||||||||
| 510 | } never executed: end of block | 0 | ||||||||||||
| 511 | - | |||||||||||||
| 512 | return size; never executed: return size; | 0 | ||||||||||||
| 513 | } | - | ||||||||||||
| 514 | - | |||||||||||||
| 515 | QSize q_screenSizeFromFb(int framebufferDevice) | - | ||||||||||||
| 516 | { | - | ||||||||||||
| 517 | #ifndef Q_OS_LINUX | - | ||||||||||||
| 518 | Q_UNUSED(framebufferDevice) | - | ||||||||||||
| 519 | #endif | - | ||||||||||||
| 520 | const int defaultWidth = 800; | - | ||||||||||||
| 521 | const int defaultHeight = 600; | - | ||||||||||||
| 522 | static QSize size; | - | ||||||||||||
| 523 | - | |||||||||||||
| 524 | if (size.isEmpty()) {
| 0 | ||||||||||||
| 525 | int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_WIDTH"); | - | ||||||||||||
| 526 | int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_HEIGHT"); | - | ||||||||||||
| 527 | - | |||||||||||||
| 528 | if (width && height) {
| 0 | ||||||||||||
| 529 | size.setWidth(width); | - | ||||||||||||
| 530 | size.setHeight(height); | - | ||||||||||||
| 531 | return size; never executed: return size; | 0 | ||||||||||||
| 532 | } | - | ||||||||||||
| 533 | - | |||||||||||||
| 534 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 535 | struct fb_var_screeninfo vinfo; | - | ||||||||||||
| 536 | int xres = -1; | - | ||||||||||||
| 537 | int yres = -1; | - | ||||||||||||
| 538 | - | |||||||||||||
| 539 | if (framebufferDevice != -1) {
| 0 | ||||||||||||
| 540 | if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) {
| 0 | ||||||||||||
| 541 | qWarning("eglconvenience: Could not read screen info"); | - | ||||||||||||
| 542 | } else { never executed: end of block | 0 | ||||||||||||
| 543 | xres = vinfo.xres; | - | ||||||||||||
| 544 | yres = vinfo.yres; | - | ||||||||||||
| 545 | } never executed: end of block | 0 | ||||||||||||
| 546 | } | - | ||||||||||||
| 547 | - | |||||||||||||
| 548 | size.setWidth(xres <= 0 ? defaultWidth : xres); | - | ||||||||||||
| 549 | size.setHeight(yres <= 0 ? defaultHeight : yres); | - | ||||||||||||
| 550 | #else | - | ||||||||||||
| 551 | size.setWidth(defaultWidth); | - | ||||||||||||
| 552 | size.setHeight(defaultHeight); | - | ||||||||||||
| 553 | #endif | - | ||||||||||||
| 554 | } never executed: end of block | 0 | ||||||||||||
| 555 | - | |||||||||||||
| 556 | return size; never executed: return size; | 0 | ||||||||||||
| 557 | } | - | ||||||||||||
| 558 | - | |||||||||||||
| 559 | int q_screenDepthFromFb(int framebufferDevice) | - | ||||||||||||
| 560 | { | - | ||||||||||||
| 561 | #ifndef Q_OS_LINUX | - | ||||||||||||
| 562 | Q_UNUSED(framebufferDevice) | - | ||||||||||||
| 563 | #endif | - | ||||||||||||
| 564 | const int defaultDepth = 32; | - | ||||||||||||
| 565 | static int depth = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEPTH"); | - | ||||||||||||
| 566 | - | |||||||||||||
| 567 | if (depth == 0) {
| 0 | ||||||||||||
| 568 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 569 | struct fb_var_screeninfo vinfo; | - | ||||||||||||
| 570 | - | |||||||||||||
| 571 | if (framebufferDevice != -1) {
| 0 | ||||||||||||
| 572 | if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1)
| 0 | ||||||||||||
| 573 | qWarning("eglconvenience: Could not query screen info"); never executed: QMessageLogger(__FILE__, 573, __PRETTY_FUNCTION__).warning("eglconvenience: Could not query screen info"); | 0 | ||||||||||||
| 574 | else | - | ||||||||||||
| 575 | depth = vinfo.bits_per_pixel; never executed: depth = vinfo.bits_per_pixel; | 0 | ||||||||||||
| 576 | } | - | ||||||||||||
| 577 | - | |||||||||||||
| 578 | if (depth <= 0)
| 0 | ||||||||||||
| 579 | depth = defaultDepth; never executed: depth = defaultDepth; | 0 | ||||||||||||
| 580 | #else | - | ||||||||||||
| 581 | depth = defaultDepth; | - | ||||||||||||
| 582 | #endif | - | ||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||
| 584 | - | |||||||||||||
| 585 | return depth; never executed: return depth; | 0 | ||||||||||||
| 586 | } | - | ||||||||||||
| 587 | - | |||||||||||||
| 588 | qreal q_refreshRateFromFb(int framebufferDevice) | - | ||||||||||||
| 589 | { | - | ||||||||||||
| 590 | #ifndef Q_OS_LINUX | - | ||||||||||||
| 591 | Q_UNUSED(framebufferDevice) | - | ||||||||||||
| 592 | #endif | - | ||||||||||||
| 593 | - | |||||||||||||
| 594 | static qreal rate = 0; | - | ||||||||||||
| 595 | - | |||||||||||||
| 596 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 597 | if (rate == 0) {
| 0 | ||||||||||||
| 598 | if (framebufferDevice != -1) {
| 0 | ||||||||||||
| 599 | struct fb_var_screeninfo vinfo; | - | ||||||||||||
| 600 | if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) != -1) {
| 0 | ||||||||||||
| 601 | const quint64 quot = quint64(vinfo.left_margin + vinfo.right_margin + vinfo.xres + vinfo.hsync_len) | - | ||||||||||||
| 602 | * quint64(vinfo.upper_margin + vinfo.lower_margin + vinfo.yres + vinfo.vsync_len) | - | ||||||||||||
| 603 | * vinfo.pixclock; | - | ||||||||||||
| 604 | if (quot)
| 0 | ||||||||||||
| 605 | rate = 1000000000000LLU / quot; never executed: rate = 1000000000000LLU / quot; | 0 | ||||||||||||
| 606 | } else { never executed: end of block | 0 | ||||||||||||
| 607 | qWarning("eglconvenience: Could not query screen info"); | - | ||||||||||||
| 608 | } never executed: end of block | 0 | ||||||||||||
| 609 | } | - | ||||||||||||
| 610 | } never executed: end of block | 0 | ||||||||||||
| 611 | #endif | - | ||||||||||||
| 612 | - | |||||||||||||
| 613 | if (rate == 0)
| 0 | ||||||||||||
| 614 | rate = 60; never executed: rate = 60; | 0 | ||||||||||||
| 615 | - | |||||||||||||
| 616 | return rate; never executed: return rate; | 0 | ||||||||||||
| 617 | } | - | ||||||||||||
| 618 | - | |||||||||||||
| 619 | #endif // Q_OS_UNIX | - | ||||||||||||
| 620 | - | |||||||||||||
| 621 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |