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

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