OpenCoverage

qsurfaceformat.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qsurfaceformat.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 QtGui module 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 "qsurfaceformat.h"-
41-
42#include <QtCore/qatomic.h>-
43#include <QtCore/QDebug>-
44#include <QOpenGLContext>-
45#include <QtGui/qguiapplication.h>-
46-
47#ifdef major-
48#undef major-
49#endif-
50-
51#ifdef minor-
52#undef minor-
53#endif-
54-
55QT_BEGIN_NAMESPACE-
56-
57class QSurfaceFormatPrivate-
58{-
59public:-
60 explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = 0)-
61 : ref(1)-
62 , opts(_opts)-
63 , redBufferSize(-1)-
64 , greenBufferSize(-1)-
65 , blueBufferSize(-1)-
66 , alphaBufferSize(-1)-
67 , depthSize(-1)-
68 , stencilSize(-1)-
69 , swapBehavior(QSurfaceFormat::DefaultSwapBehavior)-
70 , numSamples(-1)-
71 , renderableType(QSurfaceFormat::DefaultRenderableType)-
72 , profile(QSurfaceFormat::NoProfile)-
73 , major(2)-
74 , minor(0)-
75 , swapInterval(1) // default to vsync-
76 {-
77 }
never executed: end of block
0
78-
79 QSurfaceFormatPrivate(const QSurfaceFormatPrivate *other)-
80 : ref(1),-
81 opts(other->opts),-
82 redBufferSize(other->redBufferSize),-
83 greenBufferSize(other->greenBufferSize),-
84 blueBufferSize(other->blueBufferSize),-
85 alphaBufferSize(other->alphaBufferSize),-
86 depthSize(other->depthSize),-
87 stencilSize(other->stencilSize),-
88 swapBehavior(other->swapBehavior),-
89 numSamples(other->numSamples),-
90 renderableType(other->renderableType),-
91 profile(other->profile),-
92 major(other->major),-
93 minor(other->minor),-
94 swapInterval(other->swapInterval)-
95 {-
96 }
never executed: end of block
0
97-
98 QAtomicInt ref;-
99 QSurfaceFormat::FormatOptions opts;-
100 int redBufferSize;-
101 int greenBufferSize;-
102 int blueBufferSize;-
103 int alphaBufferSize;-
104 int depthSize;-
105 int stencilSize;-
106 QSurfaceFormat::SwapBehavior swapBehavior;-
107 int numSamples;-
108 QSurfaceFormat::RenderableType renderableType;-
109 QSurfaceFormat::OpenGLContextProfile profile;-
110 int major;-
111 int minor;-
112 int swapInterval;-
113};-
114-
115/*!-
116 \class QSurfaceFormat-
117 \since 5.0-
118 \brief The QSurfaceFormat class represents the format of a QSurface.-
119 \inmodule QtGui-
120-
121 The format includes the size of the color buffers, red, green, and blue;-
122 the size of the alpha buffer; the size of the depth and stencil buffers;-
123 and number of samples per pixel for multisampling. In addition, the format-
124 contains surface configuration parameters such as OpenGL profile and-
125 version for rendering, whether or not to enable stereo buffers, and swap-
126 behaviour.-
127*/-
128-
129/*!-
130 \enum QSurfaceFormat::FormatOption-
131-
132 This enum contains format options for use with QSurfaceFormat.-
133-
134 \value StereoBuffers Used to request stereo buffers in the surface format.-
135 \value DebugContext Used to request a debug context with extra debugging information.-
136 \value DeprecatedFunctions Used to request that deprecated functions be included-
137 in the OpenGL context profile. If not specified, you should get a forward compatible context-
138 without support functionality marked as deprecated. This requires OpenGL version 3.0 or higher.-
139 \value ResetNotification Enables notifications about resets of the OpenGL context. The status is then-
140 queryable via the context's \l{QOpenGLContext::isValid()}{isValid()} function. Note that not setting-
141 this flag does not guarantee that context state loss never occurs. Additionally, some implementations-
142 may choose to report context loss regardless of this flag.-
143*/-
144-
145/*!-
146 \enum QSurfaceFormat::SwapBehavior-
147-
148 This enum is used by QSurfaceFormat to specify the swap behaviour of a surface. The swap behaviour-
149 is mostly transparent to the application, but it affects factors such as rendering latency and-
150 throughput.-
151-
152 \value DefaultSwapBehavior The default, unspecified swap behaviour of the platform.-
153 \value SingleBuffer Used to request single buffering, which might result in flickering-
154 when OpenGL rendering is done directly to screen without an intermediate offscreen-
155 buffer.-
156 \value DoubleBuffer This is typically the default swap behaviour on desktop platforms,-
157 consisting of one back buffer and one front buffer. Rendering is done to the back-
158 buffer, and then the back buffer and front buffer are swapped, or the contents of-
159 the back buffer are copied to the front buffer, depending on the implementation.-
160 \value TripleBuffer This swap behaviour is sometimes used in order to decrease the-
161 risk of skipping a frame when the rendering rate is just barely keeping up with-
162 the screen refresh rate. Depending on the platform it might also lead to slightly-
163 more efficient use of the GPU due to improved pipelining behaviour. Triple buffering-
164 comes at the cost of an extra frame of memory usage and latency, and might not be-
165 supported depending on the underlying platform.-
166*/-
167-
168/*!-
169 \enum QSurfaceFormat::RenderableType-
170-
171 This enum specifies the rendering backend for the surface.-
172-
173 \value DefaultRenderableType The default, unspecified rendering method-
174 \value OpenGL Desktop OpenGL rendering-
175 \value OpenGLES OpenGL ES 2.0 rendering-
176 \value OpenVG Open Vector Graphics rendering-
177*/-
178-
179/*!-
180 \enum QSurfaceFormat::OpenGLContextProfile-
181-
182 This enum is used to specify the OpenGL context profile, in-
183 conjunction with QSurfaceFormat::setMajorVersion() and-
184 QSurfaceFormat::setMinorVersion().-
185-
186 Profiles are exposed in OpenGL 3.2 and above, and are used-
187 to choose between a restricted core profile, and a compatibility-
188 profile which might contain deprecated support functionality.-
189-
190 Note that the core profile might still contain functionality that-
191 is deprecated and scheduled for removal in a higher version. To-
192 get access to the deprecated functionality for the core profile-
193 in the set OpenGL version you can use the QSurfaceFormat format option-
194 QSurfaceFormat::DeprecatedFunctions.-
195-
196 \value NoProfile OpenGL version is lower than 3.2. For 3.2 and newer this is same as CoreProfile.-
197 \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available.-
198 \value CompatibilityProfile Functionality from earlier OpenGL versions is available.-
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}
never executed: end of block
0
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}
never executed: end of block
0
218-
219/*!-
220 \internal-
221*/-
222void QSurfaceFormat::detach()-
223{-
224 if (d->ref.load() != 1) {
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
225 QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d);-
226 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
227 delete d;
never executed: delete d;
0
228 d = newd;-
229 }
never executed: end of block
0
230}
never executed: end of block
0
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}
never executed: end of block
0
240-
241/*!-
242 Assigns \a other to this object.-
243*/-
244QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other)-
245{-
246 if (d != other.d) {
d != other.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
247 other.d->ref.ref();-
248 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
249 delete d;
never executed: delete d;
0
250 d = other.d;-
251 }
never executed: end of block
0
252 return *this;
never executed: return *this;
0
253}-
254-
255/*!-
256 Destroys the QSurfaceFormat.-
257*/-
258QSurfaceFormat::~QSurfaceFormat()-
259{-
260 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
261 delete d;
never executed: delete d;
0
262}
never executed: end of block
0
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(QSurfaceFormat::StereoBuffers, enable);-
288-
289 if (int(newOptions) != int(d->opts)) {
int(newOptions...= int(d->opts)Description
TRUEnever evaluated
FALSEnever evaluated
0
290 detach();-
291 d->opts = newOptions;-
292 }
never executed: end of block
0
293}
never executed: end of block
0
294-
295/*!-
296 Returns the number of samples per pixel when multisampling is-
297 enabled. By default, multisampling is disabled.-
298-
299 \sa setSamples()-
300*/-
301int QSurfaceFormat::samples() const-
302{-
303 return d->numSamples;
never executed: return d->numSamples;
0
304}-
305-
306/*!-
307 Set the preferred number of samples per pixel when multisampling-
308 is enabled to \a numSamples. By default, multisampling is disabled.-
309-
310 \sa samples()-
311*/-
312void QSurfaceFormat::setSamples(int numSamples)-
313{-
314 if (d->numSamples != numSamples) {
d->numSamples != numSamplesDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 detach();-
316 d->numSamples = numSamples;-
317 }
never executed: end of block
0
318}
never executed: end of block
0
319-
320#if QT_DEPRECATED_SINCE(5, 2)-
321/*!-
322 \obsolete-
323 \overload-
324-
325 Use setOption(QSurfaceFormat::FormatOption, bool) or setOptions() instead.-
326-
327 Sets the format options to the OR combination of \a opt and the-
328 current format options.-
329-
330 \sa options(), testOption()-
331*/-
332void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt)-
333{-
334 const QSurfaceFormat::FormatOptions newOptions = d->opts | opt;-
335 if (int(newOptions) != int(d->opts)) {
int(newOptions...= int(d->opts)Description
TRUEnever evaluated
FALSEnever evaluated
0
336 detach();-
337 d->opts = newOptions;-
338 }
never executed: end of block
0
339}
never executed: end of block
0
340-
341/*!-
342 \obsolete-
343 \overload-
344-
345 Use testOption(QSurfaceFormat::FormatOption) instead.-
346-
347 Returns \c true if any of the options in \a opt is currently set-
348 on this object; otherwise returns false.-
349-
350 \sa setOption()-
351*/-
352bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const-
353{-
354 return d->opts & opt;
never executed: return d->opts & opt;
0
355}-
356#endif // QT_DEPRECATED_SINCE(5, 2)-
357-
358/*!-
359 \since 5.3-
360-
361 Sets the format options to \a options.-
362-
363 \sa options(), testOption()-
364*/-
365void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)-
366{-
367 if (int(d->opts) != int(options)) {
int(d->opts) != int(options)Description
TRUEnever evaluated
FALSEnever evaluated
0
368 detach();-
369 d->opts = options;-
370 }
never executed: end of block
0
371}
never executed: end of block
0
372-
373/*!-
374 \since 5.3-
375-
376 Sets the format option \a option if \a on is true; otherwise, clears the option.-
377-
378 \sa setOptions(), options(), testOption()-
379*/-
380void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on)-
381{-
382 if (testOption(option) == on)
testOption(option) == onDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 return;
never executed: return;
0
384 detach();-
385 if (on)
onDescription
TRUEnever evaluated
FALSEnever evaluated
0
386 d->opts |= option;
never executed: d->opts |= option;
0
387 else-
388 d->opts &= ~option;
never executed: d->opts &= ~option;
0
389}-
390-
391/*!-
392 \since 5.3-
393-
394 Returns true if the format option \a option is set; otherwise returns false.-
395-
396 \sa options()-
397*/-
398bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option) const-
399{-
400 return d->opts & option;
never executed: return d->opts & option;
0
401}-
402-
403/*!-
404 \since 5.3-
405-
406 Returns the currently set format options.-
407-
408 \sa setOption(), setOptions(), testOption()-
409*/-
410QSurfaceFormat::FormatOptions QSurfaceFormat::options() const-
411{-
412 return d->opts;
never executed: return d->opts;
0
413}-
414-
415/*!-
416 Set the minimum depth buffer size to \a size.-
417-
418 \sa depthBufferSize()-
419*/-
420void QSurfaceFormat::setDepthBufferSize(int size)-
421{-
422 if (d->depthSize != size) {
d->depthSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
423 detach();-
424 d->depthSize = size;-
425 }
never executed: end of block
0
426}
never executed: end of block
0
427-
428/*!-
429 Returns the depth buffer size.-
430-
431 \sa setDepthBufferSize()-
432*/-
433int QSurfaceFormat::depthBufferSize() const-
434{-
435 return d->depthSize;
never executed: return d->depthSize;
0
436}-
437-
438/*!-
439 Set the swap \a behavior of the surface.-
440-
441 The swap behavior specifies whether single, double, or triple-
442 buffering is desired. The default, DefaultSwapBehavior,-
443 gives the default swap behavior of the platform.-
444*/-
445void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)-
446{-
447 if (d->swapBehavior != behavior) {
d->swapBehavior != behaviorDescription
TRUEnever evaluated
FALSEnever evaluated
0
448 detach();-
449 d->swapBehavior = behavior;-
450 }
never executed: end of block
0
451}
never executed: end of block
0
452-
453/*!-
454 Returns the configured swap behaviour.-
455-
456 \sa setSwapBehavior()-
457*/-
458QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const-
459{-
460 return d->swapBehavior;
never executed: return d->swapBehavior;
0
461}-
462-
463/*!-
464 Returns \c true if the alpha buffer size is greater than zero.-
465-
466 This means that the surface might be used with per pixel-
467 translucency effects.-
468*/-
469bool QSurfaceFormat::hasAlpha() const-
470{-
471 return d->alphaBufferSize > 0;
never executed: return d->alphaBufferSize > 0;
0
472}-
473-
474/*!-
475 Set the preferred stencil buffer size to \a size bits.-
476-
477 \sa stencilBufferSize()-
478*/-
479void QSurfaceFormat::setStencilBufferSize(int size)-
480{-
481 if (d->stencilSize != size) {
d->stencilSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
482 detach();-
483 d->stencilSize = size;-
484 }
never executed: end of block
0
485}
never executed: end of block
0
486-
487/*!-
488 Returns the stencil buffer size in bits.-
489-
490 \sa setStencilBufferSize()-
491*/-
492int QSurfaceFormat::stencilBufferSize() const-
493{-
494 return d->stencilSize;
never executed: return d->stencilSize;
0
495}-
496-
497/*!-
498 Get the size in bits of the red channel of the color buffer.-
499*/-
500int QSurfaceFormat::redBufferSize() const-
501{-
502 return d->redBufferSize;
never executed: return d->redBufferSize;
0
503}-
504-
505/*!-
506 Get the size in bits of the green channel of the color buffer.-
507*/-
508int QSurfaceFormat::greenBufferSize() const-
509{-
510 return d->greenBufferSize;
never executed: return d->greenBufferSize;
0
511}-
512-
513/*!-
514 Get the size in bits of the blue channel of the color buffer.-
515*/-
516int QSurfaceFormat::blueBufferSize() const-
517{-
518 return d->blueBufferSize;
never executed: return d->blueBufferSize;
0
519}-
520-
521/*!-
522 Get the size in bits of the alpha channel of the color buffer.-
523*/-
524int QSurfaceFormat::alphaBufferSize() const-
525{-
526 return d->alphaBufferSize;
never executed: return d->alphaBufferSize;
0
527}-
528-
529/*!-
530 Set the desired \a size in bits of the red channel of the color buffer.-
531-
532 \note On Mac OSX, be sure to set the buffer size of all color channels,-
533 otherwise this setting will have no effect. If one of the buffer sizes is not set,-
534 the current bit-depth of the screen is used.-
535*/-
536void QSurfaceFormat::setRedBufferSize(int size)-
537{-
538 if (d->redBufferSize != size) {
d->redBufferSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
539 detach();-
540 d->redBufferSize = size;-
541 }
never executed: end of block
0
542}
never executed: end of block
0
543-
544/*!-
545 Set the desired \a size in bits of the green channel of the color buffer.-
546-
547 \note On Mac OSX, be sure to set the buffer size of all color channels,-
548 otherwise this setting will have no effect. If one of the buffer sizes is not set,-
549 the current bit-depth of the screen is used.-
550*/-
551void QSurfaceFormat::setGreenBufferSize(int size)-
552{-
553 if (d->greenBufferSize != size) {
d->greenBufferSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
554 detach();-
555 d->greenBufferSize = size;-
556 }
never executed: end of block
0
557}
never executed: end of block
0
558-
559/*!-
560 Set the desired \a size in bits of the blue channel of the color buffer.-
561-
562 \note On Mac OSX, be sure to set the buffer size of all color channels,-
563 otherwise this setting will have no effect. If one of the buffer sizes is not set,-
564 the current bit-depth of the screen is used.-
565*/-
566void QSurfaceFormat::setBlueBufferSize(int size)-
567{-
568 if (d->blueBufferSize != size) {
d->blueBufferSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
569 detach();-
570 d->blueBufferSize = size;-
571 }
never executed: end of block
0
572}
never executed: end of block
0
573-
574/*!-
575 Set the desired \a size in bits of the alpha channel of the color buffer.-
576*/-
577void QSurfaceFormat::setAlphaBufferSize(int size)-
578{-
579 if (d->alphaBufferSize != size) {
d->alphaBufferSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
580 detach();-
581 d->alphaBufferSize = size;-
582 }
never executed: end of block
0
583}
never executed: end of block
0
584-
585/*!-
586 Sets the desired renderable \a type.-
587-
588 Chooses between desktop OpenGL, OpenGL ES, and OpenVG.-
589*/-
590void QSurfaceFormat::setRenderableType(RenderableType type)-
591{-
592 if (d->renderableType != type) {
d->renderableType != typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
593 detach();-
594 d->renderableType = type;-
595 }
never executed: end of block
0
596}
never executed: end of block
0
597-
598/*!-
599 Gets the renderable type.-
600-
601 Chooses between desktop OpenGL, OpenGL ES, and OpenVG.-
602*/-
603QSurfaceFormat::RenderableType QSurfaceFormat::renderableType() const-
604{-
605 return d->renderableType;
never executed: return d->renderableType;
0
606}-
607-
608/*!-
609 Sets the desired OpenGL context \a profile.-
610-
611 This setting is ignored if the requested OpenGL version is-
612 less than 3.2.-
613*/-
614void QSurfaceFormat::setProfile(OpenGLContextProfile profile)-
615{-
616 if (d->profile != profile) {
d->profile != profileDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 detach();-
618 d->profile = profile;-
619 }
never executed: end of block
0
620}
never executed: end of block
0
621-
622/*!-
623 Get the configured OpenGL context profile.-
624-
625 This setting is ignored if the requested OpenGL version is-
626 less than 3.2.-
627*/-
628QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile() const-
629{-
630 return d->profile;
never executed: return d->profile;
0
631}-
632-
633/*!-
634 Sets the desired \a major OpenGL version.-
635*/-
636void QSurfaceFormat::setMajorVersion(int major)-
637{-
638 if (d->major != major) {
d->major != majorDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 detach();-
640 d->major = major;-
641 }
never executed: end of block
0
642}
never executed: end of block
0
643-
644/*!-
645 Returns the major OpenGL version.-
646-
647 The default version is 2.0.-
648*/-
649int QSurfaceFormat::majorVersion() const-
650{-
651 return d->major;
never executed: return d->major;
0
652}-
653-
654/*!-
655 Sets the desired \a minor OpenGL version.-
656-
657 The default version is 2.0.-
658*/-
659void QSurfaceFormat::setMinorVersion(int minor)-
660{-
661 if (d->minor != minor) {
d->minor != minorDescription
TRUEnever evaluated
FALSEnever evaluated
0
662 detach();-
663 d->minor = minor;-
664 }
never executed: end of block
0
665}
never executed: end of block
0
666-
667/*!-
668 Returns the minor OpenGL version.-
669*/-
670int QSurfaceFormat::minorVersion() const-
671{-
672 return d->minor;
never executed: return d->minor;
0
673}-
674-
675/*!-
676 Returns a QPair<int, int> representing the OpenGL version.-
677-
678 Useful for version checks, for example format.version() >= qMakePair(3, 2)-
679*/-
680QPair<int, int> QSurfaceFormat::version() const-
681{-
682 return qMakePair(d->major, d->minor);
never executed: return qMakePair(d->major, d->minor);
0
683}-
684-
685/*!-
686 Sets the desired \a major and \a minor OpenGL versions.-
687-
688 The default version is 2.0.-
689*/-
690void QSurfaceFormat::setVersion(int major, int minor)-
691{-
692 if (d->minor != minor || d->major != major) {
d->minor != minorDescription
TRUEnever evaluated
FALSEnever evaluated
d->major != majorDescription
TRUEnever evaluated
FALSEnever evaluated
0
693 detach();-
694 d->minor = minor;-
695 d->major = major;-
696 }
never executed: end of block
0
697}
never executed: end of block
0
698-
699/*!-
700 Sets the preferred swap interval. The swap interval specifies the-
701 minimum number of video frames that are displayed before a buffer-
702 swap occurs. This can be used to sync the GL drawing into a window-
703 to the vertical refresh of the screen.-
704-
705 Setting an \a interval value of 0 will turn the vertical refresh-
706 syncing off, any value higher than 0 will turn the vertical-
707 syncing on. Setting \a interval to a higher value, for example 10,-
708 results in having 10 vertical retraces between every buffer swap.-
709-
710 The default interval is 1.-
711-
712 Changing the swap interval may not be supported by the underlying-
713 platform. In this case, the request will be silently ignored.-
714-
715 \since 5.3-
716-
717 \sa swapInterval()-
718 */-
719void QSurfaceFormat::setSwapInterval(int interval)-
720{-
721 if (d->swapInterval != interval) {
d->swapInterval != intervalDescription
TRUEnever evaluated
FALSEnever evaluated
0
722 detach();-
723 d->swapInterval = interval;-
724 }
never executed: end of block
0
725}
never executed: end of block
0
726-
727/*!-
728 Returns the swap interval.-
729-
730 \since 5.3-
731-
732 \sa setSwapInterval()-
733*/-
734int QSurfaceFormat::swapInterval() const-
735{-
736 return d->swapInterval;
never executed: return d->swapInterval;
0
737}-
738-
739Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
740-
741/*!-
742 Sets the global default surface \a format.-
743-
744 This format is used by default in QOpenGLContext, QWindow, QOpenGLWidget and-
745 similar classes.-
746-
747 It can always be overridden on a per-instance basis by using the class in-
748 question's own setFormat() function. However, it is often more convenient to-
749 set the format for all windows once at the start of the application. It also-
750 guarantees proper behavior in cases where shared contexts are required,-
751 because settings the format via this function guarantees that all contexts-
752 and surfaces, even the ones created internally by Qt, will use the same-
753 format.-
754-
755 \note When setting Qt::AA_ShareOpenGLContexts, it is strongly recommended to-
756 place the call to this function before the construction of the-
757 QGuiApplication or QApplication. Otherwise \a format will not be applied to-
758 the global share context and therefore issues may arise with context sharing-
759 afterwards.-
760-
761 \since 5.4-
762 \sa defaultFormat()-
763 */-
764void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format)-
765{-
766#ifndef QT_NO_OPENGL-
767 if (qApp) {
(static_cast<Q...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
0
768 QOpenGLContext *globalContext = QOpenGLContext::globalShareContext();-
769 if (globalContext && globalContext->isValid()) {
globalContextDescription
TRUEnever evaluated
FALSEnever evaluated
globalContext->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
770 qWarning("Warning: Setting a new default format with a different version or profile "-
771 "after the global shared context is created may cause issues with context "-
772 "sharing.");-
773 }
never executed: end of block
0
774 }
never executed: end of block
0
775#endif-
776 *qt_default_surface_format() = format;-
777}
never executed: end of block
0
778-
779/*!-
780 Returns the global default surface format.-
781-
782 When setDefaultFormat() is not called, this is a default-constructed QSurfaceFormat.-
783-
784 \since 5.4-
785 \sa setDefaultFormat()-
786 */-
787QSurfaceFormat QSurfaceFormat::defaultFormat()-
788{-
789 return *qt_default_surface_format();
never executed: return *qt_default_surface_format();
0
790}-
791-
792/*!-
793 Returns \c true if all the options of the two QSurfaceFormat objects-
794 \a a and \a b are equal.-
795-
796 \relates QSurfaceFormat-
797*/-
798bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b)-
799{-
800 return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
801 && a.d->stencilSize == b.d->stencilSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
802 && a.d->redBufferSize == b.d->redBufferSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
803 && a.d->greenBufferSize == b.d->greenBufferSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
804 && a.d->blueBufferSize == b.d->blueBufferSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
805 && a.d->alphaBufferSize == b.d->alphaBufferSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
806 && a.d->depthSize == b.d->depthSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
807 && a.d->numSamples == b.d->numSamples
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
808 && a.d->swapBehavior == b.d->swapBehavior
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
809 && a.d->profile == b.d->profile
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
810 && a.d->major == b.d->major
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
811 && a.d->minor == b.d->minor
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
812 && a.d->swapInterval == b.d->swapInterval);
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize && a.d->redBufferSize == b.d->redBufferSize && a.d->greenBufferSize == b.d->greenBufferSize && a.d->blueBufferSize == b.d->blueBufferSize && a.d->alphaBuffe...ferSize && a.d->depthSize == b.d->depthSize && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->profile == b.d->profile && a.d->major == b.d->major && a.d->minor == b.d->minor && a.d->swapInterval == b.d->swapInterval);
0
813}-
814-
815/*!-
816 Returns \c false if all the options of the two QSurfaceFormat objects-
817 \a a and \a b are equal; otherwise returns \c true.-
818-
819 \relates QSurfaceFormat-
820*/-
821bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b)-
822{-
823 return !(a == b);
never executed: return !(a == b);
0
824}-
825-
826#ifndef QT_NO_DEBUG_STREAM-
827QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)-
828{-
829 const QSurfaceFormatPrivate * const d = f.d;-
830 QDebugStateSaver saver(dbg);-
831-
832 dbg.nospace() << "QSurfaceFormat("-
833 << "version " << d->major << '.' << d->minor-
834 << ", options " << d->opts-
835 << ", depthBufferSize " << d->depthSize-
836 << ", redBufferSize " << d->redBufferSize-
837 << ", greenBufferSize " << d->greenBufferSize-
838 << ", blueBufferSize " << d->blueBufferSize-
839 << ", alphaBufferSize " << d->alphaBufferSize-
840 << ", stencilBufferSize " << d->stencilSize-
841 << ", samples " << d->numSamples-
842 << ", swapBehavior " << d->swapBehavior-
843 << ", swapInterval " << d->swapInterval-
844 << ", profile " << d->profile-
845 << ')';-
846-
847 return dbg;
never executed: return dbg;
0
848}-
849#endif-
850-
851QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9