146
147
148
149
150
151
152
155
156
157
158
159
160
161
162
163
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
205
206
207
208
209
210
211
212
213
214
215
216
219
220
221
222
223
224QSurfaceFormat::QSurfaceFormat() : d(
new QSurfaceFormatPrivate)
229
230
231QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
232 d(
new QSurfaceFormatPrivate(options))
237
238
239void QSurfaceFormat::detach()
241 if (d->ref.loadRelaxed() != 1) {
242 QSurfaceFormatPrivate *newd =
new QSurfaceFormatPrivate(d);
250
251
252QSurfaceFormat::QSurfaceFormat(
const QSurfaceFormat &other)
259
260
261QSurfaceFormat &QSurfaceFormat::operator=(
const QSurfaceFormat &other)
273
274
275QSurfaceFormat::~QSurfaceFormat()
282
283
284
285
286
287
288
291
292
293
294
295
296
297
298
299
300
301void QSurfaceFormat::setStereo(
bool enable)
303 QSurfaceFormat::FormatOptions newOptions = d->opts;
304 newOptions.setFlag(QSurfaceFormat::StereoBuffers, enable);
306 if (
int(newOptions) !=
int(d->opts)) {
308 d->opts = newOptions;
313
314
315
316
317
318
319int QSurfaceFormat::samples()
const
321 return d->numSamples;
325
326
327
328
329
330void QSurfaceFormat::setSamples(
int numSamples)
332 if (d->numSamples != numSamples) {
334 d->numSamples = numSamples;
339
340
341
342
343
344
345
346
347
348void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
350 if (
int(d->opts) !=
int(options)) {
357
358
359
360
361
362
363
364
365
366void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option,
bool on)
368 if (testOption(option) == on)
378
379
380
381
382
383
384bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option)
const
386 return d->opts & option;
390
391
392
393
394
395
396QSurfaceFormat::FormatOptions QSurfaceFormat::options()
const
402
403
404
405
406void QSurfaceFormat::setDepthBufferSize(
int size)
408 if (d->depthSize != size) {
415
416
417
418
419int QSurfaceFormat::depthBufferSize()
const
425
426
427
428
429
430
431void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
433 if (d->swapBehavior != behavior) {
435 d->swapBehavior = behavior;
440
441
442
443
444QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior()
const
446 return d->swapBehavior;
450
451
452
453
454
455bool QSurfaceFormat::hasAlpha()
const
457 return d->alphaBufferSize > 0;
461
462
463
464
465void QSurfaceFormat::setStencilBufferSize(
int size)
467 if (d->stencilSize != size) {
469 d->stencilSize = size;
474
475
476
477
478int QSurfaceFormat::stencilBufferSize()
const
480 return d->stencilSize;
484
485
486int QSurfaceFormat::redBufferSize()
const
488 return d->redBufferSize;
492
493
494int QSurfaceFormat::greenBufferSize()
const
496 return d->greenBufferSize;
500
501
502int QSurfaceFormat::blueBufferSize()
const
504 return d->blueBufferSize;
508
509
510int QSurfaceFormat::alphaBufferSize()
const
512 return d->alphaBufferSize;
516
517
518void QSurfaceFormat::setRedBufferSize(
int size)
520 if (d->redBufferSize != size) {
522 d->redBufferSize = size;
527
528
529void QSurfaceFormat::setGreenBufferSize(
int size)
531 if (d->greenBufferSize != size) {
533 d->greenBufferSize = size;
538
539
540void QSurfaceFormat::setBlueBufferSize(
int size)
542 if (d->blueBufferSize != size) {
544 d->blueBufferSize = size;
549
550
551void QSurfaceFormat::setAlphaBufferSize(
int size)
553 if (d->alphaBufferSize != size) {
555 d->alphaBufferSize = size;
560
561
562
563
564
565
566
567
568
569
570
571
572
573void QSurfaceFormat::setColorComponentType(ColorComponentType type)
575 if (d->colorComponentType != type) {
577 d->colorComponentType = type;
582
583
584
585
586
587
588QSurfaceFormat::ColorComponentType QSurfaceFormat::colorComponentType()
const
590 return d->colorComponentType;
594
595
596
597
598void QSurfaceFormat::setRenderableType(RenderableType type)
600 if (d->renderableType != type) {
602 d->renderableType = type;
607
608
609
610
611QSurfaceFormat::RenderableType QSurfaceFormat::renderableType()
const
613 return d->renderableType;
617
618
619
620
621
622void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
624 if (d->profile != profile) {
626 d->profile = profile;
631
632
633
634
635
636QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile()
const
642
643
644void QSurfaceFormat::setMajorVersion(
int major)
646 if (d->major != major) {
653
654
655
656
657int QSurfaceFormat::majorVersion()
const
663
664
665
666
667void QSurfaceFormat::setMinorVersion(
int minor)
669 if (d->minor != minor) {
676
677
678int QSurfaceFormat::minorVersion()
const
684
685
686
687
688std::pair<
int,
int> QSurfaceFormat::version()
const
690 return std::pair(d->major, d->minor);
694
695
696
697
698void QSurfaceFormat::setVersion(
int major,
int minor)
700 if (d->minor != minor || d->major != major) {
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727void QSurfaceFormat::setSwapInterval(
int interval)
729 if (d->swapInterval != interval) {
731 d->swapInterval = interval;
736
737
738
739
740
741
742int QSurfaceFormat::swapInterval()
const
744 return d->swapInterval;
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768void QSurfaceFormat::setColorSpace(
const QColorSpace &colorSpace)
770 if (d->colorSpace != colorSpace) {
772 d->colorSpace = colorSpace;
776#if QT_DEPRECATED_SINCE(6
, 0
)
778
779
780
781
782
783
784
785
786
787void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
789 switch (colorSpace) {
790 case DefaultColorSpace:
791 setColorSpace(QColorSpace());
794 setColorSpace(QColorSpace::SRgb);
801
802
803
804
805
806
807const QColorSpace &QSurfaceFormat::colorSpace()
const
809 return d->colorSpace;
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831void QSurfaceFormat::setDefaultFormat(
const QSurfaceFormat &format)
835 QOpenGLContext *globalContext = qt_gl_global_share_context();
836 if (globalContext && globalContext->isValid()) {
837 qWarning(
"Warning: Setting a new default format with a different version or profile "
838 "after the global shared context is created may cause issues with context "
843 *qt_default_surface_format() = format;
847
848
849
850
851
852
853
854QSurfaceFormat QSurfaceFormat::defaultFormat()
856 return *qt_default_surface_format();
860
861
862
863
864
867
868
869
870
871
874
875
876bool QSurfaceFormat::equals(
const QSurfaceFormat& other)
const noexcept
878 return (d == other.d) || ((
int) d->opts == (
int) other.d->opts
879 && d->stencilSize == other.d->stencilSize
880 && d->redBufferSize == other.d->redBufferSize
881 && d->greenBufferSize == other.d->greenBufferSize
882 && d->blueBufferSize == other.d->blueBufferSize
883 && d->alphaBufferSize == other.d->alphaBufferSize
884 && d->depthSize == other.d->depthSize
885 && d->numSamples == other.d->numSamples
886 && d->swapBehavior == other.d->swapBehavior
887 && d->profile == other.d->profile
888 && d->major == other.d->major
889 && d->minor == other.d->minor
890 && d->swapInterval == other.d->swapInterval);
893#ifndef QT_NO_DEBUG_STREAM
897 QDebugStateSaver saver(dbg);
899 dbg.nospace() <<
"QSurfaceFormat("
901 <<
", options " << d->opts
909 <<
", swapBehavior " << d->swapBehavior
911 <<
", colorSpace " << d->colorSpace
912 <<
", profile " << d->profile
Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames, { { Qt::DisplayRole, "display" }, { Qt::DecorationRole, "decoration" }, { Qt::EditRole, "edit" }, { Qt::ToolTipRole, "toolTip" }, { Qt::StatusTipRole, "statusTip" }, { Qt::WhatsThisRole, "whatsThis" }, }) const QHash< int