1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qsurfaceformat.h"
5
6#include <QtCore/qatomic.h>
7#include <QtCore/QDebug>
8#include <QOpenGLContext>
9#include <QtGui/qcolorspace.h>
10#include <QtGui/qguiapplication.h>
11
12#ifndef QT_NO_OPENGL
13#include <QtGui/private/qopenglcontext_p.h>
14#endif
15
16#ifdef major
17#undef major
18#endif
19
20#ifdef minor
21#undef minor
22#endif
23
24QT_BEGIN_NAMESPACE
25
26class QSurfaceFormatPrivate
27{
28public:
29 explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = { })
30 : ref(1)
31 , opts(_opts)
32 , redBufferSize(-1)
33 , greenBufferSize(-1)
34 , blueBufferSize(-1)
35 , alphaBufferSize(-1)
36 , depthSize(-1)
37 , stencilSize(-1)
38 , swapBehavior(QSurfaceFormat::DefaultSwapBehavior)
39 , numSamples(-1)
40 , renderableType(QSurfaceFormat::DefaultRenderableType)
41 , profile(QSurfaceFormat::NoProfile)
42 , major(2)
43 , minor(0)
44 , swapInterval(1) // default to vsync
45 {
46 }
47
48 QSurfaceFormatPrivate(const QSurfaceFormatPrivate *other)
49 : ref(1),
50 opts(other->opts),
51 redBufferSize(other->redBufferSize),
52 greenBufferSize(other->greenBufferSize),
53 blueBufferSize(other->blueBufferSize),
54 alphaBufferSize(other->alphaBufferSize),
55 depthSize(other->depthSize),
56 stencilSize(other->stencilSize),
57 swapBehavior(other->swapBehavior),
58 numSamples(other->numSamples),
59 renderableType(other->renderableType),
60 profile(other->profile),
61 major(other->major),
62 minor(other->minor),
63 swapInterval(other->swapInterval),
64 colorSpace(other->colorSpace)
65 {
66 }
67
68 QAtomicInt ref;
69 QSurfaceFormat::FormatOptions opts;
70 int redBufferSize;
71 int greenBufferSize;
72 int blueBufferSize;
73 int alphaBufferSize;
74 int depthSize;
75 int stencilSize;
76 QSurfaceFormat::SwapBehavior swapBehavior;
77 int numSamples;
78 QSurfaceFormat::RenderableType renderableType;
79 QSurfaceFormat::OpenGLContextProfile profile;
80 int major;
81 int minor;
82 int swapInterval;
83 QColorSpace colorSpace;
84};
85
86/*!
87 \class QSurfaceFormat
88 \since 5.0
89 \brief The QSurfaceFormat class represents the format of a QSurface.
90 \inmodule QtGui
91
92 The format includes the size of the color buffers, red, green, and blue;
93 the size of the alpha buffer; the size of the depth and stencil buffers;
94 and number of samples per pixel for multisampling. In addition, the format
95 contains surface configuration parameters such as OpenGL profile and
96 version for rendering, whether or not to enable stereo buffers, and swap
97 behaviour.
98
99 \note When troubleshooting context or window format issues, it can be
100 helpful to enable the logging category \c{qt.qpa.gl}. Depending on the
101 platform, this may print useful debug information when it comes to OpenGL
102 initialization and the native visual or framebuffer configurations which
103 QSurfaceFormat gets mapped to.
104*/
105
106/*!
107 \enum QSurfaceFormat::FormatOption
108
109 This enum contains format options for use with QSurfaceFormat.
110
111 \value StereoBuffers Used to request stereo buffers in the surface format.
112 \value DebugContext Used to request a debug context with extra debugging information.
113 \value DeprecatedFunctions Used to request that deprecated functions be included
114 in the OpenGL context profile. If not specified, you should get a forward compatible context
115 without support functionality marked as deprecated. This requires OpenGL version 3.0 or higher.
116 \value ResetNotification Enables notifications about resets of the OpenGL context. The status is then
117 queryable via the context's \l{QOpenGLContext::isValid()}{isValid()} function. Note that not setting
118 this flag does not guarantee that context state loss never occurs. Additionally, some implementations
119 may choose to report context loss regardless of this flag. Platforms that support dynamically enabling
120 the monitoring of the loss of context, such as, Windows with WGL, or Linux/X11 (xcb) with GLX, will
121 monitor the status in every call to \l{QOpenGLContext::makeCurrent()}{makeCurrent()}. See
122 \l{QOpenGLContext::isValid()}{isValid()} for more information on this.
123 \value ProtectedContent Enables access to protected content. This allows the GPU to operate on protected
124 resources (surfaces, buffers, textures), for example DRM-protected video content.
125 Currently only implemented for EGL.
126*/
127
128/*!
129 \enum QSurfaceFormat::SwapBehavior
130
131 This enum is used by QSurfaceFormat to specify the swap behaviour of a surface. The swap behaviour
132 is mostly transparent to the application, but it affects factors such as rendering latency and
133 throughput.
134
135 \value DefaultSwapBehavior The default, unspecified swap behaviour of the platform.
136 \value SingleBuffer Used to request single buffering, which might result in flickering
137 when OpenGL rendering is done directly to screen without an intermediate offscreen
138 buffer.
139 \value DoubleBuffer This is typically the default swap behaviour on desktop platforms,
140 consisting of one back buffer and one front buffer. Rendering is done to the back
141 buffer, and then the back buffer and front buffer are swapped, or the contents of
142 the back buffer are copied to the front buffer, depending on the implementation.
143 \value TripleBuffer This swap behaviour is sometimes used in order to decrease the
144 risk of skipping a frame when the rendering rate is just barely keeping up with
145 the screen refresh rate. Depending on the platform it might also lead to slightly
146 more efficient use of the GPU due to improved pipelining behaviour. Triple buffering
147 comes at the cost of an extra frame of memory usage and latency, and might not be
148 supported depending on the underlying platform.
149*/
150
151/*!
152 \enum QSurfaceFormat::RenderableType
153
154 This enum specifies the rendering backend for the surface.
155
156 \value DefaultRenderableType The default, unspecified rendering method
157 \value OpenGL Desktop OpenGL rendering
158 \value OpenGLES OpenGL ES 2.0 rendering
159 \value OpenVG Open Vector Graphics rendering
160*/
161
162/*!
163 \enum QSurfaceFormat::OpenGLContextProfile
164
165 This enum is used to specify the OpenGL context profile, in
166 conjunction with QSurfaceFormat::setMajorVersion() and
167 QSurfaceFormat::setMinorVersion().
168
169 Profiles are exposed in OpenGL 3.2 and above, and are used
170 to choose between a restricted core profile, and a compatibility
171 profile which might contain deprecated support functionality.
172
173 Note that the core profile might still contain functionality that
174 is deprecated and scheduled for removal in a higher version. To
175 get access to the deprecated functionality for the core profile
176 in the set OpenGL version you can use the QSurfaceFormat format option
177 QSurfaceFormat::DeprecatedFunctions.
178
179 \value NoProfile OpenGL version is lower than 3.2. For 3.2 and newer this is same as CoreProfile.
180 \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available.
181 \value CompatibilityProfile Functionality from earlier OpenGL versions is available.
182*/
183
184/*!
185 \enum QSurfaceFormat::ColorSpace
186 \deprecated [6.0] Use setColorSpace(QColorSpace) instead
187
188 This enum is used to specify the preferred color space, controlling if the
189 window's associated default framebuffer is able to do updates and blending
190 in a given encoding instead of the standard linear operations.
191
192 \value DefaultColorSpace The default, unspecified color space.
193
194 \value sRGBColorSpace When \c{GL_ARB_framebuffer_sRGB} or
195 \c{GL_EXT_framebuffer_sRGB} is supported by the platform and this value is
196 set, the window will be created with an sRGB-capable default
197 framebuffer. Note that some platforms may return windows with a sRGB-capable
198 default framebuffer even when not requested explicitly.
199 */
200
201/*!
202 Constructs a default initialized QSurfaceFormat.
203
204 \note By default OpenGL 2.0 is requested since this provides the highest
205 grade of portability between platforms and OpenGL implementations.
206*/
207QSurfaceFormat::QSurfaceFormat() : d(new QSurfaceFormatPrivate)
208{
209}
210
211/*!
212 Constructs a QSurfaceFormat with the given format \a options.
213*/
214QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
215 d(new QSurfaceFormatPrivate(options))
216{
217}
218
219/*!
220 \internal
221*/
222void QSurfaceFormat::detach()
223{
224 if (d->ref.loadRelaxed() != 1) {
225 QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d);
226 if (!d->ref.deref())
227 delete d;
228 d = newd;
229 }
230}
231
232/*!
233 Constructs a copy of \a other.
234*/
235QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other)
236{
237 d = other.d;
238 d->ref.ref();
239}
240
241/*!
242 Assigns \a other to this object.
243*/
244QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other)
245{
246 if (d != other.d) {
247 other.d->ref.ref();
248 if (!d->ref.deref())
249 delete d;
250 d = other.d;
251 }
252 return *this;
253}
254
255/*!
256 Destroys the QSurfaceFormat.
257*/
258QSurfaceFormat::~QSurfaceFormat()
259{
260 if (!d->ref.deref())
261 delete d;
262}
263
264/*!
265 \fn bool QSurfaceFormat::stereo() const
266
267 Returns \c true if stereo buffering is enabled; otherwise returns
268 false. Stereo buffering is disabled by default.
269
270 \sa setStereo()
271*/
272
273/*!
274 If \a enable is true enables stereo buffering; otherwise disables
275 stereo buffering.
276
277 Stereo buffering is disabled by default.
278
279 Stereo buffering provides extra color buffers to generate left-eye
280 and right-eye images.
281
282 \sa stereo()
283*/
284void QSurfaceFormat::setStereo(bool enable)
285{
286 QSurfaceFormat::FormatOptions newOptions = d->opts;
287 newOptions.setFlag(flag: QSurfaceFormat::StereoBuffers, on: enable);
288
289 if (int(newOptions) != int(d->opts)) {
290 detach();
291 d->opts = newOptions;
292 }
293}
294
295/*!
296 Returns the number of samples per pixel when multisampling is
297 enabled, or \c -1 when multisampling is disabled. The default
298 return value is \c -1.
299
300 \sa setSamples()
301*/
302int QSurfaceFormat::samples() const
303{
304 return d->numSamples;
305}
306
307/*!
308 Set the preferred number of samples per pixel when multisampling
309 is enabled to \a numSamples. By default, multisampling is disabled.
310
311 \sa samples()
312*/
313void QSurfaceFormat::setSamples(int numSamples)
314{
315 if (d->numSamples != numSamples) {
316 detach();
317 d->numSamples = numSamples;
318 }
319}
320
321/*!
322 \since 5.3
323
324 Sets the format options to \a options.
325
326 To verify that an option was respected, compare the actual format to the
327 requested format after surface/context creation.
328
329 \sa options(), testOption()
330*/
331void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
332{
333 if (int(d->opts) != int(options)) {
334 detach();
335 d->opts = options;
336 }
337}
338
339/*!
340 \since 5.3
341
342 Sets the format option \a option if \a on is true; otherwise, clears the option.
343
344 To verify that an option was respected, compare the actual format to the
345 requested format after surface/context creation.
346
347 \sa setOptions(), options(), testOption()
348*/
349void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on)
350{
351 if (testOption(option) == on)
352 return;
353 detach();
354 if (on)
355 d->opts |= option;
356 else
357 d->opts &= ~option;
358}
359
360/*!
361 \since 5.3
362
363 Returns true if the format option \a option is set; otherwise returns false.
364
365 \sa options()
366*/
367bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option) const
368{
369 return d->opts & option;
370}
371
372/*!
373 \since 5.3
374
375 Returns the currently set format options.
376
377 \sa setOption(), setOptions(), testOption()
378*/
379QSurfaceFormat::FormatOptions QSurfaceFormat::options() const
380{
381 return d->opts;
382}
383
384/*!
385 Set the minimum depth buffer size to \a size.
386
387 \sa depthBufferSize()
388*/
389void QSurfaceFormat::setDepthBufferSize(int size)
390{
391 if (d->depthSize != size) {
392 detach();
393 d->depthSize = size;
394 }
395}
396
397/*!
398 Returns the depth buffer size.
399
400 \sa setDepthBufferSize()
401*/
402int QSurfaceFormat::depthBufferSize() const
403{
404 return d->depthSize;
405}
406
407/*!
408 Set the swap \a behavior of the surface.
409
410 The swap behavior specifies whether single, double, or triple
411 buffering is desired. The default, DefaultSwapBehavior,
412 gives the default swap behavior of the platform.
413*/
414void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
415{
416 if (d->swapBehavior != behavior) {
417 detach();
418 d->swapBehavior = behavior;
419 }
420}
421
422/*!
423 Returns the configured swap behaviour.
424
425 \sa setSwapBehavior()
426*/
427QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const
428{
429 return d->swapBehavior;
430}
431
432/*!
433 Returns \c true if the alpha buffer size is greater than zero.
434
435 This means that the surface might be used with per pixel
436 translucency effects.
437*/
438bool QSurfaceFormat::hasAlpha() const
439{
440 return d->alphaBufferSize > 0;
441}
442
443/*!
444 Set the preferred stencil buffer size to \a size bits.
445
446 \sa stencilBufferSize()
447*/
448void QSurfaceFormat::setStencilBufferSize(int size)
449{
450 if (d->stencilSize != size) {
451 detach();
452 d->stencilSize = size;
453 }
454}
455
456/*!
457 Returns the stencil buffer size in bits.
458
459 \sa setStencilBufferSize()
460*/
461int QSurfaceFormat::stencilBufferSize() const
462{
463 return d->stencilSize;
464}
465
466/*!
467 Get the size in bits of the red channel of the color buffer.
468*/
469int QSurfaceFormat::redBufferSize() const
470{
471 return d->redBufferSize;
472}
473
474/*!
475 Get the size in bits of the green channel of the color buffer.
476*/
477int QSurfaceFormat::greenBufferSize() const
478{
479 return d->greenBufferSize;
480}
481
482/*!
483 Get the size in bits of the blue channel of the color buffer.
484*/
485int QSurfaceFormat::blueBufferSize() const
486{
487 return d->blueBufferSize;
488}
489
490/*!
491 Get the size in bits of the alpha channel of the color buffer.
492*/
493int QSurfaceFormat::alphaBufferSize() const
494{
495 return d->alphaBufferSize;
496}
497
498/*!
499 Set the desired \a size in bits of the red channel of the color buffer.
500*/
501void QSurfaceFormat::setRedBufferSize(int size)
502{
503 if (d->redBufferSize != size) {
504 detach();
505 d->redBufferSize = size;
506 }
507}
508
509/*!
510 Set the desired \a size in bits of the green channel of the color buffer.
511*/
512void QSurfaceFormat::setGreenBufferSize(int size)
513{
514 if (d->greenBufferSize != size) {
515 detach();
516 d->greenBufferSize = size;
517 }
518}
519
520/*!
521 Set the desired \a size in bits of the blue channel of the color buffer.
522*/
523void QSurfaceFormat::setBlueBufferSize(int size)
524{
525 if (d->blueBufferSize != size) {
526 detach();
527 d->blueBufferSize = size;
528 }
529}
530
531/*!
532 Set the desired \a size in bits of the alpha channel of the color buffer.
533*/
534void QSurfaceFormat::setAlphaBufferSize(int size)
535{
536 if (d->alphaBufferSize != size) {
537 detach();
538 d->alphaBufferSize = size;
539 }
540}
541
542/*!
543 Sets the desired renderable \a type.
544
545 Chooses between desktop OpenGL, OpenGL ES, and OpenVG.
546*/
547void QSurfaceFormat::setRenderableType(RenderableType type)
548{
549 if (d->renderableType != type) {
550 detach();
551 d->renderableType = type;
552 }
553}
554
555/*!
556 Gets the renderable type.
557
558 Chooses between desktop OpenGL, OpenGL ES, and OpenVG.
559*/
560QSurfaceFormat::RenderableType QSurfaceFormat::renderableType() const
561{
562 return d->renderableType;
563}
564
565/*!
566 Sets the desired OpenGL context \a profile.
567
568 This setting is ignored if the requested OpenGL version is
569 less than 3.2.
570*/
571void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
572{
573 if (d->profile != profile) {
574 detach();
575 d->profile = profile;
576 }
577}
578
579/*!
580 Get the configured OpenGL context profile.
581
582 This setting is ignored if the requested OpenGL version is
583 less than 3.2.
584*/
585QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile() const
586{
587 return d->profile;
588}
589
590/*!
591 Sets the desired \a major OpenGL version.
592*/
593void QSurfaceFormat::setMajorVersion(int major)
594{
595 if (d->major != major) {
596 detach();
597 d->major = major;
598 }
599}
600
601/*!
602 Returns the major OpenGL version.
603
604 The default version is 2.0.
605*/
606int QSurfaceFormat::majorVersion() const
607{
608 return d->major;
609}
610
611/*!
612 Sets the desired \a minor OpenGL version.
613
614 The default version is 2.0.
615*/
616void QSurfaceFormat::setMinorVersion(int minor)
617{
618 if (d->minor != minor) {
619 detach();
620 d->minor = minor;
621 }
622}
623
624/*!
625 Returns the minor OpenGL version.
626*/
627int QSurfaceFormat::minorVersion() const
628{
629 return d->minor;
630}
631
632/*!
633 Returns a std::pair<int, int> representing the OpenGL version.
634
635 Useful for version checks, for example format.version() >= std::pair(3, 2)
636*/
637std::pair<int, int> QSurfaceFormat::version() const
638{
639 return std::pair(d->major, d->minor);
640}
641
642/*!
643 Sets the desired \a major and \a minor OpenGL versions.
644
645 The default version is 2.0.
646*/
647void QSurfaceFormat::setVersion(int major, int minor)
648{
649 if (d->minor != minor || d->major != major) {
650 detach();
651 d->minor = minor;
652 d->major = major;
653 }
654}
655
656/*!
657 Sets the preferred swap interval. The swap interval specifies the
658 minimum number of video frames that are displayed before a buffer
659 swap occurs. This can be used to sync the GL drawing into a window
660 to the vertical refresh of the screen.
661
662 Setting an \a interval value of 0 will turn the vertical refresh
663 syncing off, any value higher than 0 will turn the vertical
664 syncing on. Setting \a interval to a higher value, for example 10,
665 results in having 10 vertical retraces between every buffer swap.
666
667 The default interval is 1.
668
669 Changing the swap interval may not be supported by the underlying
670 platform. In this case, the request will be silently ignored.
671
672 \since 5.3
673
674 \sa swapInterval()
675 */
676void QSurfaceFormat::setSwapInterval(int interval)
677{
678 if (d->swapInterval != interval) {
679 detach();
680 d->swapInterval = interval;
681 }
682}
683
684/*!
685 Returns the swap interval.
686
687 \since 5.3
688
689 \sa setSwapInterval()
690*/
691int QSurfaceFormat::swapInterval() const
692{
693 return d->swapInterval;
694}
695
696/*!
697 Sets the preferred \a colorSpace.
698
699 For example, this allows requesting windows with default framebuffers that
700 are sRGB-capable on platforms that support it.
701
702 \note When the requested color space is not supported by the platform, the
703 request is ignored. Query the QSurfaceFormat after window creation to verify
704 if the color space request could be honored or not.
705
706 \note This setting controls if the default framebuffer of the window is
707 capable of updates and blending in a given color space. It does not change
708 applications' output by itself. The applications' rendering code will still
709 have to opt in via the appropriate OpenGL calls to enable updates and
710 blending to be performed in the given color space instead of using the
711 standard linear operations.
712
713 \since 6.0
714
715 \sa colorSpace()
716 */
717void QSurfaceFormat::setColorSpace(const QColorSpace &colorSpace)
718{
719 if (d->colorSpace != colorSpace) {
720 detach();
721 d->colorSpace = colorSpace;
722 }
723}
724
725#if QT_DEPRECATED_SINCE(6, 0)
726/*!
727 \overload
728 \deprecated [6.0] Use setColorSpace(QColorSpace) instead.
729
730 Sets the colorspace to one of the predefined values.
731
732 \since 5.10
733
734 \sa colorSpace()
735 */
736void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
737{
738 switch (colorSpace) {
739 case DefaultColorSpace:
740 setColorSpace(QColorSpace());
741 break;
742 case sRGBColorSpace:
743 setColorSpace(QColorSpace::SRgb);
744 break;
745 }
746}
747#endif // QT_DEPRECATED_SINCE(6, 0)
748
749/*!
750 \return the color space.
751
752 \since 5.10
753
754 \sa setColorSpace()
755*/
756const QColorSpace &QSurfaceFormat::colorSpace() const
757{
758 return d->colorSpace;
759}
760
761Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
762
763/*!
764 Sets the global default surface \a format.
765
766 This format is used by default in QOpenGLContext, QWindow, QOpenGLWidget and
767 similar classes.
768
769 It can always be overridden on a per-instance basis by using the class in
770 question's own setFormat() function. However, it is often more convenient to
771 set the format for all windows once at the start of the application. It also
772 guarantees proper behavior in cases where shared contexts are required,
773 because setting the format via this function guarantees that all contexts
774 and surfaces, even the ones created internally by Qt, will use the same
775 format.
776
777 \since 5.4
778 \sa defaultFormat()
779 */
780void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format)
781{
782#ifndef QT_NO_OPENGL
783 if (qApp) {
784 QOpenGLContext *globalContext = qt_gl_global_share_context();
785 if (globalContext && globalContext->isValid()) {
786 qWarning(msg: "Warning: Setting a new default format with a different version or profile "
787 "after the global shared context is created may cause issues with context "
788 "sharing.");
789 }
790 }
791#endif
792 *qt_default_surface_format() = format;
793}
794
795/*!
796 Returns the global default surface format.
797
798 When setDefaultFormat() is not called, this is a default-constructed QSurfaceFormat.
799
800 \since 5.4
801 \sa setDefaultFormat()
802 */
803QSurfaceFormat QSurfaceFormat::defaultFormat()
804{
805 return *qt_default_surface_format();
806}
807
808/*!
809 \fn bool QSurfaceFormat::operator==(const QSurfaceFormat& lhs, const QSurfaceFormat& rhs)
810
811 Returns \c true if all the options of the two QSurfaceFormat objects
812 \a lhs and \a rhs are equal.
813*/
814
815/*!
816 \fn bool QSurfaceFormat::operator!=(const QSurfaceFormat& lhs, const QSurfaceFormat& rhs)
817
818 Returns \c false if all the options of the two QSurfaceFormat objects
819 \a lhs and \a rhs are equal; otherwise returns \c true.
820*/
821
822/*!
823 \internal
824*/
825bool QSurfaceFormat::equals(const QSurfaceFormat& other) const noexcept
826{
827 return (d == other.d) || ((int) d->opts == (int) other.d->opts
828 && d->stencilSize == other.d->stencilSize
829 && d->redBufferSize == other.d->redBufferSize
830 && d->greenBufferSize == other.d->greenBufferSize
831 && d->blueBufferSize == other.d->blueBufferSize
832 && d->alphaBufferSize == other.d->alphaBufferSize
833 && d->depthSize == other.d->depthSize
834 && d->numSamples == other.d->numSamples
835 && d->swapBehavior == other.d->swapBehavior
836 && d->profile == other.d->profile
837 && d->major == other.d->major
838 && d->minor == other.d->minor
839 && d->swapInterval == other.d->swapInterval);
840}
841
842#ifndef QT_NO_DEBUG_STREAM
843QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
844{
845 const QSurfaceFormatPrivate * const d = f.d;
846 QDebugStateSaver saver(dbg);
847
848 dbg.nospace() << "QSurfaceFormat("
849 << "version " << d->major << '.' << d->minor
850 << ", options " << d->opts
851 << ", depthBufferSize " << d->depthSize
852 << ", redBufferSize " << d->redBufferSize
853 << ", greenBufferSize " << d->greenBufferSize
854 << ", blueBufferSize " << d->blueBufferSize
855 << ", alphaBufferSize " << d->alphaBufferSize
856 << ", stencilBufferSize " << d->stencilSize
857 << ", samples " << d->numSamples
858 << ", swapBehavior " << d->swapBehavior
859 << ", swapInterval " << d->swapInterval
860 << ", colorSpace " << d->colorSpace
861 << ", profile " << d->profile
862 << ')';
863
864 return dbg;
865}
866#endif
867
868QT_END_NAMESPACE
869
870#include "moc_qsurfaceformat.cpp"
871

source code of qtbase/src/gui/kernel/qsurfaceformat.cpp