| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | class QSurfaceFormatPrivate | - |
| 5 | { | - |
| 6 | public: | - |
| 7 | explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = 0) | - |
| 8 | : ref(1) | - |
| 9 | , opts(_opts) | - |
| 10 | , redBufferSize(-1) | - |
| 11 | , greenBufferSize(-1) | - |
| 12 | , blueBufferSize(-1) | - |
| 13 | , alphaBufferSize(-1) | - |
| 14 | , depthSize(-1) | - |
| 15 | , stencilSize(-1) | - |
| 16 | , swapBehavior(QSurfaceFormat::DefaultSwapBehavior) | - |
| 17 | , numSamples(-1) | - |
| 18 | , renderableType(QSurfaceFormat::DefaultRenderableType) | - |
| 19 | , profile(QSurfaceFormat::NoProfile) | - |
| 20 | , major(2) | - |
| 21 | , minor(0) | - |
| 22 | , swapInterval(1) | - |
| 23 | { | - |
| 24 | } | - |
| 25 | | - |
| 26 | QSurfaceFormatPrivate(const QSurfaceFormatPrivate *other) | - |
| 27 | : ref(1), | - |
| 28 | opts(other->opts), | - |
| 29 | redBufferSize(other->redBufferSize), | - |
| 30 | greenBufferSize(other->greenBufferSize), | - |
| 31 | blueBufferSize(other->blueBufferSize), | - |
| 32 | alphaBufferSize(other->alphaBufferSize), | - |
| 33 | depthSize(other->depthSize), | - |
| 34 | stencilSize(other->stencilSize), | - |
| 35 | swapBehavior(other->swapBehavior), | - |
| 36 | numSamples(other->numSamples), | - |
| 37 | renderableType(other->renderableType), | - |
| 38 | profile(other->profile), | - |
| 39 | major(other->major), | - |
| 40 | minor(other->minor), | - |
| 41 | swapInterval(other->swapInterval) | - |
| 42 | { | - |
| 43 | } | - |
| 44 | | - |
| 45 | QAtomicInt ref; | - |
| 46 | QSurfaceFormat::FormatOptions opts; | - |
| 47 | int redBufferSize; | - |
| 48 | int greenBufferSize; | - |
| 49 | int blueBufferSize; | - |
| 50 | int alphaBufferSize; | - |
| 51 | int depthSize; | - |
| 52 | int stencilSize; | - |
| 53 | QSurfaceFormat::SwapBehavior swapBehavior; | - |
| 54 | int numSamples; | - |
| 55 | QSurfaceFormat::RenderableType renderableType; | - |
| 56 | QSurfaceFormat::OpenGLContextProfile profile; | - |
| 57 | int major; | - |
| 58 | int minor; | - |
| 59 | int swapInterval; | - |
| 60 | }; | - |
| 61 | QSurfaceFormat::QSurfaceFormat() : d(new QSurfaceFormatPrivate) | - |
| 62 | { | - |
| 63 | } | - |
| 64 | | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) : | - |
| 69 | d(new QSurfaceFormatPrivate(options)) | - |
| 70 | { | - |
| 71 | } | - |
| 72 | | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | void QSurfaceFormat::detach() | - |
| 77 | { | - |
| 78 | if (d->ref.load() != 1) { | - |
| 79 | QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d); | - |
| 80 | if (!d->ref.deref()) | - |
| 81 | delete d; | - |
| 82 | d = newd; | - |
| 83 | } | - |
| 84 | } | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | | - |
| 89 | QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other) | - |
| 90 | { | - |
| 91 | d = other.d; | - |
| 92 | d->ref.ref(); | - |
| 93 | } | - |
| 94 | | - |
| 95 | | - |
| 96 | | - |
| 97 | | - |
| 98 | QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other) | - |
| 99 | { | - |
| 100 | if (d != other.d) { | - |
| 101 | other.d->ref.ref(); | - |
| 102 | if (!d->ref.deref()) | - |
| 103 | delete d; | - |
| 104 | d = other.d; | - |
| 105 | } | - |
| 106 | return *this; | - |
| 107 | } | - |
| 108 | | - |
| 109 | | - |
| 110 | | - |
| 111 | | - |
| 112 | QSurfaceFormat::~QSurfaceFormat() | - |
| 113 | { | - |
| 114 | if (!d->ref.deref()) | - |
| 115 | delete d; | - |
| 116 | } | - |
| 117 | void QSurfaceFormat::setStereo(bool enable) | - |
| 118 | { | - |
| 119 | QSurfaceFormat::FormatOptions newOptions = d->opts; | - |
| 120 | if (enable) { | - |
| newOptions |= QSurfaceFormat::StereoBuffers; | |
| } else {newOptions&= ~.setFlag(QSurfaceFormat::StereoBuffers; | |
| }, enable); | |
| 121 | | - |
| 122 | if (int(newOptions) != int(d->opts)| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 123 | detach(); | - |
| 124 | d->opts = newOptions; | - |
| 125 | } never executed: end of block | 0 |
| 126 | } never executed: end of block | 0 |
| 127 | | - |
| 128 | | - |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | | - |
| 134 | int QSurfaceFormat::samples() const | - |
| 135 | { | - |
| 136 | return d->numSamples; | - |
| 137 | } | - |
| 138 | | - |
| 139 | | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | | - |
| 145 | void QSurfaceFormat::setSamples(int numSamples) | - |
| 146 | { | - |
| 147 | if (d->numSamples != numSamples) { | - |
| 148 | detach(); | - |
| 149 | d->numSamples = numSamples; | - |
| 150 | } | - |
| 151 | } | - |
| 152 | void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt) | - |
| 153 | { | - |
| 154 | const QSurfaceFormat::FormatOptions newOptions = d->opts | opt; | - |
| 155 | if (int(newOptions) != int(d->opts)) { | - |
| 156 | detach(); | - |
| 157 | d->opts = newOptions; | - |
| 158 | } | - |
| 159 | } | - |
| 160 | bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const | - |
| 161 | { | - |
| 162 | return d->opts & opt; | - |
| 163 | } | - |
| 164 | void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options) | - |
| 165 | { | - |
| 166 | if (int(d->opts) != int(options)) { | - |
| 167 | detach(); | - |
| 168 | d->opts = options; | - |
| 169 | } | - |
| 170 | } | - |
| 171 | void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on) | - |
| 172 | { | - |
| 173 | if (testOption(option) == on) | - |
| 174 | return; | - |
| 175 | detach(); | - |
| 176 | if (on) | - |
| 177 | d->opts |= option; | - |
| 178 | else | - |
| 179 | d->opts &= ~option; | - |
| 180 | } | - |
| 181 | bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option) const | - |
| 182 | { | - |
| 183 | return d->opts & option; | - |
| 184 | } | - |
| 185 | QSurfaceFormat::FormatOptions QSurfaceFormat::options() const | - |
| 186 | { | - |
| 187 | return d->opts; | - |
| 188 | } | - |
| 189 | | - |
| 190 | | - |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | void QSurfaceFormat::setDepthBufferSize(int size) | - |
| 196 | { | - |
| 197 | if (d->depthSize != size) { | - |
| 198 | detach(); | - |
| 199 | d->depthSize = size; | - |
| 200 | } | - |
| 201 | } | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | | - |
| 207 | | - |
| 208 | int QSurfaceFormat::depthBufferSize() const | - |
| 209 | { | - |
| 210 | return d->depthSize; | - |
| 211 | } | - |
| 212 | void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior) | - |
| 213 | { | - |
| 214 | if (d->swapBehavior != behavior) { | - |
| 215 | detach(); | - |
| 216 | d->swapBehavior = behavior; | - |
| 217 | } | - |
| 218 | } | - |
| 219 | | - |
| 220 | | - |
| 221 | | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const | - |
| 226 | { | - |
| 227 | return d->swapBehavior; | - |
| 228 | } | - |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | | - |
| 236 | bool QSurfaceFormat::hasAlpha() const | - |
| 237 | { | - |
| 238 | return d->alphaBufferSize > 0; | - |
| 239 | } | - |
| 240 | | - |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | void QSurfaceFormat::setStencilBufferSize(int size) | - |
| 247 | { | - |
| 248 | if (d->stencilSize != size) { | - |
| 249 | detach(); | - |
| 250 | d->stencilSize = size; | - |
| 251 | } | - |
| 252 | } | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | | - |
| 257 | | - |
| 258 | | - |
| 259 | int QSurfaceFormat::stencilBufferSize() const | - |
| 260 | { | - |
| 261 | return d->stencilSize; | - |
| 262 | } | - |
| 263 | | - |
| 264 | | - |
| 265 | | - |
| 266 | | - |
| 267 | int QSurfaceFormat::redBufferSize() const | - |
| 268 | { | - |
| 269 | return d->redBufferSize; | - |
| 270 | } | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| 274 | | - |
| 275 | int QSurfaceFormat::greenBufferSize() const | - |
| 276 | { | - |
| 277 | return d->greenBufferSize; | - |
| 278 | } | - |
| 279 | | - |
| 280 | | - |
| 281 | | - |
| 282 | | - |
| 283 | int QSurfaceFormat::blueBufferSize() const | - |
| 284 | { | - |
| 285 | return d->blueBufferSize; | - |
| 286 | } | - |
| 287 | | - |
| 288 | | - |
| 289 | | - |
| 290 | | - |
| 291 | int QSurfaceFormat::alphaBufferSize() const | - |
| 292 | { | - |
| 293 | return d->alphaBufferSize; | - |
| 294 | } | - |
| 295 | void QSurfaceFormat::setRedBufferSize(int size) | - |
| 296 | { | - |
| 297 | if (d->redBufferSize != size) { | - |
| 298 | detach(); | - |
| 299 | d->redBufferSize = size; | - |
| 300 | } | - |
| 301 | } | - |
| 302 | void QSurfaceFormat::setGreenBufferSize(int size) | - |
| 303 | { | - |
| 304 | if (d->greenBufferSize != size) { | - |
| 305 | detach(); | - |
| 306 | d->greenBufferSize = size; | - |
| 307 | } | - |
| 308 | } | - |
| 309 | void QSurfaceFormat::setBlueBufferSize(int size) | - |
| 310 | { | - |
| 311 | if (d->blueBufferSize != size) { | - |
| 312 | detach(); | - |
| 313 | d->blueBufferSize = size; | - |
| 314 | } | - |
| 315 | } | - |
| 316 | | - |
| 317 | | - |
| 318 | | - |
| 319 | | - |
| 320 | void QSurfaceFormat::setAlphaBufferSize(int size) | - |
| 321 | { | - |
| 322 | if (d->alphaBufferSize != size) { | - |
| 323 | detach(); | - |
| 324 | d->alphaBufferSize = size; | - |
| 325 | } | - |
| 326 | } | - |
| 327 | | - |
| 328 | | - |
| 329 | | - |
| 330 | | - |
| 331 | | - |
| 332 | | - |
| 333 | void QSurfaceFormat::setRenderableType(RenderableType type) | - |
| 334 | { | - |
| 335 | if (d->renderableType != type) { | - |
| 336 | detach(); | - |
| 337 | d->renderableType = type; | - |
| 338 | } | - |
| 339 | } | - |
| 340 | | - |
| 341 | | - |
| 342 | | - |
| 343 | | - |
| 344 | | - |
| 345 | | - |
| 346 | QSurfaceFormat::RenderableType QSurfaceFormat::renderableType() const | - |
| 347 | { | - |
| 348 | return d->renderableType; | - |
| 349 | } | - |
| 350 | | - |
| 351 | | - |
| 352 | | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | | - |
| 357 | void QSurfaceFormat::setProfile(OpenGLContextProfile profile) | - |
| 358 | { | - |
| 359 | if (d->profile != profile) { | - |
| 360 | detach(); | - |
| 361 | d->profile = profile; | - |
| 362 | } | - |
| 363 | } | - |
| 364 | | - |
| 365 | | - |
| 366 | | - |
| 367 | | - |
| 368 | | - |
| 369 | | - |
| 370 | | - |
| 371 | QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile() const | - |
| 372 | { | - |
| 373 | return d->profile; | - |
| 374 | } | - |
| 375 | | - |
| 376 | | - |
| 377 | | - |
| 378 | | - |
| 379 | void QSurfaceFormat::setMajorVersion(int major) | - |
| 380 | { | - |
| 381 | if (d->major != major) { | - |
| 382 | detach(); | - |
| 383 | d->major = major; | - |
| 384 | } | - |
| 385 | } | - |
| 386 | | - |
| 387 | | - |
| 388 | | - |
| 389 | | - |
| 390 | | - |
| 391 | | - |
| 392 | int QSurfaceFormat::majorVersion() const | - |
| 393 | { | - |
| 394 | return d->major; | - |
| 395 | } | - |
| 396 | | - |
| 397 | | - |
| 398 | | - |
| 399 | | - |
| 400 | | - |
| 401 | | - |
| 402 | void QSurfaceFormat::setMinorVersion(int minor) | - |
| 403 | { | - |
| 404 | if (d->minor != minor) { | - |
| 405 | detach(); | - |
| 406 | d->minor = minor; | - |
| 407 | } | - |
| 408 | } | - |
| 409 | | - |
| 410 | | - |
| 411 | | - |
| 412 | | - |
| 413 | int QSurfaceFormat::minorVersion() const | - |
| 414 | { | - |
| 415 | return d->minor; | - |
| 416 | } | - |
| 417 | | - |
| 418 | | - |
| 419 | | - |
| 420 | | - |
| 421 | | - |
| 422 | | - |
| 423 | QPair<int, int> QSurfaceFormat::version() const | - |
| 424 | { | - |
| 425 | return qMakePair(d->major, d->minor); | - |
| 426 | } | - |
| 427 | | - |
| 428 | | - |
| 429 | | - |
| 430 | | - |
| 431 | | - |
| 432 | | - |
| 433 | void QSurfaceFormat::setVersion(int major, int minor) | - |
| 434 | { | - |
| 435 | if (d->minor != minor || d->major != major) { | - |
| 436 | detach(); | - |
| 437 | d->minor = minor; | - |
| 438 | d->major = major; | - |
| 439 | } | - |
| 440 | } | - |
| 441 | void QSurfaceFormat::setSwapInterval(int interval) | - |
| 442 | { | - |
| 443 | if (d->swapInterval != interval) { | - |
| 444 | detach(); | - |
| 445 | d->swapInterval = interval; | - |
| 446 | } | - |
| 447 | } | - |
| 448 | int QSurfaceFormat::swapInterval() const | - |
| 449 | { | - |
| 450 | return d->swapInterval; | - |
| 451 | } | - |
| 452 | | - |
| 453 | namespace { namespace Q_QGS_qt_default_surface_format { typedef QSurfaceFormat Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QSurfaceFormat, Q_QGS_qt_default_surface_format::innerFunction, Q_QGS_qt_default_surface_format::guard> qt_default_surface_format; | - |
| 454 | void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format) | - |
| 455 | { | - |
| 456 | | - |
| 457 | if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))) { | - |
| 458 | QOpenGLContext *globalContext = QOpenGLContext::globalShareContext(); | - |
| 459 | if (globalContext && globalContext->isValid()) { | - |
| 460 | QMessageLogger(__FILE__, 767770, __PRETTY_FUNCTION__).warning("Warning: Setting a new default format with a different version or profile " | - |
| 461 | "after the global shared context is created may cause issues with context " | - |
| 462 | "sharing."); | - |
| 463 | } | - |
| 464 | } | - |
| 465 | | - |
| 466 | *qt_default_surface_format() = format; | - |
| 467 | } | - |
| 468 | QSurfaceFormat QSurfaceFormat::defaultFormat() | - |
| 469 | { | - |
| 470 | return *qt_default_surface_format(); | - |
| 471 | } | - |
| 472 | | - |
| 473 | | - |
| 474 | | - |
| 475 | | - |
| 476 | | - |
| 477 | | - |
| 478 | | - |
| 479 | bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b) | - |
| 480 | { | - |
| 481 | return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts | - |
| 482 | && a.d->stencilSize == b.d->stencilSize | - |
| 483 | && a.d->redBufferSize == b.d->redBufferSize | - |
| 484 | && a.d->greenBufferSize == b.d->greenBufferSize | - |
| 485 | && a.d->blueBufferSize == b.d->blueBufferSize | - |
| 486 | && a.d->alphaBufferSize == b.d->alphaBufferSize | - |
| 487 | && a.d->depthSize == b.d->depthSize | - |
| 488 | && a.d->numSamples == b.d->numSamples | - |
| 489 | && a.d->swapBehavior == b.d->swapBehavior | - |
| 490 | && a.d->profile == b.d->profile | - |
| 491 | && a.d->major == b.d->major | - |
| 492 | && a.d->minor == b.d->minor | - |
| 493 | && a.d->swapInterval == b.d->swapInterval); | - |
| 494 | } | - |
| 495 | | - |
| 496 | | - |
| 497 | | - |
| 498 | | - |
| 499 | | - |
| 500 | | - |
| 501 | | - |
| 502 | bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b) | - |
| 503 | { | - |
| 504 | return !(a == b); | - |
| 505 | } | - |
| 506 | | - |
| 507 | | - |
| 508 | QDebug operator<<(QDebug dbg, const QSurfaceFormat &f) | - |
| 509 | { | - |
| 510 | const QSurfaceFormatPrivate * const d = f.d; | - |
| 511 | QDebugStateSaver saver(dbg); | - |
| 512 | | - |
| 513 | dbg.nospace() << "QSurfaceFormat(" | - |
| 514 | << "version " << d->major << '.' << d->minor | - |
| 515 | << ", options " << d->opts | - |
| 516 | << ", depthBufferSize " << d->depthSize | - |
| 517 | << ", redBufferSize " << d->redBufferSize | - |
| 518 | << ", greenBufferSize " << d->greenBufferSize | - |
| 519 | << ", blueBufferSize " << d->blueBufferSize | - |
| 520 | << ", alphaBufferSize " << d->alphaBufferSize | - |
| 521 | << ", stencilBufferSize " << d->stencilSize | - |
| 522 | << ", samples " << d->numSamples | - |
| 523 | << ", swapBehavior " << d->swapBehavior | - |
| 524 | << ", swapInterval " << d->swapInterval | - |
| 525 | << ", profile " << d->profile | - |
| 526 | << ')'; | - |
| 527 | | - |
| 528 | return dbg; | - |
| 529 | } | - |
| 530 | | - |
| 531 | | - |
| 532 | | - |
| | |