qgl.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtOpenGL 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qapplication.h" -
43#include "qplatformdefs.h" -
44#include "qgl.h" -
45#include <qdebug.h> -
46#include <qglfunctions.h> -
47 -
48#include <qdatetime.h> -
49 -
50#include <stdlib.h> // malloc -
51 -
52#include "qpixmap.h" -
53#include "qimage.h" -
54#include "qgl_p.h" -
55 -
56#include "gl2paintengineex/qpaintengineex_opengl2_p.h" -
57 -
58#include <qpa/qplatformopenglcontext.h> -
59 -
60#include <qglpixelbuffer.h> -
61#include <qglframebufferobject.h> -
62 -
63#include <private/qimage_p.h> -
64#include <qpa/qplatformpixmap.h> -
65#include <private/qglpixelbuffer_p.h> -
66#include <private/qimagepixmapcleanuphooks_p.h> -
67#include "qcolormap.h" -
68#include "qfile.h" -
69#include "qlibrary.h" -
70#include <qmutex.h> -
71 -
72// #define QT_GL_CONTEXT_RESOURCE_DEBUG -
73 -
74QT_BEGIN_NAMESPACE -
75 -
76QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; -
77 -
78struct QGLThreadContext { -
79 ~QGLThreadContext() { -
80 if (context)
never evaluated: context
0
81 context->doneCurrent();
never executed: context->doneCurrent();
0
82 }
never executed: }
0
83 QGLContext *context; -
84}; -
85 -
86Q_GLOBAL_STATIC(QGLFormat, qgl_default_format)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
87 -
88class QGLDefaultOverlayFormat: public QGLFormat -
89{ -
90public: -
91 inline QGLDefaultOverlayFormat() -
92 { -
93 setOption(QGL::FormatOption(0xffff << 16)); // turn off all options
never executed (the execution status of this line is deduced): setOption(QGL::FormatOption(0xffff << 16));
-
94 setOption(QGL::DirectRendering);
never executed (the execution status of this line is deduced): setOption(QGL::DirectRendering);
-
95 setPlane(1);
never executed (the execution status of this line is deduced): setPlane(1);
-
96 }
never executed: }
0
97}; -
98Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
99 -
100Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
101QGLSignalProxy *QGLSignalProxy::instance() -
102{ -
103 QGLSignalProxy *proxy = theSignalProxy();
never executed (the execution status of this line is deduced): QGLSignalProxy *proxy = theSignalProxy();
-
104 if (proxy && proxy->thread() != qApp->thread()) {
never evaluated: proxy
never evaluated: proxy->thread() != (static_cast<QApplication *>(QCoreApplication::instance()))->thread()
0
105 if (proxy->thread() == QThread::currentThread())
never evaluated: proxy->thread() == QThread::currentThread()
0
106 proxy->moveToThread(qApp->thread());
never executed: proxy->moveToThread((static_cast<QApplication *>(QCoreApplication::instance()))->thread());
0
107 }
never executed: }
0
108 return proxy;
never executed: return proxy;
0
109} -
110 -
111 -
112/*! -
113 \namespace QGL -
114 \inmodule QtOpenGL -
115 -
116 \brief The QGL namespace specifies miscellaneous identifiers used -
117 in the Qt OpenGL module. -
118*/ -
119 -
120/*! -
121 \enum QGL::FormatOption -
122 -
123 This enum specifies the format options that can be used to configure an OpenGL -
124 context. These are set using QGLFormat::setOption(). -
125 -
126 \value DoubleBuffer Specifies the use of double buffering. -
127 \value DepthBuffer Enables the use of a depth buffer. -
128 \value Rgba Specifies that the context should use RGBA as its pixel format. -
129 \value AlphaChannel Enables the use of an alpha channel. -
130 \value AccumBuffer Enables the use of an accumulation buffer. -
131 \value StencilBuffer Enables the use of a stencil buffer. -
132 \value StereoBuffers Enables the use of a stereo buffers for use with visualization hardware. -
133 \value DirectRendering Specifies that the context is used for direct rendering to a display. -
134 \value HasOverlay Enables the use of an overlay. -
135 \value SampleBuffers Enables the use of sample buffers. -
136 \value DeprecatedFunctions Enables the use of deprecated functionality for OpenGL 3.x -
137 contexts. A context with deprecated functionality enabled is -
138 called a full context in the OpenGL specification. -
139 \value SingleBuffer Specifies the use of a single buffer, as opposed to double buffers. -
140 \value NoDepthBuffer Disables the use of a depth buffer. -
141 \value ColorIndex Specifies that the context should use a color index as its pixel format. -
142 \value NoAlphaChannel Disables the use of an alpha channel. -
143 \value NoAccumBuffer Disables the use of an accumulation buffer. -
144 \value NoStencilBuffer Disables the use of a stencil buffer. -
145 \value NoStereoBuffers Disables the use of stereo buffers. -
146 \value IndirectRendering Specifies that the context is used for indirect rendering to a buffer. -
147 \value NoOverlay Disables the use of an overlay. -
148 \value NoSampleBuffers Disables the use of sample buffers. -
149 \value NoDeprecatedFunctions Disables the use of deprecated functionality for OpenGL 3.x -
150 contexts. A context with deprecated functionality disabled is -
151 called a forward compatible context in the OpenGL specification. -
152 -
153 \sa {Sample Buffers Example} -
154*/ -
155 -
156/***************************************************************************** -
157 QGLFormat implementation -
158 *****************************************************************************/ -
159 -
160 -
161/*! -
162 \class QGLFormat -
163 \inmodule QtOpenGL -
164 -
165 \brief The QGLFormat class specifies the display format of an OpenGL -
166 rendering context. -
167 -
168 A display format has several characteristics: -
169 \list -
170 \li \l{setDoubleBuffer()}{Double or single buffering.} -
171 \li \l{setDepth()}{Depth buffer.} -
172 \li \l{setRgba()}{RGBA or color index mode.} -
173 \li \l{setAlpha()}{Alpha channel.} -
174 \li \l{setAccum()}{Accumulation buffer.} -
175 \li \l{setStencil()}{Stencil buffer.} -
176 \li \l{setStereo()}{Stereo buffers.} -
177 \li \l{setDirectRendering()}{Direct rendering.} -
178 \li \l{setOverlay()}{Presence of an overlay.} -
179 \li \l{setPlane()}{Plane of an overlay.} -
180 \li \l{setSampleBuffers()}{Multisample buffers.} -
181 \endlist -
182 -
183 You can also specify preferred bit depths for the color buffer, -
184 depth buffer, alpha buffer, accumulation buffer and the stencil -
185 buffer with the functions: setRedBufferSize(), setGreenBufferSize(), -
186 setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(), -
187 setAccumBufferSize() and setStencilBufferSize(). -
188 -
189 Note that even if you specify that you prefer a 32 bit depth -
190 buffer (e.g. with setDepthBufferSize(32)), the format that is -
191 chosen may not have a 32 bit depth buffer, even if there is a -
192 format available with a 32 bit depth buffer. The main reason for -
193 this is how the system dependant picking algorithms work on the -
194 different platforms, and some format options may have higher -
195 precedence than others. -
196 -
197 You create and tell a QGLFormat object what rendering options you -
198 want from an OpenGL rendering context. -
199 -
200 OpenGL drivers or accelerated hardware may or may not support -
201 advanced features such as alpha channel or stereographic viewing. -
202 If you request some features that the driver/hardware does not -
203 provide when you create a QGLWidget, you will get a rendering -
204 context with the nearest subset of features. -
205 -
206 There are different ways to define the display characteristics of -
207 a rendering context. One is to create a QGLFormat and make it the -
208 default for the entire application: -
209 \snippet code/src_opengl_qgl.cpp 0 -
210 -
211 Or you can specify the desired format when creating an object of -
212 your QGLWidget subclass: -
213 \snippet code/src_opengl_qgl.cpp 1 -
214 -
215 After the widget has been created, you can find out which of the -
216 requested features the system was able to provide: -
217 \snippet code/src_opengl_qgl.cpp 2 -
218 -
219 \legalese -
220 OpenGL is a trademark of Silicon Graphics, Inc. in the -
221 United States and other countries. -
222 \endlegalese -
223 -
224 \sa QGLContext, QGLWidget -
225*/ -
226 -
227#ifndef QT_OPENGL_ES -
228 -
229static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]) -
230{ -
231#define M(row,col) m[col*4+row] -
232 out[0] =
never executed (the execution status of this line is deduced): out[0] =
-
233 M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
never executed (the execution status of this line is deduced): m[0*4+0] * in[0] + m[1*4+0] * in[1] + m[2*4+0] * in[2] + m[3*4+0] * in[3];
-
234 out[1] =
never executed (the execution status of this line is deduced): out[1] =
-
235 M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
never executed (the execution status of this line is deduced): m[0*4+1] * in[0] + m[1*4+1] * in[1] + m[2*4+1] * in[2] + m[3*4+1] * in[3];
-
236 out[2] =
never executed (the execution status of this line is deduced): out[2] =
-
237 M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
never executed (the execution status of this line is deduced): m[0*4+2] * in[0] + m[1*4+2] * in[1] + m[2*4+2] * in[2] + m[3*4+2] * in[3];
-
238 out[3] =
never executed (the execution status of this line is deduced): out[3] =
-
239 M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
never executed (the execution status of this line is deduced): m[0*4+3] * in[0] + m[1*4+3] * in[1] + m[2*4+3] * in[2] + m[3*4+3] * in[3];
-
240#undef M -
241}
never executed: }
0
242 -
243static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, -
244 const GLdouble model[16], const GLdouble proj[16], -
245 const GLint viewport[4], -
246 GLdouble * winx, GLdouble * winy, GLdouble * winz) -
247{ -
248 GLdouble in[4], out[4];
never executed (the execution status of this line is deduced): GLdouble in[4], out[4];
-
249 -
250 in[0] = objx;
never executed (the execution status of this line is deduced): in[0] = objx;
-
251 in[1] = objy;
never executed (the execution status of this line is deduced): in[1] = objy;
-
252 in[2] = objz;
never executed (the execution status of this line is deduced): in[2] = objz;
-
253 in[3] = 1.0;
never executed (the execution status of this line is deduced): in[3] = 1.0;
-
254 transform_point(out, model, in);
never executed (the execution status of this line is deduced): transform_point(out, model, in);
-
255 transform_point(in, proj, out);
never executed (the execution status of this line is deduced): transform_point(in, proj, out);
-
256 -
257 if (in[3] == 0.0)
never evaluated: in[3] == 0.0
0
258 return GL_FALSE;
never executed: return 0x0;
0
259 -
260 in[0] /= in[3];
never executed (the execution status of this line is deduced): in[0] /= in[3];
-
261 in[1] /= in[3];
never executed (the execution status of this line is deduced): in[1] /= in[3];
-
262 in[2] /= in[3];
never executed (the execution status of this line is deduced): in[2] /= in[3];
-
263 -
264 *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2;
never executed (the execution status of this line is deduced): *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2;
-
265 *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2;
never executed (the execution status of this line is deduced): *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2;
-
266 -
267 *winz = (1 + in[2]) / 2;
never executed (the execution status of this line is deduced): *winz = (1 + in[2]) / 2;
-
268 return GL_TRUE;
never executed: return 0x1;
0
269} -
270 -
271#endif // !QT_OPENGL_ES -
272 -
273/*! -
274 Constructs a QGLFormat object with the following default settings: -
275 \list -
276 \li \l{setDoubleBuffer()}{Double buffer:} Enabled. -
277 \li \l{setDepth()}{Depth buffer:} Enabled. -
278 \li \l{setRgba()}{RGBA:} Enabled (i.e., color index disabled). -
279 \li \l{setAlpha()}{Alpha channel:} Disabled. -
280 \li \l{setAccum()}{Accumulator buffer:} Disabled. -
281 \li \l{setStencil()}{Stencil buffer:} Enabled. -
282 \li \l{setStereo()}{Stereo:} Disabled. -
283 \li \l{setDirectRendering()}{Direct rendering:} Enabled. -
284 \li \l{setOverlay()}{Overlay:} Disabled. -
285 \li \l{setPlane()}{Plane:} 0 (i.e., normal plane). -
286 \li \l{setSampleBuffers()}{Multisample buffers:} Disabled. -
287 \endlist -
288*/ -
289 -
290QGLFormat::QGLFormat() -
291{ -
292 d = new QGLFormatPrivate;
never executed (the execution status of this line is deduced): d = new QGLFormatPrivate;
-
293}
never executed: }
0
294 -
295 -
296/*! -
297 Creates a QGLFormat object that is a copy of the current -
298 defaultFormat(). -
299 -
300 If \a options is not 0, the default format is modified by the -
301 specified format options. The \a options parameter should be -
302 QGL::FormatOption values OR'ed together. -
303 -
304 This constructor makes it easy to specify a certain desired format -
305 in classes derived from QGLWidget, for example: -
306 \snippet code/src_opengl_qgl.cpp 3 -
307 -
308 Note that there are QGL::FormatOption values to turn format settings -
309 both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer, -
310 QGL::DirectRendering and QGL::IndirectRendering, etc. -
311 -
312 The \a plane parameter defaults to 0 and is the plane which this -
313 format should be associated with. Not all OpenGL implementations -
314 supports overlay/underlay rendering planes. -
315 -
316 \sa defaultFormat(), setOption(), setPlane() -
317*/ -
318 -
319QGLFormat::QGLFormat(QGL::FormatOptions options, int plane) -
320{ -
321 d = new QGLFormatPrivate;
never executed (the execution status of this line is deduced): d = new QGLFormatPrivate;
-
322 QGL::FormatOptions newOpts = options;
never executed (the execution status of this line is deduced): QGL::FormatOptions newOpts = options;
-
323 d->opts = defaultFormat().d->opts;
never executed (the execution status of this line is deduced): d->opts = defaultFormat().d->opts;
-
324 d->opts |= (newOpts & 0xffff);
never executed (the execution status of this line is deduced): d->opts |= (newOpts & 0xffff);
-
325 d->opts &= ~(newOpts >> 16);
never executed (the execution status of this line is deduced): d->opts &= ~(newOpts >> 16);
-
326 d->pln = plane;
never executed (the execution status of this line is deduced): d->pln = plane;
-
327}
never executed: }
0
328 -
329/*! -
330 \internal -
331*/ -
332void QGLFormat::detach() -
333{ -
334 if (d->ref.load() != 1) {
never evaluated: d->ref.load() != 1
0
335 QGLFormatPrivate *newd = new QGLFormatPrivate(d);
never executed (the execution status of this line is deduced): QGLFormatPrivate *newd = new QGLFormatPrivate(d);
-
336 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
337 delete d;
never executed: delete d;
0
338 d = newd;
never executed (the execution status of this line is deduced): d = newd;
-
339 }
never executed: }
0
340}
never executed: }
0
341 -
342/*! -
343 Constructs a copy of \a other. -
344*/ -
345 -
346QGLFormat::QGLFormat(const QGLFormat &other) -
347{ -
348 d = other.d;
never executed (the execution status of this line is deduced): d = other.d;
-
349 d->ref.ref();
never executed (the execution status of this line is deduced): d->ref.ref();
-
350}
never executed: }
0
351 -
352/*! -
353 Assigns \a other to this object. -
354*/ -
355 -
356QGLFormat &QGLFormat::operator=(const QGLFormat &other) -
357{ -
358 if (d != other.d) {
never evaluated: d != other.d
0
359 other.d->ref.ref();
never executed (the execution status of this line is deduced): other.d->ref.ref();
-
360 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
361 delete d;
never executed: delete d;
0
362 d = other.d;
never executed (the execution status of this line is deduced): d = other.d;
-
363 }
never executed: }
0
364 return *this;
never executed: return *this;
0
365} -
366 -
367/*! -
368 Destroys the QGLFormat. -
369*/ -
370QGLFormat::~QGLFormat() -
371{ -
372 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
373 delete d;
never executed: delete d;
0
374}
never executed: }
0
375 -
376/*! -
377 \fn bool QGLFormat::doubleBuffer() const -
378 -
379 Returns true if double buffering is enabled; otherwise returns -
380 false. Double buffering is enabled by default. -
381 -
382 \sa setDoubleBuffer() -
383*/ -
384 -
385/*! -
386 If \a enable is true sets double buffering; otherwise sets single -
387 buffering. -
388 -
389 Double buffering is enabled by default. -
390 -
391 Double buffering is a technique where graphics are rendered on an -
392 off-screen buffer and not directly to the screen. When the drawing -
393 has been completed, the program calls a swapBuffers() function to -
394 exchange the screen contents with the buffer. The result is -
395 flicker-free drawing and often better performance. -
396 -
397 Note that single buffered contexts are currently not supported -
398 with EGL. -
399 -
400 \sa doubleBuffer(), QGLContext::swapBuffers(), -
401 QGLWidget::swapBuffers() -
402*/ -
403 -
404void QGLFormat::setDoubleBuffer(bool enable) -
405{ -
406 setOption(enable ? QGL::DoubleBuffer : QGL::SingleBuffer);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::DoubleBuffer : QGL::SingleBuffer);
-
407}
never executed: }
0
408 -
409 -
410/*! -
411 \fn bool QGLFormat::depth() const -
412 -
413 Returns true if the depth buffer is enabled; otherwise returns -
414 false. The depth buffer is enabled by default. -
415 -
416 \sa setDepth(), setDepthBufferSize() -
417*/ -
418 -
419/*! -
420 If \a enable is true enables the depth buffer; otherwise disables -
421 the depth buffer. -
422 -
423 The depth buffer is enabled by default. -
424 -
425 The purpose of a depth buffer (or Z-buffering) is to remove hidden -
426 surfaces. Pixels are assigned Z values based on the distance to -
427 the viewer. A pixel with a high Z value is closer to the viewer -
428 than a pixel with a low Z value. This information is used to -
429 decide whether to draw a pixel or not. -
430 -
431 \sa depth(), setDepthBufferSize() -
432*/ -
433 -
434void QGLFormat::setDepth(bool enable) -
435{ -
436 setOption(enable ? QGL::DepthBuffer : QGL::NoDepthBuffer);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::DepthBuffer : QGL::NoDepthBuffer);
-
437}
never executed: }
0
438 -
439 -
440/*! -
441 \fn bool QGLFormat::rgba() const -
442 -
443 Returns true if RGBA color mode is set. Returns false if color -
444 index mode is set. The default color mode is RGBA. -
445 -
446 \sa setRgba() -
447*/ -
448 -
449/*! -
450 If \a enable is true sets RGBA mode. If \a enable is false sets -
451 color index mode. -
452 -
453 The default color mode is RGBA. -
454 -
455 RGBA is the preferred mode for most OpenGL applications. In RGBA -
456 color mode you specify colors as red + green + blue + alpha -
457 quadruplets. -
458 -
459 In color index mode you specify an index into a color lookup -
460 table. -
461 -
462 \sa rgba() -
463*/ -
464 -
465void QGLFormat::setRgba(bool enable) -
466{ -
467 setOption(enable ? QGL::Rgba : QGL::ColorIndex);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::Rgba : QGL::ColorIndex);
-
468}
never executed: }
0
469 -
470 -
471/*! -
472 \fn bool QGLFormat::alpha() const -
473 -
474 Returns true if the alpha buffer in the framebuffer is enabled; -
475 otherwise returns false. The alpha buffer is disabled by default. -
476 -
477 \sa setAlpha(), setAlphaBufferSize() -
478*/ -
479 -
480/*! -
481 If \a enable is true enables the alpha buffer; otherwise disables -
482 the alpha buffer. -
483 -
484 The alpha buffer is disabled by default. -
485 -
486 The alpha buffer is typically used for implementing transparency -
487 or translucency. The A in RGBA specifies the transparency of a -
488 pixel. -
489 -
490 \sa alpha(), setAlphaBufferSize() -
491*/ -
492 -
493void QGLFormat::setAlpha(bool enable) -
494{ -
495 setOption(enable ? QGL::AlphaChannel : QGL::NoAlphaChannel);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::AlphaChannel : QGL::NoAlphaChannel);
-
496}
never executed: }
0
497 -
498 -
499/*! -
500 \fn bool QGLFormat::accum() const -
501 -
502 Returns true if the accumulation buffer is enabled; otherwise -
503 returns false. The accumulation buffer is disabled by default. -
504 -
505 \sa setAccum(), setAccumBufferSize() -
506*/ -
507 -
508/*! -
509 If \a enable is true enables the accumulation buffer; otherwise -
510 disables the accumulation buffer. -
511 -
512 The accumulation buffer is disabled by default. -
513 -
514 The accumulation buffer is used to create blur effects and -
515 multiple exposures. -
516 -
517 \sa accum(), setAccumBufferSize() -
518*/ -
519 -
520void QGLFormat::setAccum(bool enable) -
521{ -
522 setOption(enable ? QGL::AccumBuffer : QGL::NoAccumBuffer);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::AccumBuffer : QGL::NoAccumBuffer);
-
523}
never executed: }
0
524 -
525 -
526/*! -
527 \fn bool QGLFormat::stencil() const -
528 -
529 Returns true if the stencil buffer is enabled; otherwise returns -
530 false. The stencil buffer is enabled by default. -
531 -
532 \sa setStencil(), setStencilBufferSize() -
533*/ -
534 -
535/*! -
536 If \a enable is true enables the stencil buffer; otherwise -
537 disables the stencil buffer. -
538 -
539 The stencil buffer is enabled by default. -
540 -
541 The stencil buffer masks certain parts of the drawing area so that -
542 masked parts are not drawn on. -
543 -
544 \sa stencil(), setStencilBufferSize() -
545*/ -
546 -
547void QGLFormat::setStencil(bool enable) -
548{ -
549 setOption(enable ? QGL::StencilBuffer: QGL::NoStencilBuffer);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::StencilBuffer: QGL::NoStencilBuffer);
-
550}
never executed: }
0
551 -
552 -
553/*! -
554 \fn bool QGLFormat::stereo() const -
555 -
556 Returns true if stereo buffering is enabled; otherwise returns -
557 false. Stereo buffering is disabled by default. -
558 -
559 \sa setStereo() -
560*/ -
561 -
562/*! -
563 If \a enable is true enables stereo buffering; otherwise disables -
564 stereo buffering. -
565 -
566 Stereo buffering is disabled by default. -
567 -
568 Stereo buffering provides extra color buffers to generate left-eye -
569 and right-eye images. -
570 -
571 \sa stereo() -
572*/ -
573 -
574void QGLFormat::setStereo(bool enable) -
575{ -
576 setOption(enable ? QGL::StereoBuffers : QGL::NoStereoBuffers);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::StereoBuffers : QGL::NoStereoBuffers);
-
577}
never executed: }
0
578 -
579 -
580/*! -
581 \fn bool QGLFormat::directRendering() const -
582 -
583 Returns true if direct rendering is enabled; otherwise returns -
584 false. -
585 -
586 Direct rendering is enabled by default. -
587 -
588 \sa setDirectRendering() -
589*/ -
590 -
591/*! -
592 If \a enable is true enables direct rendering; otherwise disables -
593 direct rendering. -
594 -
595 Direct rendering is enabled by default. -
596 -
597 Enabling this option will make OpenGL bypass the underlying window -
598 system and render directly from hardware to the screen, if this is -
599 supported by the system. -
600 -
601 \sa directRendering() -
602*/ -
603 -
604void QGLFormat::setDirectRendering(bool enable) -
605{ -
606 setOption(enable ? QGL::DirectRendering : QGL::IndirectRendering);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::DirectRendering : QGL::IndirectRendering);
-
607}
never executed: }
0
608 -
609/*! -
610 \fn bool QGLFormat::sampleBuffers() const -
611 -
612 Returns true if multisample buffer support is enabled; otherwise -
613 returns false. -
614 -
615 The multisample buffer is disabled by default. -
616 -
617 \sa setSampleBuffers() -
618*/ -
619 -
620/*! -
621 If \a enable is true, a GL context with multisample buffer support -
622 is picked; otherwise ignored. -
623 -
624 \sa sampleBuffers(), setSamples(), samples() -
625*/ -
626void QGLFormat::setSampleBuffers(bool enable) -
627{ -
628 setOption(enable ? QGL::SampleBuffers : QGL::NoSampleBuffers);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::SampleBuffers : QGL::NoSampleBuffers);
-
629}
never executed: }
0
630 -
631/*! -
632 Returns the number of samples per pixel when multisampling is -
633 enabled. By default, the highest number of samples that is -
634 available is used. -
635 -
636 \sa setSampleBuffers(), sampleBuffers(), setSamples() -
637*/ -
638int QGLFormat::samples() const -
639{ -
640 return d->numSamples;
never executed: return d->numSamples;
0
641} -
642 -
643/*! -
644 Set the preferred number of samples per pixel when multisampling -
645 is enabled to \a numSamples. By default, the highest number of -
646 samples available is used. -
647 -
648 \sa setSampleBuffers(), sampleBuffers(), samples() -
649*/ -
650void QGLFormat::setSamples(int numSamples) -
651{ -
652 detach();
never executed (the execution status of this line is deduced): detach();
-
653 if (numSamples < 0) {
never evaluated: numSamples < 0
0
654 qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 654, __PRETTY_FUNCTION__).warning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
-
655 return;
never executed: return;
0
656 } -
657 d->numSamples = numSamples;
never executed (the execution status of this line is deduced): d->numSamples = numSamples;
-
658 setSampleBuffers(numSamples > 0);
never executed (the execution status of this line is deduced): setSampleBuffers(numSamples > 0);
-
659}
never executed: }
0
660 -
661/*! -
662 \since 4.2 -
663 -
664 Set the preferred swap interval. This can be used to sync the GL -
665 drawing into a system window to the vertical refresh of the screen. -
666 Setting an \a interval value of 0 will turn the vertical refresh syncing -
667 off, any value higher than 0 will turn the vertical syncing on. -
668 -
669 Under Windows and under X11, where the \c{WGL_EXT_swap_control} -
670 and \c{GLX_SGI_video_sync} extensions are used, the \a interval -
671 parameter can be used to set the minimum number of video frames -
672 that are displayed before a buffer swap will occur. In effect, -
673 setting the \a interval to 10, means there will be 10 vertical -
674 retraces between every buffer swap. -
675 -
676 Under Windows the \c{WGL_EXT_swap_control} extension has to be present, -
677 and under X11 the \c{GLX_SGI_video_sync} extension has to be present. -
678*/ -
679void QGLFormat::setSwapInterval(int interval) -
680{ -
681 detach();
never executed (the execution status of this line is deduced): detach();
-
682 d->swapInterval = interval;
never executed (the execution status of this line is deduced): d->swapInterval = interval;
-
683}
never executed: }
0
684 -
685/*! -
686 \since 4.2 -
687 -
688 Returns the currently set swap interval. -1 is returned if setting -
689 the swap interval isn't supported in the system GL implementation. -
690*/ -
691int QGLFormat::swapInterval() const -
692{ -
693 return d->swapInterval;
never executed: return d->swapInterval;
0
694} -
695 -
696/*! -
697 \fn bool QGLFormat::hasOverlay() const -
698 -
699 Returns true if overlay plane is enabled; otherwise returns false. -
700 -
701 Overlay is disabled by default. -
702 -
703 \sa setOverlay() -
704*/ -
705 -
706/*! -
707 If \a enable is true enables an overlay plane; otherwise disables -
708 the overlay plane. -
709 -
710 Enabling the overlay plane will cause QGLWidget to create an -
711 additional context in an overlay plane. See the QGLWidget -
712 documentation for further information. -
713 -
714 \sa hasOverlay() -
715*/ -
716 -
717void QGLFormat::setOverlay(bool enable) -
718{ -
719 setOption(enable ? QGL::HasOverlay : QGL::NoOverlay);
never executed (the execution status of this line is deduced): setOption(enable ? QGL::HasOverlay : QGL::NoOverlay);
-
720}
never executed: }
0
721 -
722/*! -
723 Returns the plane of this format. The default for normal formats -
724 is 0, which means the normal plane. The default for overlay -
725 formats is 1, which is the first overlay plane. -
726 -
727 \sa setPlane(), defaultOverlayFormat() -
728*/ -
729int QGLFormat::plane() const -
730{ -
731 return d->pln;
never executed: return d->pln;
0
732} -
733 -
734/*! -
735 Sets the requested plane to \a plane. 0 is the normal plane, 1 is -
736 the first overlay plane, 2 is the second overlay plane, etc.; -1, -
737 -2, etc. are underlay planes. -
738 -
739 Note that in contrast to other format specifications, the plane -
740 specifications will be matched exactly. This means that if you -
741 specify a plane that the underlying OpenGL system cannot provide, -
742 an \l{QGLWidget::isValid()}{invalid} QGLWidget will be -
743 created. -
744 -
745 \sa plane() -
746*/ -
747void QGLFormat::setPlane(int plane) -
748{ -
749 detach();
never executed (the execution status of this line is deduced): detach();
-
750 d->pln = plane;
never executed (the execution status of this line is deduced): d->pln = plane;
-
751}
never executed: }
0
752 -
753/*! -
754 Sets the format option to \a opt. -
755 -
756 \sa testOption() -
757*/ -
758 -
759void QGLFormat::setOption(QGL::FormatOptions opt) -
760{ -
761 detach();
never executed (the execution status of this line is deduced): detach();
-
762 if (opt & 0xffff)
never evaluated: opt & 0xffff
0
763 d->opts |= opt;
never executed: d->opts |= opt;
0
764 else -
765 d->opts &= ~(opt >> 16);
never executed: d->opts &= ~(opt >> 16);
0
766} -
767 -
768 -
769 -
770/*! -
771 Returns true if format option \a opt is set; otherwise returns false. -
772 -
773 \sa setOption() -
774*/ -
775 -
776bool QGLFormat::testOption(QGL::FormatOptions opt) const -
777{ -
778 if (opt & 0xffff)
never evaluated: opt & 0xffff
0
779 return (d->opts & opt) != 0;
never executed: return (d->opts & opt) != 0;
0
780 else -
781 return (d->opts & (opt >> 16)) == 0;
never executed: return (d->opts & (opt >> 16)) == 0;
0
782} -
783 -
784/*! -
785 Set the minimum depth buffer size to \a size. -
786 -
787 \sa depthBufferSize(), setDepth(), depth() -
788*/ -
789void QGLFormat::setDepthBufferSize(int size) -
790{ -
791 detach();
never executed (the execution status of this line is deduced): detach();
-
792 if (size < 0) {
never evaluated: size < 0
0
793 qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 793, __PRETTY_FUNCTION__).warning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
-
794 return;
never executed: return;
0
795 } -
796 d->depthSize = size;
never executed (the execution status of this line is deduced): d->depthSize = size;
-
797 setDepth(size > 0);
never executed (the execution status of this line is deduced): setDepth(size > 0);
-
798}
never executed: }
0
799 -
800/*! -
801 Returns the depth buffer size. -
802 -
803 \sa depth(), setDepth(), setDepthBufferSize() -
804*/ -
805int QGLFormat::depthBufferSize() const -
806{ -
807 return d->depthSize;
never executed: return d->depthSize;
0
808} -
809 -
810/*! -
811 \since 4.2 -
812 -
813 Set the preferred red buffer size to \a size. -
814 -
815 \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize() -
816*/ -
817void QGLFormat::setRedBufferSize(int size) -
818{ -
819 detach();
never executed (the execution status of this line is deduced): detach();
-
820 if (size < 0) {
never evaluated: size < 0
0
821 qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 821, __PRETTY_FUNCTION__).warning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
-
822 return;
never executed: return;
0
823 } -
824 d->redSize = size;
never executed (the execution status of this line is deduced): d->redSize = size;
-
825}
never executed: }
0
826 -
827/*! -
828 \since 4.2 -
829 -
830 Returns the red buffer size. -
831 -
832 \sa setRedBufferSize() -
833*/ -
834int QGLFormat::redBufferSize() const -
835{ -
836 return d->redSize;
never executed: return d->redSize;
0
837} -
838 -
839/*! -
840 \since 4.2 -
841 -
842 Set the preferred green buffer size to \a size. -
843 -
844 \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize() -
845*/ -
846void QGLFormat::setGreenBufferSize(int size) -
847{ -
848 detach();
never executed (the execution status of this line is deduced): detach();
-
849 if (size < 0) {
never evaluated: size < 0
0
850 qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 850, __PRETTY_FUNCTION__).warning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
-
851 return;
never executed: return;
0
852 } -
853 d->greenSize = size;
never executed (the execution status of this line is deduced): d->greenSize = size;
-
854}
never executed: }
0
855 -
856/*! -
857 \since 4.2 -
858 -
859 Returns the green buffer size. -
860 -
861 \sa setGreenBufferSize() -
862*/ -
863int QGLFormat::greenBufferSize() const -
864{ -
865 return d->greenSize;
never executed: return d->greenSize;
0
866} -
867 -
868/*! -
869 \since 4.2 -
870 -
871 Set the preferred blue buffer size to \a size. -
872 -
873 \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize() -
874*/ -
875void QGLFormat::setBlueBufferSize(int size) -
876{ -
877 detach();
never executed (the execution status of this line is deduced): detach();
-
878 if (size < 0) {
never evaluated: size < 0
0
879 qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 879, __PRETTY_FUNCTION__).warning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
-
880 return;
never executed: return;
0
881 } -
882 d->blueSize = size;
never executed (the execution status of this line is deduced): d->blueSize = size;
-
883}
never executed: }
0
884 -
885/*! -
886 \since 4.2 -
887 -
888 Returns the blue buffer size. -
889 -
890 \sa setBlueBufferSize() -
891*/ -
892int QGLFormat::blueBufferSize() const -
893{ -
894 return d->blueSize;
never executed: return d->blueSize;
0
895} -
896 -
897/*! -
898 Set the preferred alpha buffer size to \a size. -
899 This function implicitly enables the alpha channel. -
900 -
901 \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize() -
902*/ -
903void QGLFormat::setAlphaBufferSize(int size) -
904{ -
905 detach();
never executed (the execution status of this line is deduced): detach();
-
906 if (size < 0) {
never evaluated: size < 0
0
907 qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 907, __PRETTY_FUNCTION__).warning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
-
908 return;
never executed: return;
0
909 } -
910 d->alphaSize = size;
never executed (the execution status of this line is deduced): d->alphaSize = size;
-
911 setAlpha(size > 0);
never executed (the execution status of this line is deduced): setAlpha(size > 0);
-
912}
never executed: }
0
913 -
914/*! -
915 Returns the alpha buffer size. -
916 -
917 \sa alpha(), setAlpha(), setAlphaBufferSize() -
918*/ -
919int QGLFormat::alphaBufferSize() const -
920{ -
921 return d->alphaSize;
never executed: return d->alphaSize;
0
922} -
923 -
924/*! -
925 Set the preferred accumulation buffer size, where \a size is the -
926 bit depth for each RGBA component. -
927 -
928 \sa accum(), setAccum(), accumBufferSize() -
929*/ -
930void QGLFormat::setAccumBufferSize(int size) -
931{ -
932 detach();
never executed (the execution status of this line is deduced): detach();
-
933 if (size < 0) {
never evaluated: size < 0
0
934 qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 934, __PRETTY_FUNCTION__).warning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
-
935 return;
never executed: return;
0
936 } -
937 d->accumSize = size;
never executed (the execution status of this line is deduced): d->accumSize = size;
-
938 setAccum(size > 0);
never executed (the execution status of this line is deduced): setAccum(size > 0);
-
939}
never executed: }
0
940 -
941/*! -
942 Returns the accumulation buffer size. -
943 -
944 \sa setAccumBufferSize(), accum(), setAccum() -
945*/ -
946int QGLFormat::accumBufferSize() const -
947{ -
948 return d->accumSize;
never executed: return d->accumSize;
0
949} -
950 -
951/*! -
952 Set the preferred stencil buffer size to \a size. -
953 -
954 \sa stencilBufferSize(), setStencil(), stencil() -
955*/ -
956void QGLFormat::setStencilBufferSize(int size) -
957{ -
958 detach();
never executed (the execution status of this line is deduced): detach();
-
959 if (size < 0) {
never evaluated: size < 0
0
960 qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 960, __PRETTY_FUNCTION__).warning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
-
961 return;
never executed: return;
0
962 } -
963 d->stencilSize = size;
never executed (the execution status of this line is deduced): d->stencilSize = size;
-
964 setStencil(size > 0);
never executed (the execution status of this line is deduced): setStencil(size > 0);
-
965}
never executed: }
0
966 -
967/*! -
968 Returns the stencil buffer size. -
969 -
970 \sa stencil(), setStencil(), setStencilBufferSize() -
971*/ -
972int QGLFormat::stencilBufferSize() const -
973{ -
974 return d->stencilSize;
never executed: return d->stencilSize;
0
975} -
976 -
977/*! -
978 \since 4.7 -
979 -
980 Set the OpenGL version to the \a major and \a minor numbers. If a -
981 context compatible with the requested OpenGL version cannot be -
982 created, a context compatible with version 1.x is created instead. -
983 -
984 \sa majorVersion(), minorVersion() -
985*/ -
986void QGLFormat::setVersion(int major, int minor) -
987{ -
988 if (major < 1 || minor < 0) {
never evaluated: major < 1
never evaluated: minor < 0
0
989 qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor);
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 989, __PRETTY_FUNCTION__).warning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor);
-
990 return;
never executed: return;
0
991 } -
992 detach();
never executed (the execution status of this line is deduced): detach();
-
993 d->majorVersion = major;
never executed (the execution status of this line is deduced): d->majorVersion = major;
-
994 d->minorVersion = minor;
never executed (the execution status of this line is deduced): d->minorVersion = minor;
-
995}
never executed: }
0
996 -
997/*! -
998 \since 4.7 -
999 -
1000 Returns the OpenGL major version. -
1001 -
1002 \sa setVersion(), minorVersion() -
1003*/ -
1004int QGLFormat::majorVersion() const -
1005{ -
1006 return d->majorVersion;
never executed: return d->majorVersion;
0
1007} -
1008 -
1009/*! -
1010 \since 4.7 -
1011 -
1012 Returns the OpenGL minor version. -
1013 -
1014 \sa setVersion(), majorVersion() -
1015*/ -
1016int QGLFormat::minorVersion() const -
1017{ -
1018 return d->minorVersion;
never executed: return d->minorVersion;
0
1019} -
1020 -
1021/*! -
1022 \enum QGLFormat::OpenGLContextProfile -
1023 \since 4.7 -
1024 -
1025 This enum describes the OpenGL context profiles that can be -
1026 specified for contexts implementing OpenGL version 3.2 or -
1027 higher. These profiles are different from OpenGL ES profiles. -
1028 -
1029 \value NoProfile OpenGL version is lower than 3.2. -
1030 \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. -
1031 \value CompatibilityProfile Functionality from earlier OpenGL versions is available. -
1032*/ -
1033 -
1034/*! -
1035 \since 4.7 -
1036 -
1037 Set the OpenGL context profile to \a profile. The \a profile is -
1038 ignored if the requested OpenGL version is less than 3.2. -
1039 -
1040 \sa profile() -
1041*/ -
1042void QGLFormat::setProfile(OpenGLContextProfile profile) -
1043{ -
1044 detach();
never executed (the execution status of this line is deduced): detach();
-
1045 d->profile = profile;
never executed (the execution status of this line is deduced): d->profile = profile;
-
1046}
never executed: }
0
1047 -
1048/*! -
1049 \since 4.7 -
1050 -
1051 Returns the OpenGL context profile. -
1052 -
1053 \sa setProfile() -
1054*/ -
1055QGLFormat::OpenGLContextProfile QGLFormat::profile() const -
1056{ -
1057 return d->profile;
never executed: return d->profile;
0
1058} -
1059 -
1060 -
1061/*! -
1062 \fn bool QGLFormat::hasOpenGL() -
1063 -
1064 Returns true if the window system has any OpenGL support; -
1065 otherwise returns false. -
1066 -
1067 \warning This function must not be called until the QApplication -
1068 object has been created. -
1069*/ -
1070 -
1071 -
1072 -
1073/*! -
1074 \fn bool QGLFormat::hasOpenGLOverlays() -
1075 -
1076 Returns true if the window system supports OpenGL overlays; -
1077 otherwise returns false. -
1078 -
1079 \warning This function must not be called until the QApplication -
1080 object has been created. -
1081*/ -
1082 -
1083QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString) -
1084{ -
1085 QGLFormat::OpenGLVersionFlags versionFlags = QGLFormat::OpenGL_Version_None;
never executed (the execution status of this line is deduced): QGLFormat::OpenGLVersionFlags versionFlags = QGLFormat::OpenGL_Version_None;
-
1086 -
1087 if (versionString.startsWith(QLatin1String("OpenGL ES"))) {
never evaluated: versionString.startsWith(QLatin1String("OpenGL ES"))
0
1088 QStringList parts = versionString.split(QLatin1Char(' '));
never executed (the execution status of this line is deduced): QStringList parts = versionString.split(QLatin1Char(' '));
-
1089 if (parts.size() >= 3) {
never evaluated: parts.size() >= 3
0
1090 if (parts[2].startsWith(QLatin1String("1."))) {
never evaluated: parts[2].startsWith(QLatin1String("1."))
0
1091 if (parts[1].endsWith(QLatin1String("-CM"))) {
never evaluated: parts[1].endsWith(QLatin1String("-CM"))
0
1092 versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_0 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_0 |
-
1093 QGLFormat::OpenGL_ES_CommonLite_Version_1_0;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_ES_CommonLite_Version_1_0;
-
1094 if (parts[2].startsWith(QLatin1String("1.1")))
never evaluated: parts[2].startsWith(QLatin1String("1.1"))
0
1095 versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 |
never executed: versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 | QGLFormat::OpenGL_ES_CommonLite_Version_1_1;
0
1096 QGLFormat::OpenGL_ES_CommonLite_Version_1_1;
never executed: versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 | QGLFormat::OpenGL_ES_CommonLite_Version_1_1;
0
1097 } else {
never executed: }
0
1098 // Not -CM, must be CL, CommonLite -
1099 versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_0;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_0;
-
1100 if (parts[2].startsWith(QLatin1String("1.1")))
never evaluated: parts[2].startsWith(QLatin1String("1.1"))
0
1101 versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_1;
never executed: versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_1;
0
1102 }
never executed: }
0
1103 } else { -
1104 // OpenGL ES version 2.0 or higher -
1105 versionFlags |= QGLFormat::OpenGL_ES_Version_2_0;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_ES_Version_2_0;
-
1106 }
never executed: }
0
1107 } else { -
1108 // if < 3 parts to the name, it is an unrecognised OpenGL ES -
1109 qWarning("Unrecognised OpenGL ES version");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 1109, __PRETTY_FUNCTION__).warning("Unrecognised OpenGL ES version");
-
1110 }
never executed: }
0
1111 } else { -
1112 // not ES, regular OpenGL, the version numbers are first in the string -
1113 if (versionString.startsWith(QLatin1String("1."))) {
never evaluated: versionString.startsWith(QLatin1String("1."))
0
1114 switch (versionString[2].toLatin1()) { -
1115 case '5': -
1116 versionFlags |= QGLFormat::OpenGL_Version_1_5;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_5;
-
1117 case '4':
code before this statement never executed: case '4':
0
1118 versionFlags |= QGLFormat::OpenGL_Version_1_4;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_4;
-
1119 case '3':
code before this statement never executed: case '3':
0
1120 versionFlags |= QGLFormat::OpenGL_Version_1_3;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_3;
-
1121 case '2':
code before this statement never executed: case '2':
0
1122 versionFlags |= QGLFormat::OpenGL_Version_1_2;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_2;
-
1123 case '1':
code before this statement never executed: case '1':
0
1124 versionFlags |= QGLFormat::OpenGL_Version_1_1;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_1;
-
1125 default: -
1126 break;
never executed: break;
0
1127 } -
1128 } else if (versionString.startsWith(QLatin1String("2."))) {
never executed: }
never evaluated: versionString.startsWith(QLatin1String("2."))
0
1129 versionFlags |= QGLFormat::OpenGL_Version_1_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_1 |
-
1130 QGLFormat::OpenGL_Version_1_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_2 |
-
1131 QGLFormat::OpenGL_Version_1_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_3 |
-
1132 QGLFormat::OpenGL_Version_1_4 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_4 |
-
1133 QGLFormat::OpenGL_Version_1_5 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_5 |
-
1134 QGLFormat::OpenGL_Version_2_0;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_0;
-
1135 if (versionString[2].toLatin1() == '1')
never evaluated: versionString[2].toLatin1() == '1'
0
1136 versionFlags |= QGLFormat::OpenGL_Version_2_1;
never executed: versionFlags |= QGLFormat::OpenGL_Version_2_1;
0
1137 } else if (versionString.startsWith(QLatin1String("3."))) {
never executed: }
never evaluated: versionString.startsWith(QLatin1String("3."))
0
1138 versionFlags |= QGLFormat::OpenGL_Version_1_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_1 |
-
1139 QGLFormat::OpenGL_Version_1_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_2 |
-
1140 QGLFormat::OpenGL_Version_1_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_3 |
-
1141 QGLFormat::OpenGL_Version_1_4 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_4 |
-
1142 QGLFormat::OpenGL_Version_1_5 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_5 |
-
1143 QGLFormat::OpenGL_Version_2_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_0 |
-
1144 QGLFormat::OpenGL_Version_2_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_1 |
-
1145 QGLFormat::OpenGL_Version_3_0;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_0;
-
1146 switch (versionString[2].toLatin1()) { -
1147 case '3': -
1148 versionFlags |= QGLFormat::OpenGL_Version_3_3;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_3_3;
-
1149 case '2':
code before this statement never executed: case '2':
0
1150 versionFlags |= QGLFormat::OpenGL_Version_3_2;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_3_2;
-
1151 case '1':
code before this statement never executed: case '1':
0
1152 versionFlags |= QGLFormat::OpenGL_Version_3_1;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_3_1;
-
1153 case '0': -
1154 break;
never executed: break;
0
1155 default: -
1156 versionFlags |= QGLFormat::OpenGL_Version_3_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_3_1 |
-
1157 QGLFormat::OpenGL_Version_3_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_2 |
-
1158 QGLFormat::OpenGL_Version_3_3;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_3;
-
1159 break;
never executed: break;
0
1160 } -
1161 } else if (versionString.startsWith(QLatin1String("4."))) {
never executed: }
never evaluated: versionString.startsWith(QLatin1String("4."))
0
1162 versionFlags |= QGLFormat::OpenGL_Version_1_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_1 |
-
1163 QGLFormat::OpenGL_Version_1_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_2 |
-
1164 QGLFormat::OpenGL_Version_1_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_3 |
-
1165 QGLFormat::OpenGL_Version_1_4 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_4 |
-
1166 QGLFormat::OpenGL_Version_1_5 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_5 |
-
1167 QGLFormat::OpenGL_Version_2_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_0 |
-
1168 QGLFormat::OpenGL_Version_2_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_1 |
-
1169 QGLFormat::OpenGL_Version_3_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_0 |
-
1170 QGLFormat::OpenGL_Version_3_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_1 |
-
1171 QGLFormat::OpenGL_Version_3_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_2 |
-
1172 QGLFormat::OpenGL_Version_3_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_3 |
-
1173 QGLFormat::OpenGL_Version_4_0;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_0;
-
1174 switch (versionString[2].toLatin1()) { -
1175 case '3': -
1176 versionFlags |= QGLFormat::OpenGL_Version_4_3;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_4_3;
-
1177 case '2':
code before this statement never executed: case '2':
0
1178 versionFlags |= QGLFormat::OpenGL_Version_4_2;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_4_2;
-
1179 case '1':
code before this statement never executed: case '1':
0
1180 versionFlags |= QGLFormat::OpenGL_Version_4_1;
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_4_1;
-
1181 case '0': -
1182 break;
never executed: break;
0
1183 default: -
1184 versionFlags |= QGLFormat::OpenGL_Version_4_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_4_1 |
-
1185 QGLFormat::OpenGL_Version_4_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_2 |
-
1186 QGLFormat::OpenGL_Version_4_3;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_3;
-
1187 break;
never executed: break;
0
1188 } -
1189 } else {
never executed: }
0
1190 versionFlags |= QGLFormat::OpenGL_Version_1_1 |
never executed (the execution status of this line is deduced): versionFlags |= QGLFormat::OpenGL_Version_1_1 |
-
1191 QGLFormat::OpenGL_Version_1_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_2 |
-
1192 QGLFormat::OpenGL_Version_1_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_3 |
-
1193 QGLFormat::OpenGL_Version_1_4 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_4 |
-
1194 QGLFormat::OpenGL_Version_1_5 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_1_5 |
-
1195 QGLFormat::OpenGL_Version_2_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_0 |
-
1196 QGLFormat::OpenGL_Version_2_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_2_1 |
-
1197 QGLFormat::OpenGL_Version_3_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_0 |
-
1198 QGLFormat::OpenGL_Version_3_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_1 |
-
1199 QGLFormat::OpenGL_Version_3_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_2 |
-
1200 QGLFormat::OpenGL_Version_3_3 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_3_3 |
-
1201 QGLFormat::OpenGL_Version_4_0 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_0 |
-
1202 QGLFormat::OpenGL_Version_4_1 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_1 |
-
1203 QGLFormat::OpenGL_Version_4_2 |
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_2 |
-
1204 QGLFormat::OpenGL_Version_4_3;
never executed (the execution status of this line is deduced): QGLFormat::OpenGL_Version_4_3;
-
1205 }
never executed: }
0
1206 } -
1207 return versionFlags;
never executed: return versionFlags;
0
1208} -
1209 -
1210/*! -
1211 \enum QGLFormat::OpenGLVersionFlag -
1212 \since 4.2 -
1213 -
1214 This enum describes the various OpenGL versions that are -
1215 recognized by Qt. Use the QGLFormat::openGLVersionFlags() function -
1216 to identify which versions that are supported at runtime. -
1217 -
1218 \value OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current. -
1219 -
1220 \value OpenGL_Version_1_1 OpenGL version 1.1 or higher is present. -
1221 -
1222 \value OpenGL_Version_1_2 OpenGL version 1.2 or higher is present. -
1223 -
1224 \value OpenGL_Version_1_3 OpenGL version 1.3 or higher is present. -
1225 -
1226 \value OpenGL_Version_1_4 OpenGL version 1.4 or higher is present. -
1227 -
1228 \value OpenGL_Version_1_5 OpenGL version 1.5 or higher is present. -
1229 -
1230 \value OpenGL_Version_2_0 OpenGL version 2.0 or higher is present. -
1231 Note that version 2.0 supports all the functionality of version 1.5. -
1232 -
1233 \value OpenGL_Version_2_1 OpenGL version 2.1 or higher is present. -
1234 -
1235 \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present. -
1236 -
1237 \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. -
1238 Note that OpenGL version 3.1 or higher does not necessarily support all the features of -
1239 version 3.0 and lower. -
1240 -
1241 \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. -
1242 -
1243 \value OpenGL_Version_3_3 OpenGL version 3.3 or higher is present. -
1244 -
1245 \value OpenGL_Version_4_0 OpenGL version 4.0 or higher is present. -
1246 -
1247 \value OpenGL_Version_4_1 OpenGL version 4.1 or higher is present. -
1248 -
1249 \value OpenGL_Version_4_2 OpenGL version 4.2 or higher is present. -
1250 -
1251 \value OpenGL_Version_4_3 OpenGL version 4.3 or higher is present. -
1252 -
1253 \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. -
1254 -
1255 \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. -
1256 The Common profile supports all the features of Common Lite. -
1257 -
1258 \value OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present. -
1259 -
1260 \value OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present. -
1261 The Common profile supports all the features of Common Lite. -
1262 -
1263 \value OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present. -
1264 Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. -
1265 So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned. -
1266 -
1267 See also \l{http://www.opengl.org} for more information about the different -
1268 revisions of OpenGL. -
1269 -
1270 \sa openGLVersionFlags() -
1271*/ -
1272 -
1273/*! -
1274 \since 4.2 -
1275 -
1276 Identifies, at runtime, which OpenGL versions that are supported -
1277 by the current platform. -
1278 -
1279 Note that if OpenGL version 1.5 is supported, its predecessors -
1280 (i.e., version 1.4 and lower) are also supported. To identify the -
1281 support of a particular feature, like multi texturing, test for -
1282 the version in which the feature was first introduced (i.e., -
1283 version 1.3 in the case of multi texturing) to adapt to the largest -
1284 possible group of runtime platforms. -
1285 -
1286 This function needs a valid current OpenGL context to work; -
1287 otherwise it will return OpenGL_Version_None. -
1288 -
1289 \sa hasOpenGL(), hasOpenGLOverlays() -
1290*/ -
1291QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() -
1292{ -
1293 static bool cachedDefault = false; -
1294 static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; -
1295 QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
-
1296 QGLTemporaryContext *tmpContext = 0;
never executed (the execution status of this line is deduced): QGLTemporaryContext *tmpContext = 0;
-
1297 -
1298 if (currentCtx && currentCtx->d_func()->version_flags_cached)
never evaluated: currentCtx
never evaluated: currentCtx->d_func()->version_flags_cached
0
1299 return currentCtx->d_func()->version_flags;
never executed: return currentCtx->d_func()->version_flags;
0
1300 -
1301 if (!currentCtx) {
never evaluated: !currentCtx
0
1302 if (cachedDefault) {
never evaluated: cachedDefault
0
1303 return defaultVersionFlags;
never executed: return defaultVersionFlags;
0
1304 } else { -
1305 if (!hasOpenGL())
never evaluated: !hasOpenGL()
0
1306 return defaultVersionFlags;
never executed: return defaultVersionFlags;
0
1307 tmpContext = new QGLTemporaryContext;
never executed (the execution status of this line is deduced): tmpContext = new QGLTemporaryContext;
-
1308 cachedDefault = true;
never executed (the execution status of this line is deduced): cachedDefault = true;
-
1309 }
never executed: }
0
1310 } -
1311 -
1312 QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
never executed (the execution status of this line is deduced): QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(0x1F02))));
-
1313 OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString);
never executed (the execution status of this line is deduced): OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString);
-
1314 if (currentCtx) {
never evaluated: currentCtx
0
1315 currentCtx->d_func()->version_flags_cached = true;
never executed (the execution status of this line is deduced): currentCtx->d_func()->version_flags_cached = true;
-
1316 currentCtx->d_func()->version_flags = versionFlags;
never executed (the execution status of this line is deduced): currentCtx->d_func()->version_flags = versionFlags;
-
1317 }
never executed: }
0
1318 if (tmpContext) {
never evaluated: tmpContext
0
1319 defaultVersionFlags = versionFlags;
never executed (the execution status of this line is deduced): defaultVersionFlags = versionFlags;
-
1320 delete tmpContext;
never executed (the execution status of this line is deduced): delete tmpContext;
-
1321 }
never executed: }
0
1322 -
1323 return versionFlags;
never executed: return versionFlags;
0
1324} -
1325 -
1326 -
1327/*! -
1328 Returns the default QGLFormat for the application. All QGLWidget -
1329 objects that are created use this format unless another format is -
1330 specified, e.g. when they are constructed. -
1331 -
1332 If no special default format has been set using -
1333 setDefaultFormat(), the default format is the same as that created -
1334 with QGLFormat(). -
1335 -
1336 \sa setDefaultFormat() -
1337*/ -
1338 -
1339QGLFormat QGLFormat::defaultFormat() -
1340{ -
1341 return *qgl_default_format();
never executed: return *qgl_default_format();
0
1342} -
1343 -
1344/*! -
1345 Sets a new default QGLFormat for the application to \a f. For -
1346 example, to set single buffering as the default instead of double -
1347 buffering, your main() might contain code like this: -
1348 \snippet code/src_opengl_qgl.cpp 4 -
1349 -
1350 \sa defaultFormat() -
1351*/ -
1352 -
1353void QGLFormat::setDefaultFormat(const QGLFormat &f) -
1354{ -
1355 *qgl_default_format() = f;
never executed (the execution status of this line is deduced): *qgl_default_format() = f;
-
1356}
never executed: }
0
1357 -
1358 -
1359/*! -
1360 Returns the default QGLFormat for overlay contexts. -
1361 -
1362 The default overlay format is: -
1363 \list -
1364 \li \l{setDoubleBuffer()}{Double buffer:} Disabled. -
1365 \li \l{setDepth()}{Depth buffer:} Disabled. -
1366 \li \l{setRgba()}{RGBA:} Disabled (i.e., color index enabled). -
1367 \li \l{setAlpha()}{Alpha channel:} Disabled. -
1368 \li \l{setAccum()}{Accumulator buffer:} Disabled. -
1369 \li \l{setStencil()}{Stencil buffer:} Disabled. -
1370 \li \l{setStereo()}{Stereo:} Disabled. -
1371 \li \l{setDirectRendering()}{Direct rendering:} Enabled. -
1372 \li \l{setOverlay()}{Overlay:} Disabled. -
1373 \li \l{setSampleBuffers()}{Multisample buffers:} Disabled. -
1374 \li \l{setPlane()}{Plane:} 1 (i.e., first overlay plane). -
1375 \endlist -
1376 -
1377 \sa setDefaultFormat() -
1378*/ -
1379 -
1380QGLFormat QGLFormat::defaultOverlayFormat() -
1381{ -
1382 return *defaultOverlayFormatInstance();
never executed: return *defaultOverlayFormatInstance();
0
1383} -
1384 -
1385/*! -
1386 Sets a new default QGLFormat for overlay contexts to \a f. This -
1387 format is used whenever a QGLWidget is created with a format that -
1388 hasOverlay() enabled. -
1389 -
1390 For example, to get a double buffered overlay context (if -
1391 available), use code like this: -
1392 -
1393 \snippet code/src_opengl_qgl.cpp 5 -
1394 -
1395 As usual, you can find out after widget creation whether the -
1396 underlying OpenGL system was able to provide the requested -
1397 specification: -
1398 -
1399 \snippet code/src_opengl_qgl.cpp 6 -
1400 -
1401 \sa defaultOverlayFormat() -
1402*/ -
1403 -
1404void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f) -
1405{ -
1406 QGLFormat *defaultFormat = defaultOverlayFormatInstance();
never executed (the execution status of this line is deduced): QGLFormat *defaultFormat = defaultOverlayFormatInstance();
-
1407 *defaultFormat = f;
never executed (the execution status of this line is deduced): *defaultFormat = f;
-
1408 // Make sure the user doesn't request that the overlays themselves -
1409 // have overlays, since it is unlikely that the system supports -
1410 // infinitely many planes... -
1411 defaultFormat->setOverlay(false);
never executed (the execution status of this line is deduced): defaultFormat->setOverlay(false);
-
1412}
never executed: }
0
1413 -
1414 -
1415/*! -
1416 Returns true if all the options of the two QGLFormat objects -
1417 \a a and \a b are equal; otherwise returns false. -
1418 -
1419 \relates QGLFormat -
1420*/ -
1421 -
1422bool operator==(const QGLFormat& a, const QGLFormat& b) -
1423{ -
1424 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->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1425 && a.d->pln == b.d->pln
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1426 && a.d->alphaSize == b.d->alphaSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1427 && a.d->accumSize == b.d->accumSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1428 && a.d->stencilSize == b.d->stencilSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1429 && a.d->depthSize == b.d->depthSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1430 && a.d->redSize == b.d->redSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1431 && a.d->greenSize == b.d->greenSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1432 && a.d->blueSize == b.d->blueSize
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1433 && a.d->numSamples == b.d->numSamples
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1434 && a.d->swapInterval == b.d->swapInterval
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1435 && a.d->majorVersion == b.d->majorVersion
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1436 && a.d->minorVersion == b.d->minorVersion
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1437 && a.d->profile == b.d->profile);
never executed: return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize && a.d->depthSize == b.d->depthSize && a.d->redSize == b.d->redSize && a.d->greenSize == b.d->greenSize && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion && a.d->profile == b.d->profile);
0
1438} -
1439 -
1440#ifndef QT_NO_DEBUG_STREAM -
1441QDebug operator<<(QDebug dbg, const QGLFormat &f) -
1442{ -
1443 const QGLFormatPrivate * const d = f.d;
never executed (the execution status of this line is deduced): const QGLFormatPrivate * const d = f.d;
-
1444 -
1445 dbg.nospace() << "QGLFormat("
never executed (the execution status of this line is deduced): dbg.nospace() << "QGLFormat("
-
1446 << "options " << d->opts
never executed (the execution status of this line is deduced): << "options " << d->opts
-
1447 << ", plane " << d->pln
never executed (the execution status of this line is deduced): << ", plane " << d->pln
-
1448 << ", depthBufferSize " << d->depthSize
never executed (the execution status of this line is deduced): << ", depthBufferSize " << d->depthSize
-
1449 << ", accumBufferSize " << d->accumSize
never executed (the execution status of this line is deduced): << ", accumBufferSize " << d->accumSize
-
1450 << ", stencilBufferSize " << d->stencilSize
never executed (the execution status of this line is deduced): << ", stencilBufferSize " << d->stencilSize
-
1451 << ", redBufferSize " << d->redSize
never executed (the execution status of this line is deduced): << ", redBufferSize " << d->redSize
-
1452 << ", greenBufferSize " << d->greenSize
never executed (the execution status of this line is deduced): << ", greenBufferSize " << d->greenSize
-
1453 << ", blueBufferSize " << d->blueSize
never executed (the execution status of this line is deduced): << ", blueBufferSize " << d->blueSize
-
1454 << ", alphaBufferSize " << d->alphaSize
never executed (the execution status of this line is deduced): << ", alphaBufferSize " << d->alphaSize
-
1455 << ", samples " << d->numSamples
never executed (the execution status of this line is deduced): << ", samples " << d->numSamples
-
1456 << ", swapInterval " << d->swapInterval
never executed (the execution status of this line is deduced): << ", swapInterval " << d->swapInterval
-
1457 << ", majorVersion " << d->majorVersion
never executed (the execution status of this line is deduced): << ", majorVersion " << d->majorVersion
-
1458 << ", minorVersion " << d->minorVersion
never executed (the execution status of this line is deduced): << ", minorVersion " << d->minorVersion
-
1459 << ", profile " << d->profile
never executed (the execution status of this line is deduced): << ", profile " << d->profile
-
1460 << ')';
never executed (the execution status of this line is deduced): << ')';
-
1461 -
1462 return dbg.space();
never executed: return dbg.space();
0
1463} -
1464#endif -
1465 -
1466 -
1467/*! -
1468 Returns false if all the options of the two QGLFormat objects -
1469 \a a and \a b are equal; otherwise returns true. -
1470 -
1471 \relates QGLFormat -
1472*/ -
1473 -
1474bool operator!=(const QGLFormat& a, const QGLFormat& b) -
1475{ -
1476 return !(a == b);
never executed: return !(a == b);
0
1477} -
1478 -
1479struct QGLContextGroupList { -
1480 QGLContextGroupList() -
1481 : m_mutex(QMutex::Recursive) -
1482 { -
1483 }
never executed: }
0
1484 -
1485 void append(QGLContextGroup *group) { -
1486 QMutexLocker locker(&m_mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&m_mutex);
-
1487 m_list.append(group);
never executed (the execution status of this line is deduced): m_list.append(group);
-
1488 }
never executed: }
0
1489 -
1490 void remove(QGLContextGroup *group) { -
1491 QMutexLocker locker(&m_mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&m_mutex);
-
1492 m_list.removeOne(group);
never executed (the execution status of this line is deduced): m_list.removeOne(group);
-
1493 }
never executed: }
0
1494 -
1495 QList<QGLContextGroup *> m_list; -
1496 QMutex m_mutex; -
1497}; -
1498 -
1499Q_GLOBAL_STATIC(QGLContextGroupList, qt_context_groups)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
1500 -
1501/***************************************************************************** -
1502 QGLContext implementation -
1503 *****************************************************************************/ -
1504 -
1505QGLContextGroup::QGLContextGroup(const QGLContext *context) -
1506 : m_context(context), m_refs(1) -
1507{ -
1508 qt_context_groups()->append(this);
never executed (the execution status of this line is deduced): qt_context_groups()->append(this);
-
1509}
never executed: }
0
1510 -
1511QGLContextGroup::~QGLContextGroup() -
1512{ -
1513 qt_context_groups()->remove(this);
never executed (the execution status of this line is deduced): qt_context_groups()->remove(this);
-
1514}
never executed: }
0
1515 -
1516const QGLContext *qt_gl_transfer_context(const QGLContext *ctx) -
1517{ -
1518 if (!ctx)
never evaluated: !ctx
0
1519 return 0;
never executed: return 0;
0
1520 QList<const QGLContext *> shares
never executed (the execution status of this line is deduced): QList<const QGLContext *> shares
-
1521 (QGLContextPrivate::contextGroup(ctx)->shares());
never executed (the execution status of this line is deduced): (QGLContextPrivate::contextGroup(ctx)->shares());
-
1522 if (shares.size() >= 2)
never evaluated: shares.size() >= 2
0
1523 return (ctx == shares.at(0)) ? shares.at(1) : shares.at(0);
never executed: return (ctx == shares.at(0)) ? shares.at(1) : shares.at(0);
0
1524 else -
1525 return 0;
never executed: return 0;
0
1526} -
1527 -
1528QGLContextPrivate::QGLContextPrivate(QGLContext *context) -
1529 : internal_context(false) -
1530 , q_ptr(context) -
1531 , texture_destroyer(0) -
1532 , functions(0) -
1533{ -
1534 group = new QGLContextGroup(context);
never executed (the execution status of this line is deduced): group = new QGLContextGroup(context);
-
1535 -
1536 if (qApp) {
never evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))
0
1537 texture_destroyer = new QGLTextureDestroyer;
never executed (the execution status of this line is deduced): texture_destroyer = new QGLTextureDestroyer;
-
1538 texture_destroyer->moveToThread(qApp->thread());
never executed (the execution status of this line is deduced): texture_destroyer->moveToThread((static_cast<QApplication *>(QCoreApplication::instance()))->thread());
-
1539 }
never executed: }
0
1540}
never executed: }
0
1541 -
1542QGLContextPrivate::~QGLContextPrivate() -
1543{ -
1544 delete functions;
never executed (the execution status of this line is deduced): delete functions;
-
1545 -
1546 if (!group->m_refs.deref()) {
never evaluated: !group->m_refs.deref()
0
1547 Q_ASSERT(group->context() == q_ptr);
never executed (the execution status of this line is deduced): qt_noop();
-
1548 delete group;
never executed (the execution status of this line is deduced): delete group;
-
1549 }
never executed: }
0
1550 -
1551 delete texture_destroyer;
never executed (the execution status of this line is deduced): delete texture_destroyer;
-
1552}
never executed: }
0
1553 -
1554void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) -
1555{ -
1556 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
1557 glFormat = reqFormat = format;
never executed (the execution status of this line is deduced): glFormat = reqFormat = format;
-
1558 valid = false;
never executed (the execution status of this line is deduced): valid = false;
-
1559 q->setDevice(dev);
never executed (the execution status of this line is deduced): q->setDevice(dev);
-
1560 -
1561 guiGlContext = 0;
never executed (the execution status of this line is deduced): guiGlContext = 0;
-
1562 ownContext = false;
never executed (the execution status of this line is deduced): ownContext = false;
-
1563 fbo = 0;
never executed (the execution status of this line is deduced): fbo = 0;
-
1564 crWin = false;
never executed (the execution status of this line is deduced): crWin = false;
-
1565 initDone = false;
never executed (the execution status of this line is deduced): initDone = false;
-
1566 sharing = false;
never executed (the execution status of this line is deduced): sharing = false;
-
1567 max_texture_size = -1;
never executed (the execution status of this line is deduced): max_texture_size = -1;
-
1568 version_flags_cached = false;
never executed (the execution status of this line is deduced): version_flags_cached = false;
-
1569 version_flags = QGLFormat::OpenGL_Version_None;
never executed (the execution status of this line is deduced): version_flags = QGLFormat::OpenGL_Version_None;
-
1570 extension_flags_cached = false;
never executed (the execution status of this line is deduced): extension_flags_cached = false;
-
1571 extension_flags = 0;
never executed (the execution status of this line is deduced): extension_flags = 0;
-
1572 current_fbo = 0;
never executed (the execution status of this line is deduced): current_fbo = 0;
-
1573 default_fbo = 0;
never executed (the execution status of this line is deduced): default_fbo = 0;
-
1574 active_engine = 0;
never executed (the execution status of this line is deduced): active_engine = 0;
-
1575 workaround_needsFullClearOnEveryFrame = false;
never executed (the execution status of this line is deduced): workaround_needsFullClearOnEveryFrame = false;
-
1576 workaround_brokenFBOReadBack = false;
never executed (the execution status of this line is deduced): workaround_brokenFBOReadBack = false;
-
1577 workaround_brokenTexSubImage = false;
never executed (the execution status of this line is deduced): workaround_brokenTexSubImage = false;
-
1578 workaroundsCached = false;
never executed (the execution status of this line is deduced): workaroundsCached = false;
-
1579 -
1580 workaround_brokenTextureFromPixmap = false;
never executed (the execution status of this line is deduced): workaround_brokenTextureFromPixmap = false;
-
1581 workaround_brokenTextureFromPixmap_init = false;
never executed (the execution status of this line is deduced): workaround_brokenTextureFromPixmap_init = false;
-
1582 -
1583 workaround_brokenAlphaTexSubImage = false;
never executed (the execution status of this line is deduced): workaround_brokenAlphaTexSubImage = false;
-
1584 workaround_brokenAlphaTexSubImage_init = false;
never executed (the execution status of this line is deduced): workaround_brokenAlphaTexSubImage_init = false;
-
1585 -
1586 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
never evaluated: i < 3
0
1587 vertexAttributeArraysEnabledState[i] = false;
never executed: vertexAttributeArraysEnabledState[i] = false;
0
1588}
never executed: }
0
1589 -
1590QGLContext* QGLContext::currentCtx = 0; -
1591 -
1592/* -
1593 Read back the contents of the currently bound framebuffer, used in -
1594 QGLWidget::grabFrameBuffer(), QGLPixelbuffer::toImage() and -
1595 QGLFramebufferObject::toImage() -
1596*/ -
1597 -
1598static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, bool include_alpha) -
1599{ -
1600 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
never evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
0
1601 // OpenGL gives RGBA; Qt wants ARGB -
1602 uint *p = (uint*)img.bits();
never executed (the execution status of this line is deduced): uint *p = (uint*)img.bits();
-
1603 uint *end = p + w*h;
never executed (the execution status of this line is deduced): uint *end = p + w*h;
-
1604 if (alpha_format && include_alpha) {
never evaluated: alpha_format
never evaluated: include_alpha
0
1605 while (p < end) {
never evaluated: p < end
0
1606 uint a = *p << 24;
never executed (the execution status of this line is deduced): uint a = *p << 24;
-
1607 *p = (*p >> 8) | a;
never executed (the execution status of this line is deduced): *p = (*p >> 8) | a;
-
1608 p++;
never executed (the execution status of this line is deduced): p++;
-
1609 }
never executed: }
0
1610 } else {
never executed: }
0
1611 // This is an old legacy fix for PowerPC based Macs, which -
1612 // we shouldn't remove -
1613 while (p < end) {
never evaluated: p < end
0
1614 *p = 0xff000000 | (*p>>8);
never executed (the execution status of this line is deduced): *p = 0xff000000 | (*p>>8);
-
1615 ++p;
never executed (the execution status of this line is deduced): ++p;
-
1616 }
never executed: }
0
1617 }
never executed: }
0
1618 } else { -
1619 // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB -
1620 for (int y = 0; y < h; y++) {
never evaluated: y < h
0
1621 uint *q = (uint*)img.scanLine(y);
never executed (the execution status of this line is deduced): uint *q = (uint*)img.scanLine(y);
-
1622 for (int x=0; x < w; ++x) {
never evaluated: x < w
0
1623 const uint pixel = *q;
never executed (the execution status of this line is deduced): const uint pixel = *q;
-
1624 if (alpha_format && include_alpha) {
never evaluated: alpha_format
never evaluated: include_alpha
0
1625 *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff)
never executed (the execution status of this line is deduced): *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff)
-
1626 | (pixel & 0xff00ff00);
never executed (the execution status of this line is deduced): | (pixel & 0xff00ff00);
-
1627 } else {
never executed: }
0
1628 *q = 0xff000000 | ((pixel << 16) & 0xff0000)
never executed (the execution status of this line is deduced): *q = 0xff000000 | ((pixel << 16) & 0xff0000)
-
1629 | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00);
never executed (the execution status of this line is deduced): | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00);
-
1630 }
never executed: }
0
1631 -
1632 q++;
never executed (the execution status of this line is deduced): q++;
-
1633 }
never executed: }
0
1634 }
never executed: }
0
1635 -
1636 }
never executed: }
0
1637 img = img.mirrored();
never executed (the execution status of this line is deduced): img = img.mirrored();
-
1638}
never executed: }
0
1639 -
1640QImage qt_gl_read_frame_buffer(const QSize &size, bool alpha_format, bool include_alpha) -
1641{ -
1642 QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied
never executed (the execution status of this line is deduced): QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied
-
1643 : QImage::Format_RGB32);
never executed (the execution status of this line is deduced): : QImage::Format_RGB32);
-
1644 int w = size.width();
never executed (the execution status of this line is deduced): int w = size.width();
-
1645 int h = size.height();
never executed (the execution status of this line is deduced): int h = size.height();
-
1646 glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
never executed (the execution status of this line is deduced): glReadPixels(0, 0, w, h, 0x1908, 0x1401, img.bits());
-
1647 convertFromGLImage(img, w, h, alpha_format, include_alpha);
never executed (the execution status of this line is deduced): convertFromGLImage(img, w, h, alpha_format, include_alpha);
-
1648 return img;
never executed: return img;
0
1649} -
1650 -
1651QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha) -
1652{ -
1653 QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
never executed (the execution status of this line is deduced): QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
-
1654 int w = size.width();
never executed (the execution status of this line is deduced): int w = size.width();
-
1655 int h = size.height();
never executed (the execution status of this line is deduced): int h = size.height();
-
1656#if !defined(QT_OPENGL_ES_2) -
1657 //### glGetTexImage not in GL ES 2.0, need to do something else here! -
1658 glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
never executed (the execution status of this line is deduced): glGetTexImage(0x0DE1, 0, 0x1908, 0x1401, img.bits());
-
1659#endif -
1660 convertFromGLImage(img, w, h, alpha_format, include_alpha);
never executed (the execution status of this line is deduced): convertFromGLImage(img, w, h, alpha_format, include_alpha);
-
1661 return img;
never executed: return img;
0
1662} -
1663 -
1664// returns the highest number closest to v, which is a power of 2 -
1665// NB! assumes 32 bit ints -
1666int qt_next_power_of_two(int v) -
1667{ -
1668 v--;
never executed (the execution status of this line is deduced): v--;
-
1669 v |= v >> 1;
never executed (the execution status of this line is deduced): v |= v >> 1;
-
1670 v |= v >> 2;
never executed (the execution status of this line is deduced): v |= v >> 2;
-
1671 v |= v >> 4;
never executed (the execution status of this line is deduced): v |= v >> 4;
-
1672 v |= v >> 8;
never executed (the execution status of this line is deduced): v |= v >> 8;
-
1673 v |= v >> 16;
never executed (the execution status of this line is deduced): v |= v >> 16;
-
1674 ++v;
never executed (the execution status of this line is deduced): ++v;
-
1675 return v;
never executed: return v;
0
1676} -
1677 -
1678Q_GLOBAL_STATIC(QGLTextureCache, qt_gl_texture_cache)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
1679 -
1680QGLTextureCache::QGLTextureCache() -
1681 : m_cache(64*1024) // cache ~64 MB worth of textures - this is not accurate though -
1682{ -
1683 QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(cleanupTexturesForPixampData);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(cleanupTexturesForPixampData);
-
1684 QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
-
1685 QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
-
1686}
never executed: }
0
1687 -
1688QGLTextureCache::~QGLTextureCache() -
1689{ -
1690 QImagePixmapCleanupHooks::instance()->removePlatformPixmapModificationHook(cleanupTexturesForPixampData);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->removePlatformPixmapModificationHook(cleanupTexturesForPixampData);
-
1691 QImagePixmapCleanupHooks::instance()->removePlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->removePlatformPixmapDestructionHook(cleanupBeforePixmapDestruction);
-
1692 QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
-
1693}
never executed: }
0
1694 -
1695void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) -
1696{ -
1697 QWriteLocker locker(&m_lock);
never executed (the execution status of this line is deduced): QWriteLocker locker(&m_lock);
-
1698 const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)};
never executed (the execution status of this line is deduced): const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)};
-
1699 m_cache.insert(cacheKey, texture, cost);
never executed (the execution status of this line is deduced): m_cache.insert(cacheKey, texture, cost);
-
1700}
never executed: }
0
1701 -
1702void QGLTextureCache::remove(qint64 key) -
1703{ -
1704 QWriteLocker locker(&m_lock);
never executed (the execution status of this line is deduced): QWriteLocker locker(&m_lock);
-
1705 QMutexLocker groupLocker(&qt_context_groups()->m_mutex);
never executed (the execution status of this line is deduced): QMutexLocker groupLocker(&qt_context_groups()->m_mutex);
-
1706 QList<QGLContextGroup *>::const_iterator it = qt_context_groups()->m_list.constBegin();
never executed (the execution status of this line is deduced): QList<QGLContextGroup *>::const_iterator it = qt_context_groups()->m_list.constBegin();
-
1707 while (it != qt_context_groups()->m_list.constEnd()) {
never evaluated: it != qt_context_groups()->m_list.constEnd()
0
1708 const QGLTextureCacheKey cacheKey = {key, *it};
never executed (the execution status of this line is deduced): const QGLTextureCacheKey cacheKey = {key, *it};
-
1709 m_cache.remove(cacheKey);
never executed (the execution status of this line is deduced): m_cache.remove(cacheKey);
-
1710 ++it;
never executed (the execution status of this line is deduced): ++it;
-
1711 }
never executed: }
0
1712}
never executed: }
0
1713 -
1714bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) -
1715{ -
1716 QWriteLocker locker(&m_lock);
never executed (the execution status of this line is deduced): QWriteLocker locker(&m_lock);
-
1717 QList<QGLTextureCacheKey> keys = m_cache.keys();
never executed (the execution status of this line is deduced): QList<QGLTextureCacheKey> keys = m_cache.keys();
-
1718 for (int i = 0; i < keys.size(); ++i) {
never evaluated: i < keys.size()
0
1719 QGLTexture *tex = m_cache.object(keys.at(i));
never executed (the execution status of this line is deduced): QGLTexture *tex = m_cache.object(keys.at(i));
-
1720 if (tex->id == textureId && tex->context == ctx) {
never evaluated: tex->id == textureId
never evaluated: tex->context == ctx
0
1721 tex->options |= QGLContext::MemoryManagedBindOption; // forces a glDeleteTextures() call
never executed (the execution status of this line is deduced): tex->options |= QGLContext::MemoryManagedBindOption;
-
1722 m_cache.remove(keys.at(i));
never executed (the execution status of this line is deduced): m_cache.remove(keys.at(i));
-
1723 return true;
never executed: return true;
0
1724 } -
1725 }
never executed: }
0
1726 return false;
never executed: return false;
0
1727} -
1728 -
1729void QGLTextureCache::removeContextTextures(QGLContext* ctx) -
1730{ -
1731 QWriteLocker locker(&m_lock);
never executed (the execution status of this line is deduced): QWriteLocker locker(&m_lock);
-
1732 QList<QGLTextureCacheKey> keys = m_cache.keys();
never executed (the execution status of this line is deduced): QList<QGLTextureCacheKey> keys = m_cache.keys();
-
1733 for (int i = 0; i < keys.size(); ++i) {
never evaluated: i < keys.size()
0
1734 const QGLTextureCacheKey &key = keys.at(i);
never executed (the execution status of this line is deduced): const QGLTextureCacheKey &key = keys.at(i);
-
1735 if (m_cache.object(key)->context == ctx)
never evaluated: m_cache.object(key)->context == ctx
0
1736 m_cache.remove(key);
never executed: m_cache.remove(key);
0
1737 }
never executed: }
0
1738}
never executed: }
0
1739 -
1740/* -
1741 a hook that removes textures from the cache when a pixmap/image -
1742 is deref'ed -
1743*/ -
1744void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) -
1745{ -
1746 qt_gl_texture_cache()->remove(cacheKey);
never executed (the execution status of this line is deduced): qt_gl_texture_cache()->remove(cacheKey);
-
1747}
never executed: }
0
1748 -
1749 -
1750void QGLTextureCache::cleanupTexturesForPixampData(QPlatformPixmap* pmd) -
1751{ -
1752 cleanupTexturesForCacheKey(pmd->cacheKey());
never executed (the execution status of this line is deduced): cleanupTexturesForCacheKey(pmd->cacheKey());
-
1753}
never executed: }
0
1754 -
1755void QGLTextureCache::cleanupBeforePixmapDestruction(QPlatformPixmap* pmd) -
1756{ -
1757 // Remove any bound textures first: -
1758 cleanupTexturesForPixampData(pmd);
never executed (the execution status of this line is deduced): cleanupTexturesForPixampData(pmd);
-
1759}
never executed: }
0
1760 -
1761QGLTextureCache *QGLTextureCache::instance() -
1762{ -
1763 return qt_gl_texture_cache();
never executed: return qt_gl_texture_cache();
0
1764} -
1765 -
1766// DDS format structure -
1767struct DDSFormat { -
1768 quint32 dwSize; -
1769 quint32 dwFlags; -
1770 quint32 dwHeight; -
1771 quint32 dwWidth; -
1772 quint32 dwLinearSize; -
1773 quint32 dummy1; -
1774 quint32 dwMipMapCount; -
1775 quint32 dummy2[11]; -
1776 struct { -
1777 quint32 dummy3[2]; -
1778 quint32 dwFourCC; -
1779 quint32 dummy4[5]; -
1780 } ddsPixelFormat; -
1781}; -
1782 -
1783// compressed texture pixel formats -
1784#define FOURCC_DXT1 0x31545844 -
1785#define FOURCC_DXT2 0x32545844 -
1786#define FOURCC_DXT3 0x33545844 -
1787#define FOURCC_DXT4 0x34545844 -
1788#define FOURCC_DXT5 0x35545844 -
1789 -
1790// ####TODO Properly #ifdef this class to use #define symbols actually defined -
1791// by system GL includes -
1792#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT -
1793#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -
1794#endif -
1795 -
1796#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT -
1797#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -
1798#endif -
1799 -
1800#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT -
1801#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -
1802#endif -
1803 -
1804#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT -
1805#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -
1806#endif -
1807 -
1808#ifndef GL_GENERATE_MIPMAP_SGIS -
1809#define GL_GENERATE_MIPMAP_SGIS 0x8191 -
1810#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -
1811#endif -
1812 -
1813/*! -
1814 \class QGLContext -
1815 \inmodule QtOpenGL -
1816 -
1817 \brief The QGLContext class encapsulates an OpenGL rendering context. -
1818 -
1819 An OpenGL rendering context is a complete set of OpenGL state -
1820 variables. The rendering context's \l {QGL::FormatOption} {format} -
1821 is set in the constructor, but it can also be set later with -
1822 setFormat(). The format options that are actually set are returned -
1823 by format(); the options you asked for are returned by -
1824 requestedFormat(). Note that after a QGLContext object has been -
1825 constructed, the actual OpenGL context must be created by -
1826 explicitly calling the \l{create()} -
1827 function. The makeCurrent() function makes this context the -
1828 current rendering context. You can make \e no context current -
1829 using doneCurrent(). The reset() function will reset the context -
1830 and make it invalid. -
1831 -
1832 You can examine properties of the context with, e.g. isValid(), -
1833 isSharing(), initialized(), windowCreated() and -
1834 overlayTransparentColor(). -
1835 -
1836 If you're using double buffering you can swap the screen contents -
1837 with the off-screen buffer using swapBuffers(). -
1838 -
1839 Please note that QGLContext is not thread safe. -
1840*/ -
1841 -
1842/*! -
1843 \enum QGLContext::BindOption -
1844 \since 4.6 -
1845 -
1846 A set of options to decide how to bind a texture using bindTexture(). -
1847 -
1848 \value NoBindOption Don't do anything, pass the texture straight -
1849 through. -
1850 -
1851 \value InvertedYBindOption Specifies that the texture should be flipped -
1852 over the X axis so that the texture coordinate 0,0 corresponds to -
1853 the top left corner. Inverting the texture implies a deep copy -
1854 prior to upload. -
1855 -
1856 \value MipmapBindOption Specifies that bindTexture() should try -
1857 to generate mipmaps. If the GL implementation supports the \c -
1858 GL_SGIS_generate_mipmap extension, mipmaps will be automatically -
1859 generated for the texture. Mipmap generation is only supported for -
1860 the \c GL_TEXTURE_2D target. -
1861 -
1862 \value PremultipliedAlphaBindOption Specifies that the image should be -
1863 uploaded with premultiplied alpha and does a conversion accordingly. -
1864 -
1865 \value LinearFilteringBindOption Specifies that the texture filtering -
1866 should be set to GL_LINEAR. Default is GL_NEAREST. If mipmap is -
1867 also enabled, filtering will be set to GL_LINEAR_MIPMAP_LINEAR. -
1868 -
1869 \value DefaultBindOption In Qt 4.5 and earlier, bindTexture() -
1870 would mirror the image and automatically generate mipmaps. This -
1871 option helps preserve this default behavior. -
1872 -
1873 \omitvalue CanFlipNativePixmapBindOption Used by x11 from pixmap to choose -
1874 whether or not it can bind the pixmap upside down or not. -
1875 -
1876 \omitvalue MemoryManagedBindOption Used by paint engines to -
1877 indicate that the pixmap should be memory managed along side with -
1878 the pixmap/image that it stems from, e.g. installing destruction -
1879 hooks in them. -
1880 -
1881 \omitvalue TemporarilyCachedBindOption Used by paint engines on some -
1882 platforms to indicate that the pixmap or image texture is possibly -
1883 cached only temporarily and must be destroyed immediately after the use. -
1884 -
1885 \omitvalue InternalBindOption -
1886*/ -
1887 -
1888/*! -
1889 \obsolete -
1890 -
1891 Constructs an OpenGL context for the given paint \a device, which -
1892 can be a widget or a pixmap. The \a format specifies several -
1893 display options for the context. -
1894 -
1895 If the underlying OpenGL/Window system cannot satisfy all the -
1896 features requested in \a format, the nearest subset of features -
1897 will be used. After creation, the format() method will return the -
1898 actual format obtained. -
1899 -
1900 Note that after a QGLContext object has been constructed, \l -
1901 create() must be called explicitly to create the actual OpenGL -
1902 context. The context will be \l {isValid()}{invalid} if it was not -
1903 possible to obtain a GL context at all. -
1904*/ -
1905 -
1906QGLContext::QGLContext(const QGLFormat &format, QPaintDevice *device) -
1907 : d_ptr(new QGLContextPrivate(this)) -
1908{ -
1909 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
1910 d->init(device, format);
never executed (the execution status of this line is deduced): d->init(device, format);
-
1911}
never executed: }
0
1912 -
1913/*! -
1914 Constructs an OpenGL context with the given \a format which -
1915 specifies several display options for the context. -
1916 -
1917 If the underlying OpenGL/Window system cannot satisfy all the -
1918 features requested in \a format, the nearest subset of features -
1919 will be used. After creation, the format() method will return the -
1920 actual format obtained. -
1921 -
1922 Note that after a QGLContext object has been constructed, \l -
1923 create() must be called explicitly to create the actual OpenGL -
1924 context. The context will be \l {isValid()}{invalid} if it was not -
1925 possible to obtain a GL context at all. -
1926 -
1927 \sa format(), isValid() -
1928*/ -
1929QGLContext::QGLContext(const QGLFormat &format) -
1930 : d_ptr(new QGLContextPrivate(this)) -
1931{ -
1932 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
1933 d->init(0, format);
never executed (the execution status of this line is deduced): d->init(0, format);
-
1934}
never executed: }
0
1935 -
1936/*! -
1937 Destroys the OpenGL context and frees its resources. -
1938*/ -
1939 -
1940QGLContext::~QGLContext() -
1941{ -
1942 // remove any textures cached in this context -
1943 QGLTextureCache::instance()->removeContextTextures(this);
never executed (the execution status of this line is deduced): QGLTextureCache::instance()->removeContextTextures(this);
-
1944 -
1945 // clean up resources specific to this context -
1946 d_ptr->cleanup();
never executed (the execution status of this line is deduced): d_ptr->cleanup();
-
1947 -
1948 QGLSignalProxy::instance()->emitAboutToDestroyContext(this);
never executed (the execution status of this line is deduced): QGLSignalProxy::instance()->emitAboutToDestroyContext(this);
-
1949 reset();
never executed (the execution status of this line is deduced): reset();
-
1950}
never executed: }
0
1951 -
1952void QGLContextPrivate::cleanup() -
1953{ -
1954} -
1955 -
1956#define ctx q_ptr -
1957void QGLContextPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled) -
1958{ -
1959 Q_ASSERT(arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT);
never executed (the execution status of this line is deduced): qt_noop();
-
1960#ifdef glEnableVertexAttribArray -
1961 Q_ASSERT(glEnableVertexAttribArray);
never executed (the execution status of this line is deduced): qt_noop();
-
1962#endif -
1963 -
1964 if (vertexAttributeArraysEnabledState[arrayIndex] && !enabled)
never evaluated: vertexAttributeArraysEnabledState[arrayIndex]
never evaluated: !enabled
0
1965 glDisableVertexAttribArray(arrayIndex);
never executed: QGLContextPrivate::extensionFuncs(q_ptr).qt_glDisableVertexAttribArray(arrayIndex);
0
1966 -
1967 if (!vertexAttributeArraysEnabledState[arrayIndex] && enabled)
never evaluated: !vertexAttributeArraysEnabledState[arrayIndex]
never evaluated: enabled
0
1968 glEnableVertexAttribArray(arrayIndex);
never executed: QGLContextPrivate::extensionFuncs(q_ptr).qt_glEnableVertexAttribArray(arrayIndex);
0
1969 -
1970 vertexAttributeArraysEnabledState[arrayIndex] = enabled;
never executed (the execution status of this line is deduced): vertexAttributeArraysEnabledState[arrayIndex] = enabled;
-
1971}
never executed: }
0
1972 -
1973void QGLContextPrivate::syncGlState() -
1974{ -
1975#ifdef glEnableVertexAttribArray -
1976 Q_ASSERT(glEnableVertexAttribArray);
never executed (the execution status of this line is deduced): qt_noop();
-
1977#endif -
1978 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) {
never evaluated: i < 3
0
1979 if (vertexAttributeArraysEnabledState[i])
never evaluated: vertexAttributeArraysEnabledState[i]
0
1980 glEnableVertexAttribArray(i);
never executed: QGLContextPrivate::extensionFuncs(q_ptr).qt_glEnableVertexAttribArray(i);
0
1981 else -
1982 glDisableVertexAttribArray(i);
never executed: QGLContextPrivate::extensionFuncs(q_ptr).qt_glDisableVertexAttribArray(i);
0
1983 } -
1984 -
1985}
never executed: }
0
1986#undef ctx -
1987 -
1988void QGLContextPrivate::swapRegion(const QRegion &) -
1989{ -
1990 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
1991 q->swapBuffers();
never executed (the execution status of this line is deduced): q->swapBuffers();
-
1992}
never executed: }
0
1993 -
1994/*! -
1995 \overload -
1996 -
1997 Reads the compressed texture file \a fileName and generates a 2D GL -
1998 texture from it. -
1999 -
2000 This function can load DirectDrawSurface (DDS) textures in the -
2001 DXT1, DXT3 and DXT5 DDS formats if the \c GL_ARB_texture_compression -
2002 and \c GL_EXT_texture_compression_s3tc extensions are supported. -
2003 -
2004 Since 4.6.1, textures in the ETC1 format can be loaded if the -
2005 \c GL_OES_compressed_ETC1_RGB8_texture extension is supported -
2006 and the ETC1 texture has been encapsulated in the PVR container format. -
2007 Also, textures in the PVRTC2 and PVRTC4 formats can be loaded -
2008 if the \c GL_IMG_texture_compression_pvrtc extension is supported. -
2009 -
2010 \sa deleteTexture() -
2011*/ -
2012 -
2013GLuint QGLContext::bindTexture(const QString &fileName) -
2014{ -
2015 QGLTexture texture(this);
never executed (the execution status of this line is deduced): QGLTexture texture(this);
-
2016 QSize size = texture.bindCompressedTexture(fileName);
never executed (the execution status of this line is deduced): QSize size = texture.bindCompressedTexture(fileName);
-
2017 if (!size.isValid())
never evaluated: !size.isValid()
0
2018 return 0;
never executed: return 0;
0
2019 return texture.id;
never executed: return texture.id;
0
2020} -
2021 -
2022static inline QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format) -
2023{ -
2024 if (texture_format == GL_BGRA) {
never evaluated: texture_format == 0x80E1
0
2025 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
never evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
0
2026 return ((src_pixel << 24) & 0xff000000)
never executed: return ((src_pixel << 24) & 0xff000000) | ((src_pixel >> 24) & 0x000000ff) | ((src_pixel << 8) & 0x00ff0000) | ((src_pixel >> 8) & 0x0000ff00);
0
2027 | ((src_pixel >> 24) & 0x000000ff)
never executed: return ((src_pixel << 24) & 0xff000000) | ((src_pixel >> 24) & 0x000000ff) | ((src_pixel << 8) & 0x00ff0000) | ((src_pixel >> 8) & 0x0000ff00);
0
2028 | ((src_pixel << 8) & 0x00ff0000)
never executed: return ((src_pixel << 24) & 0xff000000) | ((src_pixel >> 24) & 0x000000ff) | ((src_pixel << 8) & 0x00ff0000) | ((src_pixel >> 8) & 0x0000ff00);
0
2029 | ((src_pixel >> 8) & 0x0000ff00);
never executed: return ((src_pixel << 24) & 0xff000000) | ((src_pixel >> 24) & 0x000000ff) | ((src_pixel << 8) & 0x00ff0000) | ((src_pixel >> 8) & 0x0000ff00);
0
2030 } else { -
2031 return src_pixel;
never executed: return src_pixel;
0
2032 } -
2033 } else { // GL_RGBA -
2034 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
never evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
0
2035 return (src_pixel << 8) | ((src_pixel >> 24) & 0xff);
never executed: return (src_pixel << 8) | ((src_pixel >> 24) & 0xff);
0
2036 } else { -
2037 return ((src_pixel << 16) & 0xff0000)
never executed: return ((src_pixel << 16) & 0xff0000) | ((src_pixel >> 16) & 0xff) | (src_pixel & 0xff00ff00);
0
2038 | ((src_pixel >> 16) & 0xff)
never executed: return ((src_pixel << 16) & 0xff0000) | ((src_pixel >> 16) & 0xff) | (src_pixel & 0xff00ff00);
0
2039 | (src_pixel & 0xff00ff00);
never executed: return ((src_pixel << 16) & 0xff0000) | ((src_pixel >> 16) & 0xff) | (src_pixel & 0xff00ff00);
0
2040 } -
2041 } -
2042} -
2043 -
2044QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format) -
2045{ -
2046 return qt_gl_convertToGLFormatHelper(src_pixel, texture_format);
never executed: return qt_gl_convertToGLFormatHelper(src_pixel, texture_format);
0
2047} -
2048 -
2049static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum texture_format) -
2050{ -
2051 Q_ASSERT(dst.depth() == 32);
never executed (the execution status of this line is deduced): qt_noop();
-
2052 Q_ASSERT(img.depth() == 32);
never executed (the execution status of this line is deduced): qt_noop();
-
2053 -
2054 if (dst.size() != img.size()) {
never evaluated: dst.size() != img.size()
0
2055 int target_width = dst.width();
never executed (the execution status of this line is deduced): int target_width = dst.width();
-
2056 int target_height = dst.height();
never executed (the execution status of this line is deduced): int target_height = dst.height();
-
2057 qreal sx = target_width / qreal(img.width());
never executed (the execution status of this line is deduced): qreal sx = target_width / qreal(img.width());
-
2058 qreal sy = target_height / qreal(img.height());
never executed (the execution status of this line is deduced): qreal sy = target_height / qreal(img.height());
-
2059 -
2060 quint32 *dest = (quint32 *) dst.scanLine(0); // NB! avoid detach here
never executed (the execution status of this line is deduced): quint32 *dest = (quint32 *) dst.scanLine(0);
-
2061 uchar *srcPixels = (uchar *) img.scanLine(img.height() - 1);
never executed (the execution status of this line is deduced): uchar *srcPixels = (uchar *) img.scanLine(img.height() - 1);
-
2062 int sbpl = img.bytesPerLine();
never executed (the execution status of this line is deduced): int sbpl = img.bytesPerLine();
-
2063 int dbpl = dst.bytesPerLine();
never executed (the execution status of this line is deduced): int dbpl = dst.bytesPerLine();
-
2064 -
2065 int ix = int(0x00010000 / sx);
never executed (the execution status of this line is deduced): int ix = int(0x00010000 / sx);
-
2066 int iy = int(0x00010000 / sy);
never executed (the execution status of this line is deduced): int iy = int(0x00010000 / sy);
-
2067 -
2068 quint32 basex = int(0.5 * ix);
never executed (the execution status of this line is deduced): quint32 basex = int(0.5 * ix);
-
2069 quint32 srcy = int(0.5 * iy);
never executed (the execution status of this line is deduced): quint32 srcy = int(0.5 * iy);
-
2070 -
2071 // scale, swizzle and mirror in one loop -
2072 while (target_height--) {
never evaluated: target_height--
0
2073 const uint *src = (const quint32 *) (srcPixels - (srcy >> 16) * sbpl);
never executed (the execution status of this line is deduced): const uint *src = (const quint32 *) (srcPixels - (srcy >> 16) * sbpl);
-
2074 int srcx = basex;
never executed (the execution status of this line is deduced): int srcx = basex;
-
2075 for (int x=0; x<target_width; ++x) {
never evaluated: x<target_width
0
2076 dest[x] = qt_gl_convertToGLFormatHelper(src[srcx >> 16], texture_format);
never executed (the execution status of this line is deduced): dest[x] = qt_gl_convertToGLFormatHelper(src[srcx >> 16], texture_format);
-
2077 srcx += ix;
never executed (the execution status of this line is deduced): srcx += ix;
-
2078 }
never executed: }
0
2079 dest = (quint32 *)(((uchar *) dest) + dbpl);
never executed (the execution status of this line is deduced): dest = (quint32 *)(((uchar *) dest) + dbpl);
-
2080 srcy += iy;
never executed (the execution status of this line is deduced): srcy += iy;
-
2081 }
never executed: }
0
2082 } else {
never executed: }
0
2083 const int width = img.width();
never executed (the execution status of this line is deduced): const int width = img.width();
-
2084 const int height = img.height();
never executed (the execution status of this line is deduced): const int height = img.height();
-
2085 const uint *p = (const uint*) img.scanLine(img.height() - 1);
never executed (the execution status of this line is deduced): const uint *p = (const uint*) img.scanLine(img.height() - 1);
-
2086 uint *q = (uint*) dst.scanLine(0);
never executed (the execution status of this line is deduced): uint *q = (uint*) dst.scanLine(0);
-
2087 -
2088 if (texture_format == GL_BGRA) {
never evaluated: texture_format == 0x80E1
0
2089 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
never evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
0
2090 // mirror + swizzle -
2091 for (int i=0; i < height; ++i) {
never evaluated: i < height
0
2092 const uint *end = p + width;
never executed (the execution status of this line is deduced): const uint *end = p + width;
-
2093 while (p < end) {
never evaluated: p < end
0
2094 *q = ((*p << 24) & 0xff000000)
never executed (the execution status of this line is deduced): *q = ((*p << 24) & 0xff000000)
-
2095 | ((*p >> 24) & 0x000000ff)
never executed (the execution status of this line is deduced): | ((*p >> 24) & 0x000000ff)
-
2096 | ((*p << 8) & 0x00ff0000)
never executed (the execution status of this line is deduced): | ((*p << 8) & 0x00ff0000)
-
2097 | ((*p >> 8) & 0x0000ff00);
never executed (the execution status of this line is deduced): | ((*p >> 8) & 0x0000ff00);
-
2098 p++;
never executed (the execution status of this line is deduced): p++;
-
2099 q++;
never executed (the execution status of this line is deduced): q++;
-
2100 }
never executed: }
0
2101 p -= 2 * width;
never executed (the execution status of this line is deduced): p -= 2 * width;
-
2102 }
never executed: }
0
2103 } else {
never executed: }
0
2104 const uint bytesPerLine = img.bytesPerLine();
never executed (the execution status of this line is deduced): const uint bytesPerLine = img.bytesPerLine();
-
2105 for (int i=0; i < height; ++i) {
never evaluated: i < height
0
2106 memcpy(q, p, bytesPerLine);
never executed (the execution status of this line is deduced): memcpy(q, p, bytesPerLine);
-
2107 q += width;
never executed (the execution status of this line is deduced): q += width;
-
2108 p -= width;
never executed (the execution status of this line is deduced): p -= width;
-
2109 }
never executed: }
0
2110 }
never executed: }
0
2111 } else { -
2112 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
never evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
0
2113 for (int i=0; i < height; ++i) {
never evaluated: i < height
0
2114 const uint *end = p + width;
never executed (the execution status of this line is deduced): const uint *end = p + width;
-
2115 while (p < end) {
never evaluated: p < end
0
2116 *q = (*p << 8) | ((*p >> 24) & 0xff);
never executed (the execution status of this line is deduced): *q = (*p << 8) | ((*p >> 24) & 0xff);
-
2117 p++;
never executed (the execution status of this line is deduced): p++;
-
2118 q++;
never executed (the execution status of this line is deduced): q++;
-
2119 }
never executed: }
0
2120 p -= 2 * width;
never executed (the execution status of this line is deduced): p -= 2 * width;
-
2121 }
never executed: }
0
2122 } else {
never executed: }
0
2123 for (int i=0; i < height; ++i) {
never evaluated: i < height
0
2124 const uint *end = p + width;
never executed (the execution status of this line is deduced): const uint *end = p + width;
-
2125 while (p < end) {
never evaluated: p < end
0
2126 *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00);
never executed (the execution status of this line is deduced): *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00);
-
2127 p++;
never executed (the execution status of this line is deduced): p++;
-
2128 q++;
never executed (the execution status of this line is deduced): q++;
-
2129 }
never executed: }
0
2130 p -= 2 * width;
never executed (the execution status of this line is deduced): p -= 2 * width;
-
2131 }
never executed: }
0
2132 }
never executed: }
0
2133 } -
2134 } -
2135} -
2136 -
2137QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) -
2138{ -
2139 return qt_extensionFuncs;
never executed: return qt_extensionFuncs;
0
2140} -
2141 -
2142QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_premul, -
2143 GLenum texture_format) -
2144{ -
2145 QImage::Format target_format = image.format();
never executed (the execution status of this line is deduced): QImage::Format target_format = image.format();
-
2146 if (force_premul || image.format() != QImage::Format_ARGB32)
never evaluated: force_premul
never evaluated: image.format() != QImage::Format_ARGB32
0
2147 target_format = QImage::Format_ARGB32_Premultiplied;
never executed: target_format = QImage::Format_ARGB32_Premultiplied;
0
2148 -
2149 QImage result(image.width(), image.height(), target_format);
never executed (the execution status of this line is deduced): QImage result(image.width(), image.height(), target_format);
-
2150 convertToGLFormatHelper(result, image.convertToFormat(target_format), texture_format);
never executed (the execution status of this line is deduced): convertToGLFormatHelper(result, image.convertToFormat(target_format), texture_format);
-
2151 return result;
never executed: return result;
0
2152} -
2153 -
2154/*! \internal */ -
2155QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, -
2156 QGLContext::BindOptions options) -
2157{ -
2158 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
2159 -
2160 const qint64 key = image.cacheKey();
never executed (the execution status of this line is deduced): const qint64 key = image.cacheKey();
-
2161 QGLTexture *texture = textureCacheLookup(key, target);
never executed (the execution status of this line is deduced): QGLTexture *texture = textureCacheLookup(key, target);
-
2162 if (texture) {
never evaluated: texture
0
2163 if (image.paintingActive()) {
never evaluated: image.paintingActive()
0
2164 // A QPainter is active on the image - take the safe route and replace the texture. -
2165 q->deleteTexture(texture->id);
never executed (the execution status of this line is deduced): q->deleteTexture(texture->id);
-
2166 texture = 0;
never executed (the execution status of this line is deduced): texture = 0;
-
2167 } else {
never executed: }
0
2168 glBindTexture(target, texture->id);
never executed (the execution status of this line is deduced): glBindTexture(target, texture->id);
-
2169 return texture;
never executed: return texture;
0
2170 } -
2171 } -
2172 -
2173 if (!texture)
never evaluated: !texture
0
2174 texture = bindTexture(image, target, format, key, options);
never executed: texture = bindTexture(image, target, format, key, options);
0
2175 // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null -
2176 Q_ASSERT(texture);
never executed (the execution status of this line is deduced): qt_noop();
-
2177 -
2178 // Enable the cleanup hooks for this image so that the texture cache entry is removed when the -
2179 // image gets deleted: -
2180 QImagePixmapCleanupHooks::enableCleanupHooks(image);
never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::enableCleanupHooks(image);
-
2181 -
2182 return texture;
never executed: return texture;
0
2183} -
2184 -
2185// #define QGL_BIND_TEXTURE_DEBUG -
2186 -
2187// ####TODO Properly #ifdef this file to use #define symbols actually defined -
2188// by OpenGL/ES includes -
2189#ifndef GL_UNSIGNED_INT_8_8_8_8_REV -
2190#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -
2191#endif -
2192 -
2193// map from Qt's ARGB endianness-dependent format to GL's big-endian RGBA layout -
2194static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) -
2195{ -
2196 const int width = img.width();
never executed (the execution status of this line is deduced): const int width = img.width();
-
2197 const int height = img.height();
never executed (the execution status of this line is deduced): const int height = img.height();
-
2198 -
2199 if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
never evaluated: pixel_type == 0x8367
0
2200 || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
never evaluated: pixel_type == 0x1401
never evaluated: QSysInfo::ByteOrder == QSysInfo::LittleEndian
0
2201 { -
2202 for (int i = 0; i < height; ++i) {
never evaluated: i < height
0
2203 uint *p = (uint *) img.scanLine(i);
never executed (the execution status of this line is deduced): uint *p = (uint *) img.scanLine(i);
-
2204 for (int x = 0; x < width; ++x)
never evaluated: x < width
0
2205 p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
never executed: p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
0
2206 }
never executed: }
0
2207 } else {
never executed: }
0
2208 for (int i = 0; i < height; ++i) {
never evaluated: i < height
0
2209 uint *p = (uint *) img.scanLine(i);
never executed (the execution status of this line is deduced): uint *p = (uint *) img.scanLine(i);
-
2210 for (int x = 0; x < width; ++x)
never evaluated: x < width
0
2211 p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
never executed: p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
0
2212 }
never executed: }
0
2213 }
never executed: }
0
2214} -
2215 -
2216QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint internalFormat, -
2217 const qint64 key, QGLContext::BindOptions options) -
2218{ -
2219 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
2220 -
2221#ifdef QGL_BIND_TEXTURE_DEBUG -
2222 printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), internalFormat =0x%x, options=%x, key=%llx\n", -
2223 image.width(), image.height(), internalFormat, int(options), key); -
2224 QTime time; -
2225 time.start(); -
2226#endif -
2227 -
2228#ifndef QT_NO_DEBUG -
2229 // Reset the gl error stack...git -
2230 while (glGetError() != GL_NO_ERROR) ; -
2231#endif -
2232 -
2233 // Scale the pixmap if needed. GL textures needs to have the -
2234 // dimensions 2^n+2(border) x 2^m+2(border), unless we're using GL -
2235 // 2.0 or use the GL_TEXTURE_RECTANGLE texture target -
2236 int tx_w = qt_next_power_of_two(image.width());
never executed (the execution status of this line is deduced): int tx_w = qt_next_power_of_two(image.width());
-
2237 int tx_h = qt_next_power_of_two(image.height());
never executed (the execution status of this line is deduced): int tx_h = qt_next_power_of_two(image.height());
-
2238 -
2239 QImage img = image;
never executed (the execution status of this line is deduced): QImage img = image;
-
2240 -
2241 if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures)
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures)
0
2242 && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)
never evaluated: !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)
0
2243 && (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height())))
never evaluated: target == 0x0DE1
never evaluated: tx_w != image.width()
never evaluated: tx_h != image.height()
0
2244 { -
2245 img = img.scaled(tx_w, tx_h);
never executed (the execution status of this line is deduced): img = img.scaled(tx_w, tx_h);
-
2246#ifdef QGL_BIND_TEXTURE_DEBUG -
2247 printf(" - upscaled to %dx%d (%d ms)\n", tx_w, tx_h, time.elapsed()); -
2248 -
2249#endif -
2250 }
never executed: }
0
2251 -
2252 GLuint filtering = options & QGLContext::LinearFilteringBindOption ? GL_LINEAR : GL_NEAREST;
never evaluated: options & QGLContext::LinearFilteringBindOption
0
2253 -
2254 GLuint tx_id;
never executed (the execution status of this line is deduced): GLuint tx_id;
-
2255 glGenTextures(1, &tx_id);
never executed (the execution status of this line is deduced): glGenTextures(1, &tx_id);
-
2256 glBindTexture(target, tx_id);
never executed (the execution status of this line is deduced): glBindTexture(target, tx_id);
-
2257 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filtering);
never executed (the execution status of this line is deduced): glTexParameteri(target, 0x2800, filtering);
-
2258 -
2259#if defined(QT_OPENGL_ES_2) -
2260 bool genMipmap = false; -
2261#endif -
2262 if (glFormat.directRendering()
never evaluated: glFormat.directRendering()
0
2263 && (QGLExtensions::glExtensions() & QGLExtensions::GenerateMipmap)
never evaluated: (QGLExtensions::glExtensions() & QGLExtensions::GenerateMipmap)
0
2264 && target == GL_TEXTURE_2D
never evaluated: target == 0x0DE1
0
2265 && (options & QGLContext::MipmapBindOption))
never evaluated: (options & QGLContext::MipmapBindOption)
0
2266 { -
2267#if !defined(QT_OPENGL_ES_2) -
2268 glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
never executed (the execution status of this line is deduced): glHint(0x8192, 0x1102);
-
2269 glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
never executed (the execution status of this line is deduced): glTexParameteri(target, 0x8191, 0x1);
-
2270#else -
2271 glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); -
2272 genMipmap = true; -
2273#endif -
2274 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, options & QGLContext::LinearFilteringBindOption
never executed (the execution status of this line is deduced): glTexParameteri(target, 0x2801, options & QGLContext::LinearFilteringBindOption
-
2275 ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST);
never executed (the execution status of this line is deduced): ? 0x2703 : 0x2700);
-
2276#ifdef QGL_BIND_TEXTURE_DEBUG -
2277 printf(" - generating mipmaps (%d ms)\n", time.elapsed()); -
2278#endif -
2279 } else {
never executed: }
0
2280 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filtering);
never executed (the execution status of this line is deduced): glTexParameteri(target, 0x2801, filtering);
-
2281 }
never executed: }
0
2282 -
2283 QImage::Format target_format = img.format();
never executed (the execution status of this line is deduced): QImage::Format target_format = img.format();
-
2284 bool premul = options & QGLContext::PremultipliedAlphaBindOption;
never executed (the execution status of this line is deduced): bool premul = options & QGLContext::PremultipliedAlphaBindOption;
-
2285 GLenum externalFormat;
never executed (the execution status of this line is deduced): GLenum externalFormat;
-
2286 GLuint pixel_type;
never executed (the execution status of this line is deduced): GLuint pixel_type;
-
2287 if (QGLExtensions::glExtensions() & QGLExtensions::BGRATextureFormat) {
never evaluated: QGLExtensions::glExtensions() & QGLExtensions::BGRATextureFormat
0
2288 externalFormat = GL_BGRA;
never executed (the execution status of this line is deduced): externalFormat = 0x80E1;
-
2289 if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2)
never evaluated: QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2
0
2290 pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV;
never executed: pixel_type = 0x8367;
0
2291 else -
2292 pixel_type = GL_UNSIGNED_BYTE;
never executed: pixel_type = 0x1401;
0
2293 } else { -
2294 externalFormat = GL_RGBA;
never executed (the execution status of this line is deduced): externalFormat = 0x1908;
-
2295 pixel_type = GL_UNSIGNED_BYTE;
never executed (the execution status of this line is deduced): pixel_type = 0x1401;
-
2296 }
never executed: }
0
2297 -
2298 switch (target_format) { -
2299 case QImage::Format_ARGB32: -
2300 if (premul) {
never evaluated: premul
0
2301 img = img.convertToFormat(target_format = QImage::Format_ARGB32_Premultiplied);
never executed (the execution status of this line is deduced): img = img.convertToFormat(target_format = QImage::Format_ARGB32_Premultiplied);
-
2302#ifdef QGL_BIND_TEXTURE_DEBUG -
2303 printf(" - converted ARGB32 -> ARGB32_Premultiplied (%d ms) \n", time.elapsed()); -
2304#endif -
2305 }
never executed: }
0
2306 break;
never executed: break;
0
2307 case QImage::Format_ARGB32_Premultiplied: -
2308 if (!premul) {
never evaluated: !premul
0
2309 img = img.convertToFormat(target_format = QImage::Format_ARGB32);
never executed (the execution status of this line is deduced): img = img.convertToFormat(target_format = QImage::Format_ARGB32);
-
2310#ifdef QGL_BIND_TEXTURE_DEBUG -
2311 printf(" - converted ARGB32_Premultiplied -> ARGB32 (%d ms)\n", time.elapsed()); -
2312#endif -
2313 }
never executed: }
0
2314 break;
never executed: break;
0
2315 case QImage::Format_RGB16: -
2316 pixel_type = GL_UNSIGNED_SHORT_5_6_5;
never executed (the execution status of this line is deduced): pixel_type = 0x8363;
-
2317 externalFormat = GL_RGB;
never executed (the execution status of this line is deduced): externalFormat = 0x1907;
-
2318 internalFormat = GL_RGB;
never executed (the execution status of this line is deduced): internalFormat = 0x1907;
-
2319 break;
never executed: break;
0
2320 case QImage::Format_RGB32: -
2321 break;
never executed: break;
0
2322 default: -
2323 if (img.hasAlphaChannel()) {
never evaluated: img.hasAlphaChannel()
0
2324 img = img.convertToFormat(premul
never executed (the execution status of this line is deduced): img = img.convertToFormat(premul
-
2325 ? QImage::Format_ARGB32_Premultiplied
never executed (the execution status of this line is deduced): ? QImage::Format_ARGB32_Premultiplied
-
2326 : QImage::Format_ARGB32);
never executed (the execution status of this line is deduced): : QImage::Format_ARGB32);
-
2327#ifdef QGL_BIND_TEXTURE_DEBUG -
2328 printf(" - converted to 32-bit alpha format (%d ms)\n", time.elapsed()); -
2329#endif -
2330 } else {
never executed: }
0
2331 img = img.convertToFormat(QImage::Format_RGB32);
never executed (the execution status of this line is deduced): img = img.convertToFormat(QImage::Format_RGB32);
-
2332#ifdef QGL_BIND_TEXTURE_DEBUG -
2333 printf(" - converted to 32-bit (%d ms)\n", time.elapsed()); -
2334#endif -
2335 }
never executed: }
0
2336 } -
2337 -
2338 if (options & QGLContext::InvertedYBindOption) {
never evaluated: options & QGLContext::InvertedYBindOption
0
2339 if (img.isDetached()) {
never evaluated: img.isDetached()
0
2340 int ipl = img.bytesPerLine() / 4;
never executed (the execution status of this line is deduced): int ipl = img.bytesPerLine() / 4;
-
2341 int h = img.height();
never executed (the execution status of this line is deduced): int h = img.height();
-
2342 for (int y=0; y<h/2; ++y) {
never evaluated: y<h/2
0
2343 int *a = (int *) img.scanLine(y);
never executed (the execution status of this line is deduced): int *a = (int *) img.scanLine(y);
-
2344 int *b = (int *) img.scanLine(h - y - 1);
never executed (the execution status of this line is deduced): int *b = (int *) img.scanLine(h - y - 1);
-
2345 for (int x=0; x<ipl; ++x)
never evaluated: x<ipl
0
2346 qSwap(a[x], b[x]);
never executed: qSwap(a[x], b[x]);
0
2347 }
never executed: }
0
2348 } else {
never executed: }
0
2349 // Create a new image and copy across. If we use the -
2350 // above in-place code then a full copy of the image is -
2351 // made before the lines are swapped, which processes the -
2352 // data twice. This version should only do it once. -
2353 img = img.mirrored();
never executed (the execution status of this line is deduced): img = img.mirrored();
-
2354 }
never executed: }
0
2355#ifdef QGL_BIND_TEXTURE_DEBUG -
2356 printf(" - flipped bits over y (%d ms)\n", time.elapsed()); -
2357#endif -
2358 } -
2359 -
2360 if (externalFormat == GL_RGBA) {
never evaluated: externalFormat == 0x1908
0
2361 // The only case where we end up with a depth different from -
2362 // 32 in the switch above is for the RGB16 case, where we set -
2363 // the format to GL_RGB -
2364 Q_ASSERT(img.depth() == 32);
never executed (the execution status of this line is deduced): qt_noop();
-
2365 qgl_byteSwapImage(img, pixel_type);
never executed (the execution status of this line is deduced): qgl_byteSwapImage(img, pixel_type);
-
2366#ifdef QGL_BIND_TEXTURE_DEBUG -
2367 printf(" - did byte swapping (%d ms)\n", time.elapsed()); -
2368#endif -
2369 }
never executed: }
0
2370#ifdef QT_OPENGL_ES -
2371 // OpenGL/ES requires that the internal and external formats be -
2372 // identical. -
2373 internalFormat = externalFormat; -
2374#endif -
2375#ifdef QGL_BIND_TEXTURE_DEBUG -
2376 printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n", -
2377 img.format(), externalFormat, internalFormat, pixel_type); -
2378#endif -
2379 -
2380 const QImage &constRef = img; // to avoid detach in bits()...
never executed (the execution status of this line is deduced): const QImage &constRef = img;
-
2381 glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
never executed (the execution status of this line is deduced): glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
-
2382 pixel_type, constRef.bits());
never executed (the execution status of this line is deduced): pixel_type, constRef.bits());
-
2383#if defined(QT_OPENGL_ES_2) -
2384 if (genMipmap) -
2385 glGenerateMipmap(target); -
2386#endif -
2387#ifndef QT_NO_DEBUG -
2388 GLenum error = glGetError(); -
2389 if (error != GL_NO_ERROR) { -
2390 qWarning(" - texture upload failed, error code 0x%x, enum: %d (%x)\n", error, target, target); -
2391 } -
2392#endif -
2393 -
2394#ifdef QGL_BIND_TEXTURE_DEBUG -
2395 static int totalUploadTime = 0; -
2396 totalUploadTime += time.elapsed(); -
2397 printf(" - upload done in %d ms, (accumulated: %d ms)\n", time.elapsed(), totalUploadTime); -
2398#endif -
2399 -
2400 -
2401 // this assumes the size of a texture is always smaller than the max cache size -
2402 int cost = img.width()*img.height()*4/1024;
never executed (the execution status of this line is deduced): int cost = img.width()*img.height()*4/1024;
-
2403 QGLTexture *texture = new QGLTexture(q, tx_id, target, options);
never executed (the execution status of this line is deduced): QGLTexture *texture = new QGLTexture(q, tx_id, target, options);
-
2404 QGLTextureCache::instance()->insert(q, key, texture, cost);
never executed (the execution status of this line is deduced): QGLTextureCache::instance()->insert(q, key, texture, cost);
-
2405 -
2406 return texture;
never executed: return texture;
0
2407} -
2408 -
2409QGLTexture *QGLContextPrivate::textureCacheLookup(const qint64 key, GLenum target) -
2410{ -
2411 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
2412 QGLTexture *texture = QGLTextureCache::instance()->getTexture(q, key);
never executed (the execution status of this line is deduced): QGLTexture *texture = QGLTextureCache::instance()->getTexture(q, key);
-
2413 if (texture && texture->target == target
never evaluated: texture
never evaluated: texture->target == target
0
2414 && (texture->context == q || QGLContext::areSharing(q, texture->context)))
never evaluated: texture->context == q
never evaluated: QGLContext::areSharing(q, texture->context)
0
2415 { -
2416 return texture;
never executed: return texture;
0
2417 } -
2418 return 0;
never executed: return 0;
0
2419} -
2420 -
2421/*! \internal */ -
2422QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options) -
2423{ -
2424 Q_Q(QGLContext);
never executed (the execution status of this line is deduced): QGLContext * const q = q_func();
-
2425 QPlatformPixmap *pd = pixmap.handle();
never executed (the execution status of this line is deduced): QPlatformPixmap *pd = pixmap.handle();
-
2426 Q_UNUSED(pd);
never executed (the execution status of this line is deduced): (void)pd;;
-
2427 -
2428 const qint64 key = pixmap.cacheKey();
never executed (the execution status of this line is deduced): const qint64 key = pixmap.cacheKey();
-
2429 QGLTexture *texture = textureCacheLookup(key, target);
never executed (the execution status of this line is deduced): QGLTexture *texture = textureCacheLookup(key, target);
-
2430 if (texture) {
never evaluated: texture
0
2431 if (pixmap.paintingActive()) {
never evaluated: pixmap.paintingActive()
0
2432 // A QPainter is active on the pixmap - take the safe route and replace the texture. -
2433 q->deleteTexture(texture->id);
never executed (the execution status of this line is deduced): q->deleteTexture(texture->id);
-
2434 texture = 0;
never executed (the execution status of this line is deduced): texture = 0;
-
2435 } else {
never executed: }
0
2436 glBindTexture(target, texture->id);
never executed (the execution status of this line is deduced): glBindTexture(target, texture->id);
-
2437 return texture;
never executed: return texture;
0
2438 } -
2439 } -
2440 -
2441 if (!texture) {
never evaluated: !texture
0
2442 QImage image = pixmap.toImage();
never executed (the execution status of this line is deduced): QImage image = pixmap.toImage();
-
2443 // If the system depth is 16 and the pixmap doesn't have an alpha channel -
2444 // then we convert it to RGB16 in the hope that it gets uploaded as a 16 -
2445 // bit texture which is much faster to access than a 32-bit one. -
2446 if (pixmap.depth() == 16 && !image.hasAlphaChannel() )
never evaluated: pixmap.depth() == 16
never evaluated: !image.hasAlphaChannel()
0
2447 image = image.convertToFormat(QImage::Format_RGB16);
never executed: image = image.convertToFormat(QImage::Format_RGB16);
0
2448 texture = bindTexture(image, target, format, key, options);
never executed (the execution status of this line is deduced): texture = bindTexture(image, target, format, key, options);
-
2449 }
never executed: }
0
2450 // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null -
2451 Q_ASSERT(texture);
never executed (the execution status of this line is deduced): qt_noop();
-
2452 -
2453 if (texture->id > 0)
never evaluated: texture->id > 0
0
2454 QImagePixmapCleanupHooks::enableCleanupHooks(pixmap);
never executed: QImagePixmapCleanupHooks::enableCleanupHooks(pixmap);
0
2455 -
2456 return texture;
never executed: return texture;
0
2457} -
2458 -
2459/*! \internal */ -
2460int QGLContextPrivate::maxTextureSize() -
2461{ -
2462 if (max_texture_size != -1)
never evaluated: max_texture_size != -1
0
2463 return max_texture_size;
never executed: return max_texture_size;
0
2464 -
2465 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
never executed (the execution status of this line is deduced): glGetIntegerv(0x0D33, &max_texture_size);
-
2466 -
2467#if defined(QT_OPENGL_ES) -
2468 return max_texture_size; -
2469#else -
2470 GLenum proxy = GL_PROXY_TEXTURE_2D;
never executed (the execution status of this line is deduced): GLenum proxy = 0x8064;
-
2471 -
2472 GLint size;
never executed (the execution status of this line is deduced): GLint size;
-
2473 GLint next = 64;
never executed (the execution status of this line is deduced): GLint next = 64;
-
2474 glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
never executed (the execution status of this line is deduced): glTexImage2D(proxy, 0, 0x1908, next, next, 0, 0x1908, 0x1401, 0);
-
2475 glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &size);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(proxy, 0, 0x1000, &size);
-
2476 if (size == 0) {
never evaluated: size == 0
0
2477 return max_texture_size;
never executed: return max_texture_size;
0
2478 } -
2479 do { -
2480 size = next;
never executed (the execution status of this line is deduced): size = next;
-
2481 next = size * 2;
never executed (the execution status of this line is deduced): next = size * 2;
-
2482 -
2483 if (next > max_texture_size)
never evaluated: next > max_texture_size
0
2484 break;
never executed: break;
0
2485 glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
never executed (the execution status of this line is deduced): glTexImage2D(proxy, 0, 0x1908, next, next, 0, 0x1908, 0x1401, 0);
-
2486 glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(proxy, 0, 0x1000, &next);
-
2487 } while (next > size);
never executed: }
never evaluated: next > size
0
2488 -
2489 max_texture_size = size;
never executed (the execution status of this line is deduced): max_texture_size = size;
-
2490 return max_texture_size;
never executed: return max_texture_size;
0
2491#endif -
2492} -
2493 -
2494/*! -
2495 Returns a QGLFunctions object that is initialized for this context. -
2496 */ -
2497QGLFunctions *QGLContext::functions() const -
2498{ -
2499 QGLContextPrivate *d = const_cast<QGLContextPrivate *>(d_func());
never executed (the execution status of this line is deduced): QGLContextPrivate *d = const_cast<QGLContextPrivate *>(d_func());
-
2500 if (!d->functions) {
never evaluated: !d->functions
0
2501 d->functions = new QGLFunctions(this);
never executed (the execution status of this line is deduced): d->functions = new QGLFunctions(this);
-
2502 d->functions->initializeGLFunctions(this);
never executed (the execution status of this line is deduced): d->functions->initializeGLFunctions(this);
-
2503 }
never executed: }
0
2504 return d->functions;
never executed: return d->functions;
0
2505} -
2506 -
2507/*! -
2508 Generates and binds a 2D GL texture to the current context, based -
2509 on \a image. The generated texture id is returned and can be used in -
2510 later \c glBindTexture() calls. -
2511 -
2512 \overload -
2513*/ -
2514GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) -
2515{ -
2516 if (image.isNull())
never evaluated: image.isNull()
0
2517 return 0;
never executed: return 0;
0
2518 -
2519 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2520 QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption);
never executed (the execution status of this line is deduced): QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption);
-
2521 return texture->id;
never executed: return texture->id;
0
2522} -
2523 -
2524/*! -
2525 \since 4.6 -
2526 -
2527 Generates and binds a 2D GL texture to the current context, based -
2528 on \a image. The generated texture id is returned and can be used -
2529 in later \c glBindTexture() calls. -
2530 -
2531 The \a target parameter specifies the texture target. The default -
2532 target is \c GL_TEXTURE_2D. -
2533 -
2534 The \a format parameter sets the internal format for the -
2535 texture. The default format is \c GL_RGBA. -
2536 -
2537 The binding \a options are a set of options used to decide how to -
2538 bind the texture to the context. -
2539 -
2540 The texture that is generated is cached, so multiple calls to -
2541 bindTexture() with the same QImage will return the same texture -
2542 id. -
2543 -
2544 Note that we assume default values for the glPixelStore() and -
2545 glPixelTransfer() parameters. -
2546 -
2547 \sa deleteTexture() -
2548*/ -
2549GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, BindOptions options) -
2550{ -
2551 if (image.isNull())
never evaluated: image.isNull()
0
2552 return 0;
never executed: return 0;
0
2553 -
2554 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2555 QGLTexture *texture = d->bindTexture(image, target, format, options);
never executed (the execution status of this line is deduced): QGLTexture *texture = d->bindTexture(image, target, format, options);
-
2556 return texture->id;
never executed: return texture->id;
0
2557} -
2558 -
2559/*! \overload -
2560 -
2561 Generates and binds a 2D GL texture based on \a pixmap. -
2562*/ -
2563GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) -
2564{ -
2565 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
2566 return 0;
never executed: return 0;
0
2567 -
2568 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2569 QGLTexture *texture = d->bindTexture(pixmap, target, format, DefaultBindOption);
never executed (the execution status of this line is deduced): QGLTexture *texture = d->bindTexture(pixmap, target, format, DefaultBindOption);
-
2570 return texture->id;
never executed: return texture->id;
0
2571} -
2572 -
2573/*! -
2574 \overload -
2575 \since 4.6 -
2576 -
2577 Generates and binds a 2D GL texture to the current context, based -
2578 on \a pixmap. -
2579*/ -
2580GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, BindOptions options) -
2581{ -
2582 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
2583 return 0;
never executed: return 0;
0
2584 -
2585 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2586 QGLTexture *texture = d->bindTexture(pixmap, target, format, options);
never executed (the execution status of this line is deduced): QGLTexture *texture = d->bindTexture(pixmap, target, format, options);
-
2587 return texture->id;
never executed: return texture->id;
0
2588} -
2589 -
2590/*! -
2591 Removes the texture identified by \a id from the texture cache, -
2592 and calls glDeleteTextures() to delete the texture from the -
2593 context. -
2594 -
2595 \sa bindTexture() -
2596*/ -
2597void QGLContext::deleteTexture(GLuint id) -
2598{ -
2599 if (QGLTextureCache::instance()->remove(this, id))
never evaluated: QGLTextureCache::instance()->remove(this, id)
0
2600 return;
never executed: return;
0
2601 glDeleteTextures(1, &id);
never executed (the execution status of this line is deduced): glDeleteTextures(1, &id);
-
2602}
never executed: }
0
2603 -
2604void qt_add_rect_to_array(const QRectF &r, GLfloat *array) -
2605{ -
2606 qreal left = r.left();
never executed (the execution status of this line is deduced): qreal left = r.left();
-
2607 qreal right = r.right();
never executed (the execution status of this line is deduced): qreal right = r.right();
-
2608 qreal top = r.top();
never executed (the execution status of this line is deduced): qreal top = r.top();
-
2609 qreal bottom = r.bottom();
never executed (the execution status of this line is deduced): qreal bottom = r.bottom();
-
2610 -
2611 array[0] = left;
never executed (the execution status of this line is deduced): array[0] = left;
-
2612 array[1] = top;
never executed (the execution status of this line is deduced): array[1] = top;
-
2613 array[2] = right;
never executed (the execution status of this line is deduced): array[2] = right;
-
2614 array[3] = top;
never executed (the execution status of this line is deduced): array[3] = top;
-
2615 array[4] = right;
never executed (the execution status of this line is deduced): array[4] = right;
-
2616 array[5] = bottom;
never executed (the execution status of this line is deduced): array[5] = bottom;
-
2617 array[6] = left;
never executed (the execution status of this line is deduced): array[6] = left;
-
2618 array[7] = bottom;
never executed (the execution status of this line is deduced): array[7] = bottom;
-
2619}
never executed: }
0
2620 -
2621void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array) -
2622{ -
2623 array[0] = x1;
never executed (the execution status of this line is deduced): array[0] = x1;
-
2624 array[1] = y1;
never executed (the execution status of this line is deduced): array[1] = y1;
-
2625 array[2] = x2;
never executed (the execution status of this line is deduced): array[2] = x2;
-
2626 array[3] = y1;
never executed (the execution status of this line is deduced): array[3] = y1;
-
2627 array[4] = x2;
never executed (the execution status of this line is deduced): array[4] = x2;
-
2628 array[5] = y2;
never executed (the execution status of this line is deduced): array[5] = y2;
-
2629 array[6] = x1;
never executed (the execution status of this line is deduced): array[6] = x1;
-
2630 array[7] = y2;
never executed (the execution status of this line is deduced): array[7] = y2;
-
2631}
never executed: }
0
2632 -
2633#if !defined(QT_OPENGL_ES_2) -
2634 -
2635static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint textureHeight, GLenum textureTarget) -
2636{ -
2637 GLfloat tx = 1.0f;
never executed (the execution status of this line is deduced): GLfloat tx = 1.0f;
-
2638 GLfloat ty = 1.0f;
never executed (the execution status of this line is deduced): GLfloat ty = 1.0f;
-
2639 -
2640#ifdef QT_OPENGL_ES -
2641 Q_UNUSED(textureWidth); -
2642 Q_UNUSED(textureHeight); -
2643 Q_UNUSED(textureTarget); -
2644#else -
2645 if (textureTarget != GL_TEXTURE_2D) {
never evaluated: textureTarget != 0x0DE1
0
2646 if (textureWidth == -1 || textureHeight == -1) {
never evaluated: textureWidth == -1
never evaluated: textureHeight == -1
0
2647 glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(textureTarget, 0, 0x1000, &textureWidth);
-
2648 glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(textureTarget, 0, 0x1001, &textureHeight);
-
2649 }
never executed: }
0
2650 -
2651 tx = GLfloat(textureWidth);
never executed (the execution status of this line is deduced): tx = GLfloat(textureWidth);
-
2652 ty = GLfloat(textureHeight);
never executed (the execution status of this line is deduced): ty = GLfloat(textureHeight);
-
2653 }
never executed: }
0
2654#endif -
2655 -
2656 GLfloat texCoordArray[4*2] = {
never executed (the execution status of this line is deduced): GLfloat texCoordArray[4*2] = {
-
2657 0, ty, tx, ty, tx, 0, 0, 0
never executed (the execution status of this line is deduced): 0, ty, tx, ty, tx, 0, 0, 0
-
2658 };
never executed (the execution status of this line is deduced): };
-
2659 -
2660 GLfloat vertexArray[4*2];
never executed (the execution status of this line is deduced): GLfloat vertexArray[4*2];
-
2661 qt_add_rect_to_array(target, vertexArray);
never executed (the execution status of this line is deduced): qt_add_rect_to_array(target, vertexArray);
-
2662 -
2663 glVertexPointer(2, GL_FLOAT, 0, vertexArray);
never executed (the execution status of this line is deduced): glVertexPointer(2, 0x1406, 0, vertexArray);
-
2664 glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
never executed (the execution status of this line is deduced): glTexCoordPointer(2, 0x1406, 0, texCoordArray);
-
2665 -
2666 glEnableClientState(GL_VERTEX_ARRAY);
never executed (the execution status of this line is deduced): glEnableClientState(0x8074);
-
2667 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
never executed (the execution status of this line is deduced): glEnableClientState(0x8078);
-
2668 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
never executed (the execution status of this line is deduced): glDrawArrays(0x0006, 0, 4);
-
2669 -
2670 glDisableClientState(GL_VERTEX_ARRAY);
never executed (the execution status of this line is deduced): glDisableClientState(0x8074);
-
2671 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
never executed (the execution status of this line is deduced): glDisableClientState(0x8078);
-
2672}
never executed: }
0
2673 -
2674#endif // !QT_OPENGL_ES_2 -
2675 -
2676/*! -
2677 \since 4.4 -
2678 -
2679 This function supports the following use cases: -
2680 -
2681 \list -
2682 \li On OpenGL and OpenGL ES 1.x it draws the given texture, \a textureId, -
2683 to the given target rectangle, \a target, in OpenGL model space. The -
2684 \a textureTarget should be a 2D texture target. -
2685 \li On OpenGL and OpenGL ES 2.x, if a painter is active, not inside a -
2686 beginNativePainting / endNativePainting block, and uses the -
2687 engine with type QPaintEngine::OpenGL2, the function will draw the given -
2688 texture, \a textureId, to the given target rectangle, \a target, -
2689 respecting the current painter state. This will let you draw a texture -
2690 with the clip, transform, render hints, and composition mode set by the -
2691 painter. Note that the texture target needs to be GL_TEXTURE_2D for this -
2692 use case, and that this is the only supported use case under OpenGL ES 2.x. -
2693 \endlist -
2694 -
2695*/ -
2696void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -
2697{ -
2698#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) -
2699 if (d_ptr->active_engine &&
never evaluated: d_ptr->active_engine
0
2700 d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
never evaluated: d_ptr->active_engine->type() == QPaintEngine::OpenGL2
0
2701 QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
never executed (the execution status of this line is deduced): QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
-
2702 if (!eng->isNativePaintingActive()) {
never evaluated: !eng->isNativePaintingActive()
0
2703 QRectF src(0, 0, target.width(), target.height());
never executed (the execution status of this line is deduced): QRectF src(0, 0, target.width(), target.height());
-
2704 QSize size(target.width(), target.height());
never executed (the execution status of this line is deduced): QSize size(target.width(), target.height());
-
2705 if (eng->drawTexture(target, textureId, size, src))
never evaluated: eng->drawTexture(target, textureId, size, src)
0
2706 return;
never executed: return;
0
2707 }
never executed: }
0
2708 }
never executed: }
0
2709#endif -
2710 -
2711#ifndef QT_OPENGL_ES_2 -
2712#ifdef QT_OPENGL_ES -
2713 if (textureTarget != GL_TEXTURE_2D) { -
2714 qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES"); -
2715 return; -
2716 } -
2717#else -
2718 const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
never executed (the execution status of this line is deduced): const bool wasEnabled = glIsEnabled(0x0DE1);
-
2719 GLint oldTexture;
never executed (the execution status of this line is deduced): GLint oldTexture;
-
2720 glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
never executed (the execution status of this line is deduced): glGetIntegerv(0x8069, &oldTexture);
-
2721#endif -
2722 -
2723 glEnable(textureTarget);
never executed (the execution status of this line is deduced): glEnable(textureTarget);
-
2724 glBindTexture(textureTarget, textureId);
never executed (the execution status of this line is deduced): glBindTexture(textureTarget, textureId);
-
2725 -
2726 qDrawTextureRect(target, -1, -1, textureTarget);
never executed (the execution status of this line is deduced): qDrawTextureRect(target, -1, -1, textureTarget);
-
2727 -
2728#ifdef QT_OPENGL_ES -
2729 glDisable(textureTarget); -
2730#else -
2731 if (!wasEnabled)
never evaluated: !wasEnabled
0
2732 glDisable(textureTarget);
never executed: glDisable(textureTarget);
0
2733 glBindTexture(textureTarget, oldTexture);
never executed (the execution status of this line is deduced): glBindTexture(textureTarget, oldTexture);
-
2734#endif -
2735#else -
2736 Q_UNUSED(target); -
2737 Q_UNUSED(textureId); -
2738 Q_UNUSED(textureTarget); -
2739 qWarning("drawTexture() with OpenGL ES 2.0 requires an active OpenGL2 paint engine"); -
2740#endif -
2741}
never executed: }
0
2742 -
2743/*! -
2744 \since 4.4 -
2745 -
2746 This function supports the following use cases: -
2747 -
2748 \list -
2749 \li By default it draws the given texture, \a textureId, -
2750 at the given \a point in OpenGL model space. The -
2751 \a textureTarget should be a 2D texture target. -
2752 \li If a painter is active, not inside a -
2753 beginNativePainting / endNativePainting block, and uses the -
2754 engine with type QPaintEngine::OpenGL2, the function will draw the given -
2755 texture, \a textureId, at the given \a point, -
2756 respecting the current painter state. This will let you draw a texture -
2757 with the clip, transform, render hints, and composition mode set by the -
2758 painter. Note that the texture target needs to be GL_TEXTURE_2D for this -
2759 use case. -
2760 \endlist -
2761 -
2762 \note This function is not supported under any version of OpenGL ES. -
2763*/ -
2764void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -
2765{ -
2766#ifdef QT_OPENGL_ES -
2767 Q_UNUSED(point); -
2768 Q_UNUSED(textureId); -
2769 Q_UNUSED(textureTarget); -
2770 qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead"); -
2771#else -
2772 -
2773 const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
never executed (the execution status of this line is deduced): const bool wasEnabled = glIsEnabled(0x0DE1);
-
2774 GLint oldTexture;
never executed (the execution status of this line is deduced): GLint oldTexture;
-
2775 glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
never executed (the execution status of this line is deduced): glGetIntegerv(0x8069, &oldTexture);
-
2776 -
2777 glEnable(textureTarget);
never executed (the execution status of this line is deduced): glEnable(textureTarget);
-
2778 glBindTexture(textureTarget, textureId);
never executed (the execution status of this line is deduced): glBindTexture(textureTarget, textureId);
-
2779 -
2780 GLint textureWidth;
never executed (the execution status of this line is deduced): GLint textureWidth;
-
2781 GLint textureHeight;
never executed (the execution status of this line is deduced): GLint textureHeight;
-
2782 -
2783 glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(textureTarget, 0, 0x1000, &textureWidth);
-
2784 glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
never executed (the execution status of this line is deduced): glGetTexLevelParameteriv(textureTarget, 0, 0x1001, &textureHeight);
-
2785 -
2786 if (d_ptr->active_engine &&
never evaluated: d_ptr->active_engine
0
2787 d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
never evaluated: d_ptr->active_engine->type() == QPaintEngine::OpenGL2
0
2788 QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
never executed (the execution status of this line is deduced): QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
-
2789 if (!eng->isNativePaintingActive()) {
never evaluated: !eng->isNativePaintingActive()
0
2790 QRectF dest(point, QSizeF(textureWidth, textureHeight));
never executed (the execution status of this line is deduced): QRectF dest(point, QSizeF(textureWidth, textureHeight));
-
2791 QRectF src(0, 0, textureWidth, textureHeight);
never executed (the execution status of this line is deduced): QRectF src(0, 0, textureWidth, textureHeight);
-
2792 QSize size(textureWidth, textureHeight);
never executed (the execution status of this line is deduced): QSize size(textureWidth, textureHeight);
-
2793 if (eng->drawTexture(dest, textureId, size, src))
never evaluated: eng->drawTexture(dest, textureId, size, src)
0
2794 return;
never executed: return;
0
2795 }
never executed: }
0
2796 }
never executed: }
0
2797 -
2798 qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget);
never executed (the execution status of this line is deduced): qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget);
-
2799 -
2800 if (!wasEnabled)
never evaluated: !wasEnabled
0
2801 glDisable(textureTarget);
never executed: glDisable(textureTarget);
0
2802 glBindTexture(textureTarget, oldTexture);
never executed (the execution status of this line is deduced): glBindTexture(textureTarget, oldTexture);
-
2803#endif -
2804}
never executed: }
0
2805 -
2806/*! -
2807 This function sets the limit for the texture cache to \a size, -
2808 expressed in kilobytes. -
2809 -
2810 By default, the cache limit is approximately 64 MB. -
2811 -
2812 \sa textureCacheLimit() -
2813*/ -
2814void QGLContext::setTextureCacheLimit(int size) -
2815{ -
2816 QGLTextureCache::instance()->setMaxCost(size);
never executed (the execution status of this line is deduced): QGLTextureCache::instance()->setMaxCost(size);
-
2817}
never executed: }
0
2818 -
2819/*! -
2820 Returns the current texture cache limit in kilobytes. -
2821 -
2822 \sa setTextureCacheLimit() -
2823*/ -
2824int QGLContext::textureCacheLimit() -
2825{ -
2826 return QGLTextureCache::instance()->maxCost();
never executed: return QGLTextureCache::instance()->maxCost();
0
2827} -
2828 -
2829 -
2830/*! -
2831 \fn QGLFormat QGLContext::format() const -
2832 -
2833 Returns the frame buffer format that was obtained (this may be a -
2834 subset of what was requested). -
2835 -
2836 \sa requestedFormat() -
2837*/ -
2838 -
2839/*! -
2840 \fn QGLFormat QGLContext::requestedFormat() const -
2841 -
2842 Returns the frame buffer format that was originally requested in -
2843 the constructor or setFormat(). -
2844 -
2845 \sa format() -
2846*/ -
2847 -
2848/*! -
2849 Sets a \a format for this context. The context is \l{reset()}{reset}. -
2850 -
2851 Call create() to create a new GL context that tries to match the -
2852 new format. -
2853 -
2854 \snippet code/src_opengl_qgl.cpp 7 -
2855 -
2856 \sa format(), reset(), create() -
2857*/ -
2858 -
2859void QGLContext::setFormat(const QGLFormat &format) -
2860{ -
2861 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2862 reset();
never executed (the execution status of this line is deduced): reset();
-
2863 d->glFormat = d->reqFormat = format;
never executed (the execution status of this line is deduced): d->glFormat = d->reqFormat = format;
-
2864}
never executed: }
0
2865 -
2866/*! -
2867 \internal -
2868*/ -
2869void QGLContext::setDevice(QPaintDevice *pDev) -
2870{ -
2871 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
2872 if (isValid())
never evaluated: isValid()
0
2873 reset();
never executed: reset();
0
2874 d->paintDevice = pDev;
never executed (the execution status of this line is deduced): d->paintDevice = pDev;
-
2875 if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget
never evaluated: d->paintDevice
never evaluated: d->paintDevice->devType() != QInternal::Widget
0
2876 && d->paintDevice->devType() != QInternal::Pixmap
never evaluated: d->paintDevice->devType() != QInternal::Pixmap
0
2877 && d->paintDevice->devType() != QInternal::Pbuffer)) {
never evaluated: d->paintDevice->devType() != QInternal::Pbuffer
0
2878 qWarning("QGLContext: Unsupported paint device type");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 2878, __PRETTY_FUNCTION__).warning("QGLContext: Unsupported paint device type");
-
2879 }
never executed: }
0
2880}
never executed: }
0
2881 -
2882/*! -
2883 \fn bool QGLContext::isValid() const -
2884 -
2885 Returns true if a GL rendering context has been successfully -
2886 created; otherwise returns false. -
2887*/ -
2888 -
2889/*! -
2890 \fn void QGLContext::setValid(bool valid) -
2891 \internal -
2892 -
2893 Forces the GL rendering context to be valid. -
2894*/ -
2895 -
2896/*! -
2897 \fn bool QGLContext::isSharing() const -
2898 -
2899 Returns true if this context is sharing its GL context with -
2900 another QGLContext, otherwise false is returned. Note that context -
2901 sharing might not be supported between contexts with different -
2902 formats. -
2903*/ -
2904 -
2905/*! -
2906 Returns true if \a context1 and \a context2 are sharing their -
2907 GL resources such as textures, shader programs, etc; -
2908 otherwise returns false. -
2909 -
2910 \since 4.6 -
2911*/ -
2912bool QGLContext::areSharing(const QGLContext *context1, const QGLContext *context2) -
2913{ -
2914 if (!context1 || !context2)
never evaluated: !context1
never evaluated: !context2
0
2915 return false;
never executed: return false;
0
2916 return context1->d_ptr->group == context2->d_ptr->group;
never executed: return context1->d_ptr->group == context2->d_ptr->group;
0
2917} -
2918 -
2919/*! -
2920 \fn bool QGLContext::deviceIsPixmap() const -
2921 -
2922 Returns true if the paint device of this context is a pixmap; -
2923 otherwise returns false. -
2924*/ -
2925 -
2926/*! -
2927 \fn bool QGLContext::windowCreated() const -
2928 -
2929 Returns true if a window has been created for this context; -
2930 otherwise returns false. -
2931 -
2932 \sa setWindowCreated() -
2933*/ -
2934 -
2935/*! -
2936 \fn void QGLContext::setWindowCreated(bool on) -
2937 -
2938 If \a on is true the context has had a window created for it. If -
2939 \a on is false no window has been created for the context. -
2940 -
2941 \sa windowCreated() -
2942*/ -
2943 -
2944/*! -
2945 \fn uint QGLContext::colorIndex(const QColor& c) const -
2946 -
2947 \internal -
2948 -
2949 Returns a colormap index for the color c, in ColorIndex mode. Used -
2950 by qglColor() and qglClearColor(). -
2951*/ -
2952 -
2953 -
2954/*! -
2955 \fn bool QGLContext::initialized() const -
2956 -
2957 Returns true if this context has been initialized, i.e. if -
2958 QGLWidget::initializeGL() has been performed on it; otherwise -
2959 returns false. -
2960 -
2961 \sa setInitialized() -
2962*/ -
2963 -
2964/*! -
2965 \fn void QGLContext::setInitialized(bool on) -
2966 -
2967 If \a on is true the context has been initialized, i.e. -
2968 QGLContext::setInitialized() has been called on it. If \a on is -
2969 false the context has not been initialized. -
2970 -
2971 \sa initialized() -
2972*/ -
2973 -
2974/*! -
2975 \fn const QGLContext* QGLContext::currentContext() -
2976 -
2977 Returns the current context, i.e. the context to which any OpenGL -
2978 commands will currently be directed. Returns 0 if no context is -
2979 current. -
2980 -
2981 \sa makeCurrent() -
2982*/ -
2983 -
2984/*! -
2985 \fn QColor QGLContext::overlayTransparentColor() const -
2986 -
2987 If this context is a valid context in an overlay plane, returns -
2988 the plane's transparent color. Otherwise returns an \l{QColor::isValid()}{invalid} color. -
2989 -
2990 The returned color's \l{QColor::pixel()}{pixel} value is -
2991 the index of the transparent color in the colormap of the overlay -
2992 plane. (Naturally, the color's RGB values are meaningless.) -
2993 -
2994 The returned QColor object will generally work as expected only -
2995 when passed as the argument to QGLWidget::qglColor() or -
2996 QGLWidget::qglClearColor(). Under certain circumstances it can -
2997 also be used to draw transparent graphics with a QPainter. See the -
2998 examples/opengl/overlay_x11 example for details. -
2999*/ -
3000 -
3001 -
3002/*! -
3003 Creates the GL context. Returns true if it was successful in -
3004 creating a valid GL rendering context on the paint device -
3005 specified in the constructor; otherwise returns false (i.e. the -
3006 context is invalid). -
3007 -
3008 If the OpenGL implementation on your system does not support the requested -
3009 version of OpenGL context, then QGLContext will try to create the closest -
3010 matching version. The actual created context properties can be queried -
3011 using the QGLFormat returned by the format() function. For example, if -
3012 you request a context that supports OpenGL 4.3 Core profile but the driver -
3013 and/or hardware only supports version 3.2 Core profile contexts then you will -
3014 get a 3.2 Core profile context. -
3015 -
3016 After successful creation, format() returns the set of features of -
3017 the created GL rendering context. -
3018 -
3019 If \a shareContext points to a valid QGLContext, this method will -
3020 try to establish OpenGL display list and texture object sharing -
3021 between this context and the \a shareContext. Note that this may -
3022 fail if the two contexts have different \l {format()} {formats}. -
3023 Use isSharing() to see if sharing is in effect. -
3024 -
3025 \warning Implementation note: initialization of C++ class -
3026 members usually takes place in the class constructor. QGLContext -
3027 is an exception because it must be simple to customize. The -
3028 virtual functions chooseContext() (and chooseVisual() for X11) can -
3029 be reimplemented in a subclass to select a particular context. The -
3030 problem is that virtual functions are not properly called during -
3031 construction (even though this is correct C++) because C++ -
3032 constructs class hierarchies from the bottom up. For this reason -
3033 we need a create() function. -
3034 -
3035 \sa chooseContext(), format(), isValid() -
3036*/ -
3037 -
3038bool QGLContext::create(const QGLContext* shareContext) -
3039{ -
3040 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
3041 if (!d->paintDevice && !d->guiGlContext)
never evaluated: !d->paintDevice
never evaluated: !d->guiGlContext
0
3042 return false;
never executed: return false;
0
3043 -
3044 reset();
never executed (the execution status of this line is deduced): reset();
-
3045 d->valid = chooseContext(shareContext);
never executed (the execution status of this line is deduced): d->valid = chooseContext(shareContext);
-
3046 if (d->valid && d->paintDevice && d->paintDevice->devType() == QInternal::Widget) {
never evaluated: d->valid
never evaluated: d->paintDevice
never evaluated: d->paintDevice->devType() == QInternal::Widget
0
3047 QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice));
never executed (the execution status of this line is deduced): QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice));
-
3048 wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer();
never executed (the execution status of this line is deduced): wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer();
-
3049 }
never executed: }
0
3050 return d->valid;
never executed: return d->valid;
0
3051} -
3052 -
3053bool QGLContext::isValid() const -
3054{ -
3055 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3056 return d->valid;
never executed: return d->valid;
0
3057} -
3058 -
3059void QGLContext::setValid(bool valid) -
3060{ -
3061 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
3062 d->valid = valid;
never executed (the execution status of this line is deduced): d->valid = valid;
-
3063}
never executed: }
0
3064 -
3065bool QGLContext::isSharing() const -
3066{ -
3067 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3068 return d->group->isSharing();
never executed: return d->group->isSharing();
0
3069} -
3070 -
3071QGLFormat QGLContext::format() const -
3072{ -
3073 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3074 return d->glFormat;
never executed: return d->glFormat;
0
3075} -
3076 -
3077QGLFormat QGLContext::requestedFormat() const -
3078{ -
3079 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3080 return d->reqFormat;
never executed: return d->reqFormat;
0
3081} -
3082 -
3083 QPaintDevice* QGLContext::device() const -
3084{ -
3085 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3086 return d->paintDevice;
never executed: return d->paintDevice;
0
3087} -
3088 -
3089bool QGLContext::deviceIsPixmap() const -
3090{ -
3091 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3092 return d->paintDevice->devType() == QInternal::Pixmap;
never executed: return d->paintDevice->devType() == QInternal::Pixmap;
0
3093} -
3094 -
3095 -
3096bool QGLContext::windowCreated() const -
3097{ -
3098 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3099 return d->crWin;
never executed: return d->crWin;
0
3100} -
3101 -
3102 -
3103void QGLContext::setWindowCreated(bool on) -
3104{ -
3105 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
3106 d->crWin = on;
never executed (the execution status of this line is deduced): d->crWin = on;
-
3107}
never executed: }
0
3108 -
3109bool QGLContext::initialized() const -
3110{ -
3111 Q_D(const QGLContext);
never executed (the execution status of this line is deduced): const QGLContextPrivate * const d = d_func();
-
3112 return d->initDone;
never executed: return d->initDone;
0
3113} -
3114 -
3115void QGLContext::setInitialized(bool on) -
3116{ -
3117 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
3118 d->initDone = on;
never executed (the execution status of this line is deduced): d->initDone = on;
-
3119}
never executed: }
0
3120 -
3121const QGLContext* QGLContext::currentContext() -
3122{ -
3123 if (const QOpenGLContext *threadContext = QOpenGLContext::currentContext()) {
never evaluated: const QOpenGLContext *threadContext = QOpenGLContext::currentContext()
0
3124 return QGLContext::fromOpenGLContext(const_cast<QOpenGLContext *>(threadContext));
never executed: return QGLContext::fromOpenGLContext(const_cast<QOpenGLContext *>(threadContext));
0
3125 } -
3126 return 0;
never executed: return 0;
0
3127} -
3128 -
3129void QGLContextPrivate::setCurrentContext(QGLContext *context) -
3130{ -
3131 Q_UNUSED(context);
never executed (the execution status of this line is deduced): (void)context;;
-
3132}
never executed: }
0
3133 -
3134/*! -
3135 Moves the QGLContext to the given \a thread. -
3136 -
3137 Enables calling swapBuffers() and makeCurrent() on the context in -
3138 the given thread. -
3139*/ -
3140void QGLContext::moveToThread(QThread *thread) -
3141{ -
3142 Q_D(QGLContext);
never executed (the execution status of this line is deduced): QGLContextPrivate * const d = d_func();
-
3143 if (d->guiGlContext)
never evaluated: d->guiGlContext
0
3144 d->guiGlContext->moveToThread(thread);
never executed: d->guiGlContext->moveToThread(thread);
0
3145}
never executed: }
0
3146 -
3147/*! -
3148 \fn bool QGLContext::chooseContext(const QGLContext* shareContext = 0) -
3149 -
3150 This semi-internal function is called by create(). It creates a -
3151 system-dependent OpenGL handle that matches the format() of \a -
3152 shareContext as closely as possible, returning true if successful -
3153 or false if a suitable handle could not be found. -
3154 -
3155 On Windows, it calls the virtual function choosePixelFormat(), -
3156 which finds a matching pixel format identifier. On X11, it calls -
3157 the virtual function chooseVisual() which finds an appropriate X -
3158 visual. On other platforms it may work differently. -
3159*/ -
3160 -
3161/*! \fn int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc) -
3162 -
3163 \b{Win32 only:} This virtual function chooses a pixel format -
3164 that matches the OpenGL \l{setFormat()}{format}. -
3165 Reimplement this function in a subclass if you need a custom -
3166 context. -
3167 -
3168 \warning The \a dummyPfd pointer and \a pdc are used as a \c -
3169 PIXELFORMATDESCRIPTOR*. We use \c void to avoid using -
3170 Windows-specific types in our header files. -
3171 -
3172 \sa chooseContext() -
3173*/ -
3174 -
3175/*! \fn void *QGLContext::chooseVisual() -
3176 -
3177 \b{X11 only:} This virtual function tries to find a visual that -
3178 matches the format, reducing the demands if the original request -
3179 cannot be met. -
3180 -
3181 The algorithm for reducing the demands of the format is quite -
3182 simple-minded, so override this method in your subclass if your -
3183 application has spcific requirements on visual selection. -
3184 -
3185 \sa chooseContext() -
3186*/ -
3187 -
3188/*! \fn void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) -
3189 \internal -
3190 -
3191 \b{X11 only:} This virtual function chooses a visual that matches -
3192 the OpenGL \l{format()}{format}. Reimplement this function -
3193 in a subclass if you need a custom visual. -
3194 -
3195 \sa chooseContext() -
3196*/ -
3197 -
3198/*! -
3199 \fn void QGLContext::reset() -
3200 -
3201 Resets the context and makes it invalid. -
3202 -
3203 \sa create(), isValid() -
3204*/ -
3205 -
3206 -
3207/*! -
3208 \fn void QGLContext::makeCurrent() -
3209 -
3210 Makes this context the current OpenGL rendering context. All GL -
3211 functions you call operate on this context until another context -
3212 is made current. -
3213 -
3214 In some very rare cases the underlying call may fail. If this -
3215 occurs an error message is output to stderr. -
3216 -
3217 If you call this from a thread other than the main UI thread, -
3218 make sure you've first pushed the context to the relevant thread -
3219 from the UI thread using moveToThread(). -
3220*/ -
3221 -
3222 -
3223/*! -
3224 \fn void QGLContext::swapBuffers() const -
3225 -
3226 Call this to finish a frame of OpenGL rendering, and make sure to -
3227 call makeCurrent() again before you begin a new frame. -
3228*/ -
3229 -
3230 -
3231/*! -
3232 \fn void QGLContext::doneCurrent() -
3233 -
3234 Makes no GL context the current context. Normally, you do not need -
3235 to call this function; QGLContext calls it as necessary. -
3236*/ -
3237 -
3238 -
3239/*! -
3240 \fn QPaintDevice* QGLContext::device() const -
3241 -
3242 Returns the paint device set for this context. -
3243 -
3244 \sa QGLContext::QGLContext() -
3245*/ -
3246 -
3247 -
3248/***************************************************************************** -
3249 QGLWidget implementation -
3250 *****************************************************************************/ -
3251 -
3252 -
3253/*! -
3254 \class QGLWidget -
3255 \inmodule QtOpenGL -
3256 -
3257 \brief The QGLWidget class is a widget for rendering OpenGL graphics. -
3258 -
3259 QGLWidget provides functionality for displaying OpenGL graphics -
3260 integrated into a Qt application. It is very simple to use. You -
3261 inherit from it and use the subclass like any other QWidget, -
3262 except that you have the choice between using QPainter and -
3263 standard OpenGL rendering commands. -
3264 -
3265 QGLWidget provides three convenient virtual functions that you can -
3266 reimplement in your subclass to perform the typical OpenGL tasks: -
3267 -
3268 \list -
3269 \li paintGL() - Renders the OpenGL scene. Gets called whenever the widget -
3270 needs to be updated. -
3271 \li resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets -
3272 called whenever the widget has been resized (and also when it -
3273 is shown for the first time because all newly created widgets get a -
3274 resize event automatically). -
3275 \li initializeGL() - Sets up the OpenGL rendering context, defines display -
3276 lists, etc. Gets called once before the first time resizeGL() or -
3277 paintGL() is called. -
3278 \endlist -
3279 -
3280 Here is a rough outline of how a QGLWidget subclass might look: -
3281 -
3282 \snippet code/src_opengl_qgl.cpp 8 -
3283 -
3284 If you need to trigger a repaint from places other than paintGL() -
3285 (a typical example is when using \l{QTimer}{timers} to -
3286 animate scenes), you should call the widget's updateGL() function. -
3287 -
3288 Your widget's OpenGL rendering context is made current when -
3289 paintGL(), resizeGL(), or initializeGL() is called. If you need to -
3290 call the standard OpenGL API functions from other places (e.g. in -
3291 your widget's constructor or in your own paint functions), you -
3292 must call makeCurrent() first. -
3293 -
3294 QGLWidget provides functions for requesting a new display -
3295 \l{QGLFormat}{format} and you can also create widgets with -
3296 customized rendering \l{QGLContext}{contexts}. -
3297 -
3298 You can also share OpenGL display lists between QGLWidget objects (see -
3299 the documentation of the QGLWidget constructors for details). -
3300 -
3301 Note that under Windows, the QGLContext belonging to a QGLWidget -
3302 has to be recreated when the QGLWidget is reparented. This is -
3303 necessary due to limitations on the Windows platform. This will -
3304 most likely cause problems for users that have subclassed and -
3305 installed their own QGLContext on a QGLWidget. It is possible to -
3306 work around this issue by putting the QGLWidget inside a dummy -
3307 widget and then reparenting the dummy widget, instead of the -
3308 QGLWidget. This will side-step the issue altogether, and is what -
3309 we recommend for users that need this kind of functionality. -
3310 -
3311 On Mac OS X, when Qt is built with Cocoa support, a QGLWidget -
3312 can't have any sibling widgets placed ontop of itself. This is due -
3313 to limitations in the Cocoa API and is not supported by Apple. -
3314 -
3315 \section1 Overlays -
3316 -
3317 The QGLWidget creates a GL overlay context in addition to the -
3318 normal context if overlays are supported by the underlying system. -
3319 -
3320 If you want to use overlays, you specify it in the -
3321 \l{QGLFormat}{format}. (Note: Overlay must be requested in the format -
3322 passed to the QGLWidget constructor.) Your GL widget should also -
3323 implement some or all of these virtual methods: -
3324 -
3325 \list -
3326 \li paintOverlayGL() -
3327 \li resizeOverlayGL() -
3328 \li initializeOverlayGL() -
3329 \endlist -
3330 -
3331 These methods work in the same way as the normal paintGL() etc. -
3332 functions, except that they will be called when the overlay -
3333 context is made current. You can explicitly make the overlay -
3334 context current by using makeOverlayCurrent(), and you can access -
3335 the overlay context directly (e.g. to ask for its transparent -
3336 color) by calling overlayContext(). -
3337 -
3338 On X servers in which the default visual is in an overlay plane, -
3339 non-GL Qt windows can also be used for overlays. -
3340 -
3341 \section1 Painting Techniques -
3342 -
3343 As described above, subclass QGLWidget to render pure 3D content in the -
3344 following way: -
3345 -
3346 \list -
3347 \li Reimplement the QGLWidget::initializeGL() and QGLWidget::resizeGL() to -
3348 set up the OpenGL state and provide a perspective transformation. -
3349 \li Reimplement QGLWidget::paintGL() to paint the 3D scene, calling only -
3350 OpenGL functions to draw on the widget. -
3351 \endlist -
3352 -
3353 It is also possible to draw 2D graphics onto a QGLWidget subclass, it is necessary -
3354 to reimplement QGLWidget::paintEvent() and do the following: -
3355 -
3356 \list -
3357 \li Construct a QPainter object. -
3358 \li Initialize it for use on the widget with the QPainter::begin() function. -
3359 \li Draw primitives using QPainter's member functions. -
3360 \li Call QPainter::end() to finish painting. -
3361 \endlist -
3362 -
3363 Overpainting 2D content on top of 3D content takes a little more effort. -
3364 One approach to doing this is shown in the -
3365 \l{Overpainting Example}{Overpainting} example. -
3366 -
3367 \section1 Threading -
3368 -
3369 As of Qt version 4.8, support for doing threaded GL rendering has -
3370 been improved. There are three scenarios that we currently support: -
3371 \list -
3372 \li 1. Buffer swapping in a thread. -
3373 -
3374 Swapping buffers in a double buffered context may be a -
3375 synchronous, locking call that may be a costly operation in some -
3376 GL implementations. Especially so on embedded devices. It's not -
3377 optimal to have the CPU idling while the GPU is doing a buffer -
3378 swap. In those cases it is possible to do the rendering in the -
3379 main thread and do the actual buffer swap in a separate -
3380 thread. This can be done with the following steps: -
3381 -
3382 1. Call doneCurrent() in the main thread when the rendering is -
3383 finished. -
3384 -
3385 2. Call QGLContext::moveToThread(swapThread) to transfer ownership -
3386 of the context to the swapping thread. -
3387 -
3388 3. Notify the swapping thread that it can grab the context. -
3389 -
3390 4. Make the rendering context current in the swapping thread with -
3391 makeCurrent() and then call swapBuffers(). -
3392 -
3393 5. Call doneCurrent() in the swapping thread. -
3394 -
3395 6. Call QGLContext::moveToThread(qApp->thread()) and notify the -
3396 main thread that swapping is done. -
3397 -
3398 Doing this will free up the main thread so that it can continue -
3399 with, for example, handling UI events or network requests. Even if -
3400 there is a context swap involved, it may be preferable compared to -
3401 having the main thread wait while the GPU finishes the swap -
3402 operation. Note that this is highly implementation dependent. -
3403 -
3404 \li 2. Texture uploading in a thread. -
3405 -
3406 Doing texture uploads in a thread may be very useful for -
3407 applications handling large amounts of images that needs to be -
3408 displayed, like for instance a photo gallery application. This is -
3409 supported in Qt through the existing bindTexture() API. A simple -
3410 way of doing this is to create two sharing QGLWidgets. One is made -
3411 current in the main GUI thread, while the other is made current in -
3412 the texture upload thread. The widget in the uploading thread is -
3413 never shown, it is only used for sharing textures with the main -
3414 thread. For each texture that is bound via bindTexture(), notify -
3415 the main thread so that it can start using the texture. -
3416 -
3417 \li 3. Using QPainter to draw into a QGLWidget in a thread. -
3418 -
3419 In Qt 4.8, it is possible to draw into a QGLWidget using a -
3420 QPainter in a separate thread. Note that this is also possible for -
3421 QGLPixelBuffers and QGLFramebufferObjects. Since this is only -
3422 supported in the GL 2 paint engine, OpenGL 2.0 or OpenGL ES 2.0 is -
3423 required. -
3424 -
3425 QGLWidgets can only be created in the main GUI thread. This means -
3426 a call to doneCurrent() is necessary to release the GL context -
3427 from the main thread, before the widget can be drawn into by -
3428 another thread. You then need to call QGLContext::moveToThread() -
3429 to transfer ownership of the context to the thread in which you -
3430 want to make it current. -
3431 Also, the main GUI thread will dispatch resize and -
3432 paint events to a QGLWidget when the widget is resized, or parts -
3433 of it becomes exposed or needs redrawing. It is therefore -
3434 necessary to handle those events because the default -
3435 implementations inside QGLWidget will try to make the QGLWidget's -
3436 context current, which again will interfere with any threads -
3437 rendering into the widget. Reimplement QGLWidget::paintEvent() and -
3438 QGLWidget::resizeEvent() to notify the rendering thread that a -
3439 resize or update is necessary, and be careful not to call the base -
3440 class implementation. If you are rendering an animation, it might -
3441 not be necessary to handle the paint event at all since the -
3442 rendering thread is doing regular updates. Then it would be enough -
3443 to reimplement QGLWidget::paintEvent() to do nothing. -
3444 -
3445 \endlist -
3446 -
3447 As a general rule when doing threaded rendering: be aware that -
3448 binding and releasing contexts in different threads have to be -
3449 synchronized by the user. A GL rendering context can only be -
3450 current in one thread at any time. If you try to open a QPainter -
3451 on a QGLWidget and the widget's rendering context is current in -
3452 another thread, it will fail. -
3453 -
3454 In addition to this, rendering using raw GL calls in a separate -
3455 thread is supported. -
3456 -
3457 \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other -
3458 countries.} -
3459 -
3460 \sa QGLPixelBuffer, {Hello GL Example}, {2D Painting Example}, {Overpainting Example}, -
3461 {Grabber Example} -
3462*/ -
3463 -
3464/*! -
3465 Constructs an OpenGL widget with a \a parent widget. -
3466 -
3467 The \l{QGLFormat::defaultFormat()}{default format} is -
3468 used. The widget will be \l{isValid()}{invalid} if the -
3469 system has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. -
3470 -
3471 The \a parent and widget flag, \a f, arguments are passed -
3472 to the QWidget constructor. -
3473 -
3474 If \a shareWidget is a valid QGLWidget, this widget will share -
3475 OpenGL display lists and texture objects with \a shareWidget. But -
3476 if \a shareWidget and this widget have different \l {format()} -
3477 {formats}, sharing might not be possible. You can check whether -
3478 sharing is in effect by calling isSharing(). -
3479 -
3480 The initialization of OpenGL rendering state, etc. should be done -
3481 by overriding the initializeGL() function, rather than in the -
3482 constructor of your QGLWidget subclass. -
3483 -
3484 \sa QGLFormat::defaultFormat(), {Textures Example} -
3485*/ -
3486 -
3487QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFlags f) -
3488 : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC) -
3489{ -
3490 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3491 setAttribute(Qt::WA_PaintOnScreen);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_PaintOnScreen);
-
3492 setAttribute(Qt::WA_NoSystemBackground);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground);
-
3493 setAutoFillBackground(true); // for compatibility
never executed (the execution status of this line is deduced): setAutoFillBackground(true);
-
3494 d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget);
never executed (the execution status of this line is deduced): d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget);
-
3495}
never executed: }
0
3496 -
3497/*! -
3498 \internal -
3499 */ -
3500QGLWidget::QGLWidget(QGLWidgetPrivate &dd, const QGLFormat &format, QWidget *parent, const QGLWidget *shareWidget, Qt::WindowFlags f) -
3501 : QWidget(dd, parent, f | Qt::MSWindowsOwnDC) -
3502{ -
3503 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3504 setAttribute(Qt::WA_PaintOnScreen);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_PaintOnScreen);
-
3505 setAttribute(Qt::WA_NoSystemBackground);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground);
-
3506 setAutoFillBackground(true); // for compatibility
never executed (the execution status of this line is deduced): setAutoFillBackground(true);
-
3507 d->init(new QGLContext(format, this), shareWidget);
never executed (the execution status of this line is deduced): d->init(new QGLContext(format, this), shareWidget);
-
3508 -
3509}
never executed: }
0
3510 -
3511 -
3512/*! -
3513 Constructs an OpenGL widget with parent \a parent. -
3514 -
3515 The \a format argument specifies the desired -
3516 \l{QGLFormat}{rendering options}. -
3517 If the underlying OpenGL/Window system -
3518 cannot satisfy all the features requested in \a format, the -
3519 nearest subset of features will be used. After creation, the -
3520 format() method will return the actual format obtained. -
3521 -
3522 The widget will be \l{isValid()}{invalid} if the system -
3523 has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. -
3524 -
3525 The \a parent and widget flag, \a f, arguments are passed -
3526 to the QWidget constructor. -
3527 -
3528 If \a shareWidget is a valid QGLWidget, this widget will share -
3529 OpenGL display lists and texture objects with \a shareWidget. But -
3530 if \a shareWidget and this widget have different \l {format()} -
3531 {formats}, sharing might not be possible. You can check whether -
3532 sharing is in effect by calling isSharing(). -
3533 -
3534 The initialization of OpenGL rendering state, etc. should be done -
3535 by overriding the initializeGL() function, rather than in the -
3536 constructor of your QGLWidget subclass. -
3537 -
3538 \sa QGLFormat::defaultFormat(), isValid() -
3539*/ -
3540 -
3541QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget* shareWidget, -
3542 Qt::WindowFlags f) -
3543 : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC) -
3544{ -
3545 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3546 setAttribute(Qt::WA_PaintOnScreen);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_PaintOnScreen);
-
3547 setAttribute(Qt::WA_NoSystemBackground);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground);
-
3548 setAutoFillBackground(true); // for compatibility
never executed (the execution status of this line is deduced): setAutoFillBackground(true);
-
3549 d->init(new QGLContext(format, this), shareWidget);
never executed (the execution status of this line is deduced): d->init(new QGLContext(format, this), shareWidget);
-
3550}
never executed: }
0
3551 -
3552/*! -
3553 Constructs an OpenGL widget with parent \a parent. -
3554 -
3555 The \a context argument is a pointer to the QGLContext that -
3556 you wish to be bound to this widget. This allows you to pass in -
3557 your own QGLContext sub-classes. -
3558 -
3559 The widget will be \l{isValid()}{invalid} if the system -
3560 has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. -
3561 -
3562 The \a parent and widget flag, \a f, arguments are passed -
3563 to the QWidget constructor. -
3564 -
3565 If \a shareWidget is a valid QGLWidget, this widget will share -
3566 OpenGL display lists and texture objects with \a shareWidget. But -
3567 if \a shareWidget and this widget have different \l {format()} -
3568 {formats}, sharing might not be possible. You can check whether -
3569 sharing is in effect by calling isSharing(). -
3570 -
3571 The initialization of OpenGL rendering state, etc. should be done -
3572 by overriding the initializeGL() function, rather than in the -
3573 constructor of your QGLWidget subclass. -
3574 -
3575 \sa QGLFormat::defaultFormat(), isValid() -
3576*/ -
3577QGLWidget::QGLWidget(QGLContext *context, QWidget *parent, const QGLWidget *shareWidget, -
3578 Qt::WindowFlags f) -
3579 : QWidget(*(new QGLWidgetPrivate), parent, f | Qt::MSWindowsOwnDC) -
3580{ -
3581 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3582 setAttribute(Qt::WA_PaintOnScreen);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_PaintOnScreen);
-
3583 setAttribute(Qt::WA_NoSystemBackground);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground);
-
3584 setAutoFillBackground(true); // for compatibility
never executed (the execution status of this line is deduced): setAutoFillBackground(true);
-
3585 d->init(context, shareWidget);
never executed (the execution status of this line is deduced): d->init(context, shareWidget);
-
3586}
never executed: }
0
3587 -
3588/*! -
3589 Destroys the widget. -
3590*/ -
3591 -
3592QGLWidget::~QGLWidget() -
3593{ -
3594 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3595 delete d->glcx;
never executed (the execution status of this line is deduced): delete d->glcx;
-
3596 d->glcx = 0;
never executed (the execution status of this line is deduced): d->glcx = 0;
-
3597 d->cleanupColormaps();
never executed (the execution status of this line is deduced): d->cleanupColormaps();
-
3598}
never executed: }
0
3599 -
3600/*! -
3601 \fn QGLFormat QGLWidget::format() const -
3602 -
3603 Returns the format of the contained GL rendering context. -
3604*/ -
3605 -
3606/*! -
3607 \fn bool QGLWidget::doubleBuffer() const -
3608 -
3609 Returns true if the contained GL rendering context has double -
3610 buffering; otherwise returns false. -
3611 -
3612 \sa QGLFormat::doubleBuffer() -
3613*/ -
3614 -
3615/*! -
3616 \fn void QGLWidget::setAutoBufferSwap(bool on) -
3617 -
3618 If \a on is true automatic GL buffer swapping is switched on; -
3619 otherwise it is switched off. -
3620 -
3621 If \a on is true and the widget is using a double-buffered format, -
3622 the background and foreground GL buffers will automatically be -
3623 swapped after each paintGL() call. -
3624 -
3625 The buffer auto-swapping is on by default. -
3626 -
3627 \sa autoBufferSwap(), doubleBuffer(), swapBuffers() -
3628*/ -
3629 -
3630/*! -
3631 \fn bool QGLWidget::autoBufferSwap() const -
3632 -
3633 Returns true if the widget is doing automatic GL buffer swapping; -
3634 otherwise returns false. -
3635 -
3636 \sa setAutoBufferSwap() -
3637*/ -
3638 -
3639/*! -
3640 \fn QFunctionPointer QGLContext::getProcAddress() const -
3641 -
3642 Returns a function pointer to the GL extension function passed in -
3643 \a proc. 0 is returned if a pointer to the function could not be -
3644 obtained. -
3645*/ -
3646 -
3647/*! -
3648 \fn bool QGLWidget::isValid() const -
3649 -
3650 Returns true if the widget has a valid GL rendering context; -
3651 otherwise returns false. A widget will be invalid if the system -
3652 has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. -
3653*/ -
3654 -
3655bool QGLWidget::isValid() const -
3656{ -
3657 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
3658 return d->glcx && d->glcx->isValid();
never executed: return d->glcx && d->glcx->isValid();
0
3659} -
3660 -
3661/*! -
3662 \fn bool QGLWidget::isSharing() const -
3663 -
3664 Returns true if this widget's GL context is shared with another GL -
3665 context, otherwise false is returned. Context sharing might not be -
3666 possible if the widgets use different formats. -
3667 -
3668 \sa format() -
3669*/ -
3670 -
3671bool QGLWidget::isSharing() const -
3672{ -
3673 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
3674 return d->glcx->isSharing();
never executed: return d->glcx->isSharing();
0
3675} -
3676 -
3677/*! -
3678 \fn void QGLWidget::makeCurrent() -
3679 -
3680 Makes this widget the current widget for OpenGL operations, i.e. -
3681 makes the widget's rendering context the current OpenGL rendering -
3682 context. -
3683*/ -
3684 -
3685void QGLWidget::makeCurrent() -
3686{ -
3687 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3688 d->glcx->makeCurrent();
never executed (the execution status of this line is deduced): d->glcx->makeCurrent();
-
3689}
never executed: }
0
3690 -
3691/*! -
3692 \fn void QGLWidget::doneCurrent() -
3693 -
3694 Makes no GL context the current context. Normally, you do not need -
3695 to call this function; QGLContext calls it as necessary. However, -
3696 it may be useful in multithreaded environments. -
3697*/ -
3698 -
3699void QGLWidget::doneCurrent() -
3700{ -
3701 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3702 d->glcx->doneCurrent();
never executed (the execution status of this line is deduced): d->glcx->doneCurrent();
-
3703}
never executed: }
0
3704 -
3705/*! -
3706 \fn void QGLWidget::swapBuffers() -
3707 -
3708 Swaps the screen contents with an off-screen buffer. This only -
3709 works if the widget's format specifies double buffer mode. -
3710 -
3711 Normally, there is no need to explicitly call this function -
3712 because it is done automatically after each widget repaint, i.e. -
3713 each time after paintGL() has been executed. -
3714 -
3715 \sa doubleBuffer(), setAutoBufferSwap(), QGLFormat::setDoubleBuffer() -
3716*/ -
3717 -
3718void QGLWidget::swapBuffers() -
3719{ -
3720 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
3721 d->glcx->swapBuffers();
never executed (the execution status of this line is deduced): d->glcx->swapBuffers();
-
3722}
never executed: }
0
3723 -
3724 -
3725/*! -
3726 \fn const QGLContext* QGLWidget::overlayContext() const -
3727 -
3728 Returns the overlay context of this widget, or 0 if this widget -
3729 has no overlay. -
3730 -
3731 \sa context() -
3732*/ -
3733 -
3734 -
3735 -
3736/*! -
3737 \fn void QGLWidget::makeOverlayCurrent() -
3738 -
3739 Makes the overlay context of this widget current. Use this if you -
3740 need to issue OpenGL commands to the overlay context outside of -
3741 initializeOverlayGL(), resizeOverlayGL(), and paintOverlayGL(). -
3742 -
3743 Does nothing if this widget has no overlay. -
3744 -
3745 \sa makeCurrent() -
3746*/ -
3747 -
3748 -
3749/*! -
3750 \obsolete -
3751 -
3752 Sets a new format for this widget. -
3753 -
3754 If the underlying OpenGL/Window system cannot satisfy all the -
3755 features requested in \a format, the nearest subset of features will -
3756 be used. After creation, the format() method will return the actual -
3757 rendering context format obtained. -
3758 -
3759 The widget will be assigned a new QGLContext, and the initializeGL() -
3760 function will be executed for this new context before the first -
3761 resizeGL() or paintGL(). -
3762 -
3763 This method will try to keep display list and texture object sharing -
3764 in effect with other QGLWidget objects, but changing the format might make -
3765 sharing impossible. Use isSharing() to see if sharing is still in -
3766 effect. -
3767 -
3768 \sa format(), isSharing(), isValid() -
3769*/ -
3770 -
3771void QGLWidget::setFormat(const QGLFormat &format) -
3772{ -
3773 setContext(new QGLContext(format,this));
never executed (the execution status of this line is deduced): setContext(new QGLContext(format,this));
-
3774}
never executed: }
0
3775 -
3776 -
3777 -
3778 -
3779/*! -
3780 \fn QGLContext *QGLWidget::context() const -
3781 -
3782 Returns the context of this widget. -
3783 -
3784 It is possible that the context is not valid (see isValid()), for -
3785 example, if the underlying hardware does not support the format -
3786 attributes that were requested. -
3787*/ -
3788 -
3789/* -
3790 \fn void QGLWidget::setContext(QGLContext *context, -
3791 const QGLContext* shareContext, -
3792 bool deleteOldContext) -
3793 \obsolete -
3794 -
3795 Sets a new context for this widget. The QGLContext \a context must -
3796 be created using \e new. QGLWidget will delete \a context when -
3797 another context is set or when the widget is destroyed. -
3798 -
3799 If \a context is invalid, QGLContext::create() is performed on -
3800 it. The initializeGL() function will then be executed for the new -
3801 context before the first resizeGL() or paintGL(). -
3802 -
3803 If \a context is invalid, this method will try to keep display list -
3804 and texture object sharing in effect, or (if \a shareContext points -
3805 to a valid context) start display list and texture object sharing -
3806 with that context, but sharing might be impossible if the two -
3807 contexts have different \l {format()} {formats}. Use isSharing() to -
3808 see whether sharing is in effect. -
3809 -
3810 If \a deleteOldContext is true (the default), the existing context -
3811 will be deleted. You may use false here if you have kept a pointer -
3812 to the old context (as returned by context()), and want to restore -
3813 that context later. -
3814 -
3815 \sa context(), isSharing() -
3816*/ -
3817 -
3818 -
3819 -
3820/*! -
3821 \fn void QGLWidget::updateGL() -
3822 -
3823 Updates the widget by calling glDraw(). -
3824*/ -
3825 -
3826void QGLWidget::updateGL() -
3827{ -
3828 if (updatesEnabled() && testAttribute(Qt::WA_Mapped))
never evaluated: updatesEnabled()
never evaluated: testAttribute(Qt::WA_Mapped)
0
3829 glDraw();
never executed: glDraw();
0
3830}
never executed: }
0
3831 -
3832 -
3833/*! -
3834 \fn void QGLWidget::updateOverlayGL() -
3835 -
3836 Updates the widget's overlay (if any). Will cause the virtual -
3837 function paintOverlayGL() to be executed. -
3838 -
3839 The widget's rendering context will become the current context and -
3840 initializeGL() will be called if it hasn't already been called. -
3841*/ -
3842 -
3843 -
3844/*! -
3845 This virtual function is called once before the first call to -
3846 paintGL() or resizeGL(), and then once whenever the widget has -
3847 been assigned a new QGLContext. Reimplement it in a subclass. -
3848 -
3849 This function should set up any required OpenGL context rendering -
3850 flags, defining display lists, etc. -
3851 -
3852 There is no need to call makeCurrent() because this has already -
3853 been done when this function is called. -
3854*/ -
3855 -
3856void QGLWidget::initializeGL() -
3857{ -
3858} -
3859 -
3860 -
3861/*! -
3862 This virtual function is called whenever the widget needs to be -
3863 painted. Reimplement it in a subclass. -
3864 -
3865 There is no need to call makeCurrent() because this has already -
3866 been done when this function is called. -
3867*/ -
3868 -
3869void QGLWidget::paintGL() -
3870{ -
3871 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
never executed (the execution status of this line is deduced): glClear(0x00004000 | 0x00000100);
-
3872}
never executed: }
0
3873 -
3874 -
3875/*! -
3876 \fn void QGLWidget::resizeGL(int width , int height) -
3877 -
3878 This virtual function is called whenever the widget has been -
3879 resized. The new size is passed in \a width and \a height. -
3880 Reimplement it in a subclass. -
3881 -
3882 There is no need to call makeCurrent() because this has already -
3883 been done when this function is called. -
3884*/ -
3885 -
3886void QGLWidget::resizeGL(int, int) -
3887{ -
3888} -
3889 -
3890 -
3891 -
3892/*! -
3893 This virtual function is used in the same manner as initializeGL() -
3894 except that it operates on the widget's overlay context instead of -
3895 the widget's main context. This means that initializeOverlayGL() -
3896 is called once before the first call to paintOverlayGL() or -
3897 resizeOverlayGL(). Reimplement it in a subclass. -
3898 -
3899 This function should set up any required OpenGL context rendering -
3900 flags, defining display lists, etc. for the overlay context. -
3901 -
3902 There is no need to call makeOverlayCurrent() because this has -
3903 already been done when this function is called. -
3904*/ -
3905 -
3906void QGLWidget::initializeOverlayGL() -
3907{ -
3908} -
3909 -
3910 -
3911/*! -
3912 This virtual function is used in the same manner as paintGL() -
3913 except that it operates on the widget's overlay context instead of -
3914 the widget's main context. This means that paintOverlayGL() is -
3915 called whenever the widget's overlay needs to be painted. -
3916 Reimplement it in a subclass. -
3917 -
3918 There is no need to call makeOverlayCurrent() because this has -
3919 already been done when this function is called. -
3920*/ -
3921 -
3922void QGLWidget::paintOverlayGL() -
3923{ -
3924} -
3925 -
3926 -
3927/*! -
3928 \fn void QGLWidget::resizeOverlayGL(int width , int height) -
3929 -
3930 This virtual function is used in the same manner as paintGL() -
3931 except that it operates on the widget's overlay context instead of -
3932 the widget's main context. This means that resizeOverlayGL() is -
3933 called whenever the widget has been resized. The new size is -
3934 passed in \a width and \a height. Reimplement it in a subclass. -
3935 -
3936 There is no need to call makeOverlayCurrent() because this has -
3937 already been done when this function is called. -
3938*/ -
3939 -
3940void QGLWidget::resizeOverlayGL(int, int) -
3941{ -
3942} -
3943 -
3944/*! -
3945 \fn void QGLWidget::paintEvent(QPaintEvent *event) -
3946 -
3947 Handles paint events passed in the \a event parameter. Will cause -
3948 the virtual paintGL() function to be called. -
3949 -
3950 The widget's rendering context will become the current context and -
3951 initializeGL() will be called if it hasn't already been called. -
3952*/ -
3953 -
3954void QGLWidget::paintEvent(QPaintEvent *) -
3955{ -
3956 if (updatesEnabled()) {
never evaluated: updatesEnabled()
0
3957 glDraw();
never executed (the execution status of this line is deduced): glDraw();
-
3958 updateOverlayGL();
never executed (the execution status of this line is deduced): updateOverlayGL();
-
3959 }
never executed: }
0
3960}
never executed: }
0
3961 -
3962 -
3963/*! -
3964 \fn void QGLWidget::resizeEvent(QResizeEvent *event) -
3965 -
3966 Handles resize events that are passed in the \a event parameter. -
3967 Calls the virtual function resizeGL(). -
3968*/ -
3969 -
3970 -
3971/*! -
3972 \fn void QGLWidget::setMouseTracking(bool enable) -
3973 -
3974 If \a enable is true then mouse tracking is enabled; otherwise it -
3975 is disabled. -
3976*/ -
3977 -
3978 -
3979/*! -
3980 Renders the current scene on a pixmap and returns the pixmap. -
3981 -
3982 You can use this method on both visible and invisible QGLWidget objects. -
3983 -
3984 This method will create a pixmap and a temporary QGLContext to -
3985 render on the pixmap. It will then call initializeGL(), -
3986 resizeGL(), and paintGL() on this context. Finally, the widget's -
3987 original GL context is restored. -
3988 -
3989 The size of the pixmap will be \a w pixels wide and \a h pixels -
3990 high unless one of these parameters is 0 (the default), in which -
3991 case the pixmap will have the same size as the widget. -
3992 -
3993 If \a useContext is true, this method will try to be more -
3994 efficient by using the existing GL context to render the pixmap. -
3995 The default is false. Only use true if you understand the risks. -
3996 Note that under Windows a temporary context has to be created -
3997 and usage of the \e useContext parameter is not supported. -
3998 -
3999 Overlays are not rendered onto the pixmap. -
4000 -
4001 If the GL rendering context and the desktop have different bit -
4002 depths, the result will most likely look surprising. -
4003 -
4004 Note that the creation of display lists, modifications of the view -
4005 frustum etc. should be done from within initializeGL(). If this is -
4006 not done, the temporary QGLContext will not be initialized -
4007 properly, and the rendered pixmap may be incomplete/corrupted. -
4008*/ -
4009 -
4010QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext) -
4011{ -
4012 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4013 QSize sz = size();
never executed (the execution status of this line is deduced): QSize sz = size();
-
4014 if ((w > 0) && (h > 0))
never evaluated: (w > 0)
never evaluated: (h > 0)
0
4015 sz = QSize(w, h);
never executed: sz = QSize(w, h);
0
4016 -
4017 QPixmap pm(sz);
never executed (the execution status of this line is deduced): QPixmap pm(sz);
-
4018 -
4019 d->glcx->doneCurrent();
never executed (the execution status of this line is deduced): d->glcx->doneCurrent();
-
4020 -
4021 bool success = true;
never executed (the execution status of this line is deduced): bool success = true;
-
4022 -
4023 if (useContext && isValid() && d->renderCxPm(&pm))
never evaluated: useContext
never evaluated: isValid()
never evaluated: d->renderCxPm(&pm)
0
4024 return pm;
never executed: return pm;
0
4025 -
4026 QGLFormat fmt = d->glcx->requestedFormat();
never executed (the execution status of this line is deduced): QGLFormat fmt = d->glcx->requestedFormat();
-
4027 fmt.setDirectRendering(false); // Direct is unlikely to work
never executed (the execution status of this line is deduced): fmt.setDirectRendering(false);
-
4028 fmt.setDoubleBuffer(false); // We don't need dbl buf
never executed (the execution status of this line is deduced): fmt.setDoubleBuffer(false);
-
4029 -
4030 QGLContext* ocx = d->glcx;
never executed (the execution status of this line is deduced): QGLContext* ocx = d->glcx;
-
4031 ocx->doneCurrent();
never executed (the execution status of this line is deduced): ocx->doneCurrent();
-
4032 d->glcx = new QGLContext(fmt, &pm);
never executed (the execution status of this line is deduced): d->glcx = new QGLContext(fmt, &pm);
-
4033 d->glcx->create();
never executed (the execution status of this line is deduced): d->glcx->create();
-
4034 -
4035 if (d->glcx->isValid())
never evaluated: d->glcx->isValid()
0
4036 updateGL();
never executed: updateGL();
0
4037 else -
4038 success = false;
never executed: success = false;
0
4039 -
4040 delete d->glcx;
never executed (the execution status of this line is deduced): delete d->glcx;
-
4041 d->glcx = ocx;
never executed (the execution status of this line is deduced): d->glcx = ocx;
-
4042 -
4043 ocx->makeCurrent();
never executed (the execution status of this line is deduced): ocx->makeCurrent();
-
4044 -
4045 if (success) {
never evaluated: success
0
4046 return pm;
never executed: return pm;
0
4047 } -
4048 return QPixmap();
never executed: return QPixmap();
0
4049} -
4050 -
4051/*! -
4052 Returns an image of the frame buffer. If \a withAlpha is true the -
4053 alpha channel is included. -
4054 -
4055 Depending on your hardware, you can explicitly select which color -
4056 buffer to grab with a glReadBuffer() call before calling this -
4057 function. -
4058*/ -
4059QImage QGLWidget::grabFrameBuffer(bool withAlpha) -
4060{ -
4061 makeCurrent();
never executed (the execution status of this line is deduced): makeCurrent();
-
4062 QImage res;
never executed (the execution status of this line is deduced): QImage res;
-
4063 int w = width();
never executed (the execution status of this line is deduced): int w = width();
-
4064 int h = height();
never executed (the execution status of this line is deduced): int h = height();
-
4065 if (format().rgba())
never evaluated: format().rgba()
0
4066 res = qt_gl_read_frame_buffer(QSize(w, h), format().alpha(), withAlpha);
never executed: res = qt_gl_read_frame_buffer(QSize(w, h), format().alpha(), withAlpha);
0
4067 -
4068 return res;
never executed: return res;
0
4069} -
4070 -
4071 -
4072 -
4073/*! -
4074 Initializes OpenGL for this widget's context. Calls the virtual -
4075 function initializeGL(). -
4076*/ -
4077 -
4078void QGLWidget::glInit() -
4079{ -
4080 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4081 if (!isValid())
never evaluated: !isValid()
0
4082 return;
never executed: return;
0
4083 makeCurrent();
never executed (the execution status of this line is deduced): makeCurrent();
-
4084 initializeGL();
never executed (the execution status of this line is deduced): initializeGL();
-
4085 d->glcx->setInitialized(true);
never executed (the execution status of this line is deduced): d->glcx->setInitialized(true);
-
4086}
never executed: }
0
4087 -
4088 -
4089/*! -
4090 Executes the virtual function paintGL(). -
4091 -
4092 The widget's rendering context will become the current context and -
4093 initializeGL() will be called if it hasn't already been called. -
4094*/ -
4095 -
4096void QGLWidget::glDraw() -
4097{ -
4098 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4099 if (!isValid())
never evaluated: !isValid()
0
4100 return;
never executed: return;
0
4101 makeCurrent();
never executed (the execution status of this line is deduced): makeCurrent();
-
4102#ifndef QT_OPENGL_ES -
4103 if (d->glcx->deviceIsPixmap())
never evaluated: d->glcx->deviceIsPixmap()
0
4104 glDrawBuffer(GL_FRONT);
never executed: glDrawBuffer(0x0404);
0
4105#endif -
4106 if (!d->glcx->initialized()) {
never evaluated: !d->glcx->initialized()
0
4107 glInit();
never executed (the execution status of this line is deduced): glInit();
-
4108 const qreal scaleFactor = (window() && window()->windowHandle()) ?
never evaluated: window()
never evaluated: window()->windowHandle()
0
4109 window()->windowHandle()->devicePixelRatio() : 1.0;
never executed (the execution status of this line is deduced): window()->windowHandle()->devicePixelRatio() : 1.0;
-
4110 resizeGL(d->glcx->device()->width() * scaleFactor, d->glcx->device()->height() * scaleFactor); // New context needs this "resize"
never executed (the execution status of this line is deduced): resizeGL(d->glcx->device()->width() * scaleFactor, d->glcx->device()->height() * scaleFactor);
-
4111 }
never executed: }
0
4112 paintGL();
never executed (the execution status of this line is deduced): paintGL();
-
4113 if (doubleBuffer()) {
never evaluated: doubleBuffer()
0
4114 if (d->autoSwap)
never evaluated: d->autoSwap
0
4115 swapBuffers();
never executed: swapBuffers();
0
4116 } else {
never executed: }
0
4117 glFlush();
never executed (the execution status of this line is deduced): glFlush();
-
4118 }
never executed: }
0
4119} -
4120 -
4121/*! -
4122 Convenience function for specifying a drawing color to OpenGL. -
4123 Calls glColor4 (in RGBA mode) or glIndex (in color-index mode) -
4124 with the color \a c. Applies to this widgets GL context. -
4125 -
4126 \note This function is not supported on OpenGL/ES 2.0 systems. -
4127 -
4128 \sa qglClearColor(), QGLContext::currentContext(), QColor -
4129*/ -
4130 -
4131void QGLWidget::qglColor(const QColor& c) const -
4132{ -
4133#if !defined(QT_OPENGL_ES_2) -
4134#ifdef QT_OPENGL_ES -
4135 glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF()); -
4136#else -
4137 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4138 const QGLContext *ctx = QGLContext::currentContext();
never executed (the execution status of this line is deduced): const QGLContext *ctx = QGLContext::currentContext();
-
4139 if (ctx) {
never evaluated: ctx
0
4140 if (ctx->format().rgba())
never evaluated: ctx->format().rgba()
0
4141 glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
never executed: glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
0
4142 else if (!d->cmap.isEmpty()) { // QGLColormap in use?
never evaluated: !d->cmap.isEmpty()
0
4143 int i = d->cmap.find(c.rgb());
never executed (the execution status of this line is deduced): int i = d->cmap.find(c.rgb());
-
4144 if (i < 0)
never evaluated: i < 0
0
4145 i = d->cmap.findNearest(c.rgb());
never executed: i = d->cmap.findNearest(c.rgb());
0
4146 glIndexi(i);
never executed (the execution status of this line is deduced): glIndexi(i);
-
4147 } else
never executed: }
0
4148 glIndexi(ctx->colorIndex(c));
never executed: glIndexi(ctx->colorIndex(c));
0
4149 } -
4150#endif //QT_OPENGL_ES -
4151#else -
4152 Q_UNUSED(c); -
4153#endif //QT_OPENGL_ES_2 -
4154}
never executed: }
0
4155 -
4156/*! -
4157 Convenience function for specifying the clearing color to OpenGL. -
4158 Calls glClearColor (in RGBA mode) or glClearIndex (in color-index -
4159 mode) with the color \a c. Applies to this widgets GL context. -
4160 -
4161 \sa qglColor(), QGLContext::currentContext(), QColor -
4162*/ -
4163 -
4164void QGLWidget::qglClearColor(const QColor& c) const -
4165{ -
4166#ifdef QT_OPENGL_ES -
4167 glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); -
4168#else -
4169 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4170 const QGLContext *ctx = QGLContext::currentContext();
never executed (the execution status of this line is deduced): const QGLContext *ctx = QGLContext::currentContext();
-
4171 if (ctx) {
never evaluated: ctx
0
4172 if (ctx->format().rgba())
never evaluated: ctx->format().rgba()
0
4173 glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
never executed: glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
0
4174 else if (!d->cmap.isEmpty()) { // QGLColormap in use?
never evaluated: !d->cmap.isEmpty()
0
4175 int i = d->cmap.find(c.rgb());
never executed (the execution status of this line is deduced): int i = d->cmap.find(c.rgb());
-
4176 if (i < 0)
never evaluated: i < 0
0
4177 i = d->cmap.findNearest(c.rgb());
never executed: i = d->cmap.findNearest(c.rgb());
0
4178 glClearIndex(i);
never executed (the execution status of this line is deduced): glClearIndex(i);
-
4179 } else
never executed: }
0
4180 glClearIndex(ctx->colorIndex(c));
never executed: glClearIndex(ctx->colorIndex(c));
0
4181 } -
4182#endif -
4183}
never executed: }
0
4184 -
4185 -
4186/*! -
4187 Converts the image \a img into the unnamed format expected by -
4188 OpenGL functions such as glTexImage2D(). The returned image is not -
4189 usable as a QImage, but QImage::width(), QImage::height() and -
4190 QImage::bits() may be used with OpenGL. The GL format used is -
4191 \c GL_RGBA. -
4192 -
4193 \omit ### -
4194 -
4195 \l opengl/texture example -
4196 The following few lines are from the texture example. Most of the -
4197 code is irrelevant, so we just quote the relevant bits: -
4198 -
4199 \quotefromfile opengl/texture/gltexobj.cpp -
4200 \skipto tex1 -
4201 \printline tex1 -
4202 \printline gllogo.bmp -
4203 -
4204 We create \e tex1 (and another variable) for OpenGL, and load a real -
4205 image into \e buf. -
4206 -
4207 \skipto convertToGLFormat -
4208 \printline convertToGLFormat -
4209 -
4210 A few lines later, we convert \e buf into OpenGL format and store it -
4211 in \e tex1. -
4212 -
4213 \skipto glTexImage2D -
4214 \printline glTexImage2D -
4215 \printline tex1.bits -
4216 -
4217 Note the dimension restrictions for texture images as described in -
4218 the glTexImage2D() documentation. The width must be 2^m + 2*border -
4219 and the height 2^n + 2*border where m and n are integers and -
4220 border is either 0 or 1. -
4221 -
4222 Another function in the same example uses \e tex1 with OpenGL. -
4223 -
4224 \endomit -
4225*/ -
4226 -
4227QImage QGLWidget::convertToGLFormat(const QImage& img) -
4228{ -
4229 QImage res(img.size(), QImage::Format_ARGB32);
never executed (the execution status of this line is deduced): QImage res(img.size(), QImage::Format_ARGB32);
-
4230 convertToGLFormatHelper(res, img.convertToFormat(QImage::Format_ARGB32), GL_RGBA);
never executed (the execution status of this line is deduced): convertToGLFormatHelper(res, img.convertToFormat(QImage::Format_ARGB32), 0x1908);
-
4231 return res;
never executed: return res;
0
4232} -
4233 -
4234 -
4235/*! -
4236 \fn QGLColormap & QGLWidget::colormap() const -
4237 -
4238 Returns the colormap for this widget. -
4239 -
4240 Usually it is only top-level widgets that can have different -
4241 colormaps installed. Asking for the colormap of a child widget -
4242 will return the colormap for the child's top-level widget. -
4243 -
4244 If no colormap has been set for this widget, the QGLColormap -
4245 returned will be empty. -
4246 -
4247 \sa setColormap(), QGLColormap::isEmpty() -
4248*/ -
4249 -
4250/*! -
4251 \fn void QGLWidget::setColormap(const QGLColormap & cmap) -
4252 -
4253 Set the colormap for this widget to \a cmap. Usually it is only -
4254 top-level widgets that can have colormaps installed. -
4255 -
4256 \sa colormap() -
4257*/ -
4258 -
4259#ifndef QT_OPENGL_ES -
4260 -
4261static void qt_save_gl_state() -
4262{ -
4263 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
never executed (the execution status of this line is deduced): glPushClientAttrib(0xFFFFFFFF);
-
4264 glPushAttrib(GL_ALL_ATTRIB_BITS);
never executed (the execution status of this line is deduced): glPushAttrib(0x000FFFFF);
-
4265 glMatrixMode(GL_TEXTURE);
never executed (the execution status of this line is deduced): glMatrixMode(0x1702);
-
4266 glPushMatrix();
never executed (the execution status of this line is deduced): glPushMatrix();
-
4267 glLoadIdentity();
never executed (the execution status of this line is deduced): glLoadIdentity();
-
4268 glMatrixMode(GL_PROJECTION);
never executed (the execution status of this line is deduced): glMatrixMode(0x1701);
-
4269 glPushMatrix();
never executed (the execution status of this line is deduced): glPushMatrix();
-
4270 glMatrixMode(GL_MODELVIEW);
never executed (the execution status of this line is deduced): glMatrixMode(0x1700);
-
4271 glPushMatrix();
never executed (the execution status of this line is deduced): glPushMatrix();
-
4272 -
4273 glShadeModel(GL_FLAT);
never executed (the execution status of this line is deduced): glShadeModel(0x1D00);
-
4274 glDisable(GL_CULL_FACE);
never executed (the execution status of this line is deduced): glDisable(0x0B44);
-
4275 glDisable(GL_LIGHTING);
never executed (the execution status of this line is deduced): glDisable(0x0B50);
-
4276 glDisable(GL_STENCIL_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0B90);
-
4277 glDisable(GL_DEPTH_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0B71);
-
4278 glEnable(GL_BLEND);
never executed (the execution status of this line is deduced): glEnable(0x0BE2);
-
4279 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
never executed (the execution status of this line is deduced): glBlendFunc(0x1, 0x0303);
-
4280}
never executed: }
0
4281 -
4282static void qt_restore_gl_state() -
4283{ -
4284 glMatrixMode(GL_TEXTURE);
never executed (the execution status of this line is deduced): glMatrixMode(0x1702);
-
4285 glPopMatrix();
never executed (the execution status of this line is deduced): glPopMatrix();
-
4286 glMatrixMode(GL_PROJECTION);
never executed (the execution status of this line is deduced): glMatrixMode(0x1701);
-
4287 glPopMatrix();
never executed (the execution status of this line is deduced): glPopMatrix();
-
4288 glMatrixMode(GL_MODELVIEW);
never executed (the execution status of this line is deduced): glMatrixMode(0x1700);
-
4289 glPopMatrix();
never executed (the execution status of this line is deduced): glPopMatrix();
-
4290 glPopAttrib();
never executed (the execution status of this line is deduced): glPopAttrib();
-
4291 glPopClientAttrib();
never executed (the execution status of this line is deduced): glPopClientAttrib();
-
4292}
never executed: }
0
4293 -
4294static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, -
4295 const QFont &font) -
4296{ -
4297 GLfloat color[4];
never executed (the execution status of this line is deduced): GLfloat color[4];
-
4298 glGetFloatv(GL_CURRENT_COLOR, &color[0]);
never executed (the execution status of this line is deduced): glGetFloatv(0x0B00, &color[0]);
-
4299 -
4300 QColor col;
never executed (the execution status of this line is deduced): QColor col;
-
4301 col.setRgbF(color[0], color[1], color[2],color[3]);
never executed (the execution status of this line is deduced): col.setRgbF(color[0], color[1], color[2],color[3]);
-
4302 QPen old_pen = p->pen();
never executed (the execution status of this line is deduced): QPen old_pen = p->pen();
-
4303 QFont old_font = p->font();
never executed (the execution status of this line is deduced): QFont old_font = p->font();
-
4304 -
4305 p->setPen(col);
never executed (the execution status of this line is deduced): p->setPen(col);
-
4306 p->setFont(font);
never executed (the execution status of this line is deduced): p->setFont(font);
-
4307 p->drawText(x, y, str);
never executed (the execution status of this line is deduced): p->drawText(x, y, str);
-
4308 -
4309 p->setPen(old_pen);
never executed (the execution status of this line is deduced): p->setPen(old_pen);
-
4310 p->setFont(old_font);
never executed (the execution status of this line is deduced): p->setFont(old_font);
-
4311}
never executed: }
0
4312 -
4313#endif // !QT_OPENGL_ES -
4314 -
4315/*! -
4316 Renders the string \a str into the GL context of this widget. -
4317 -
4318 \a x and \a y are specified in window coordinates, with the origin -
4319 in the upper left-hand corner of the window. If \a font is not -
4320 specified, the currently set application font will be used to -
4321 render the string. To change the color of the rendered text you can -
4322 use the glColor() call (or the qglColor() convenience function), -
4323 just before the renderText() call. -
4324 -
4325 \note This function clears the stencil buffer. -
4326 -
4327 \note This function is not supported on OpenGL/ES systems. -
4328 -
4329 \note This function temporarily disables depth-testing when the -
4330 text is drawn. -
4331 -
4332 \note This function can only be used inside a -
4333 QPainter::beginNativePainting()/QPainter::endNativePainting() block -
4334 if a painter is active on the QGLWidget. -
4335 -
4336 \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. -
4337*/ -
4338 -
4339void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font) -
4340{ -
4341#ifndef QT_OPENGL_ES -
4342 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4343 if (str.isEmpty() || !isValid())
never evaluated: str.isEmpty()
never evaluated: !isValid()
0
4344 return;
never executed: return;
0
4345 -
4346 GLint view[4];
never executed (the execution status of this line is deduced): GLint view[4];
-
4347 bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): bool use_scissor_testing = glIsEnabled(0x0C11);
-
4348 if (!use_scissor_testing)
never evaluated: !use_scissor_testing
0
4349 glGetIntegerv(GL_VIEWPORT, &view[0]);
never executed: glGetIntegerv(0x0BA2, &view[0]);
0
4350 int width = d->glcx->device()->width();
never executed (the execution status of this line is deduced): int width = d->glcx->device()->width();
-
4351 int height = d->glcx->device()->height();
never executed (the execution status of this line is deduced): int height = d->glcx->device()->height();
-
4352 bool auto_swap = autoBufferSwap();
never executed (the execution status of this line is deduced): bool auto_swap = autoBufferSwap();
-
4353 -
4354 QPaintEngine *engine = paintEngine();
never executed (the execution status of this line is deduced): QPaintEngine *engine = paintEngine();
-
4355 -
4356 qt_save_gl_state();
never executed (the execution status of this line is deduced): qt_save_gl_state();
-
4357 -
4358 QPainter *p;
never executed (the execution status of this line is deduced): QPainter *p;
-
4359 bool reuse_painter = false;
never executed (the execution status of this line is deduced): bool reuse_painter = false;
-
4360 if (engine->isActive()) {
never evaluated: engine->isActive()
0
4361 reuse_painter = true;
never executed (the execution status of this line is deduced): reuse_painter = true;
-
4362 p = engine->painter();
never executed (the execution status of this line is deduced): p = engine->painter();
-
4363 -
4364 glDisable(GL_DEPTH_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0B71);
-
4365 glViewport(0, 0, width, height);
never executed (the execution status of this line is deduced): glViewport(0, 0, width, height);
-
4366 glMatrixMode(GL_PROJECTION);
never executed (the execution status of this line is deduced): glMatrixMode(0x1701);
-
4367 glLoadIdentity();
never executed (the execution status of this line is deduced): glLoadIdentity();
-
4368 glOrtho(0, width, height, 0, 0, 1);
never executed (the execution status of this line is deduced): glOrtho(0, width, height, 0, 0, 1);
-
4369 glMatrixMode(GL_MODELVIEW);
never executed (the execution status of this line is deduced): glMatrixMode(0x1700);
-
4370 -
4371 glLoadIdentity();
never executed (the execution status of this line is deduced): glLoadIdentity();
-
4372 } else {
never executed: }
0
4373 setAutoBufferSwap(false);
never executed (the execution status of this line is deduced): setAutoBufferSwap(false);
-
4374 // disable glClear() as a result of QPainter::begin() -
4375 d->disable_clear_on_painter_begin = true;
never executed (the execution status of this line is deduced): d->disable_clear_on_painter_begin = true;
-
4376 p = new QPainter(this);
never executed (the execution status of this line is deduced): p = new QPainter(this);
-
4377 }
never executed: }
0
4378 -
4379 QRect viewport(view[0], view[1], view[2], view[3]);
never executed (the execution status of this line is deduced): QRect viewport(view[0], view[1], view[2], view[3]);
-
4380 if (!use_scissor_testing && viewport != rect()) {
never evaluated: !use_scissor_testing
never evaluated: viewport != rect()
0
4381 // if the user hasn't set a scissor box, we set one that -
4382 // covers the current viewport -
4383 glScissor(view[0], view[1], view[2], view[3]);
never executed (the execution status of this line is deduced): glScissor(view[0], view[1], view[2], view[3]);
-
4384 glEnable(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): glEnable(0x0C11);
-
4385 } else if (use_scissor_testing) {
never executed: }
never evaluated: use_scissor_testing
0
4386 // use the scissor box set by the user -
4387 glEnable(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): glEnable(0x0C11);
-
4388 }
never executed: }
0
4389 -
4390 qt_gl_draw_text(p, x, y, str, font);
never executed (the execution status of this line is deduced): qt_gl_draw_text(p, x, y, str, font);
-
4391 -
4392 if (!reuse_painter) {
never evaluated: !reuse_painter
0
4393 p->end();
never executed (the execution status of this line is deduced): p->end();
-
4394 delete p;
never executed (the execution status of this line is deduced): delete p;
-
4395 setAutoBufferSwap(auto_swap);
never executed (the execution status of this line is deduced): setAutoBufferSwap(auto_swap);
-
4396 d->disable_clear_on_painter_begin = false;
never executed (the execution status of this line is deduced): d->disable_clear_on_painter_begin = false;
-
4397 }
never executed: }
0
4398 -
4399 qt_restore_gl_state();
never executed (the execution status of this line is deduced): qt_restore_gl_state();
-
4400 -
4401#else // QT_OPENGL_ES -
4402 Q_UNUSED(x); -
4403 Q_UNUSED(y); -
4404 Q_UNUSED(str); -
4405 Q_UNUSED(font); -
4406 qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); -
4407#endif -
4408}
never executed: }
0
4409 -
4410/*! \overload -
4411 -
4412 \a x, \a y and \a z are specified in scene or object coordinates -
4413 relative to the currently set projection and model matrices. This -
4414 can be useful if you want to annotate models with text labels and -
4415 have the labels move with the model as it is rotated etc. -
4416 -
4417 \note This function is not supported on OpenGL/ES systems. -
4418 -
4419 \note If depth testing is enabled before this function is called, -
4420 then the drawn text will be depth-tested against the models that -
4421 have already been drawn in the scene. Use \c{glDisable(GL_DEPTH_TEST)} -
4422 before calling this function to annotate the models without -
4423 depth-testing the text. -
4424 -
4425 \note This function can only be used inside a -
4426 QPainter::beginNativePainting()/QPainter::endNativePainting() block -
4427 if a painter is active on the QGLWidget. -
4428 -
4429 \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. -
4430*/ -
4431void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font) -
4432{ -
4433#ifndef QT_OPENGL_ES -
4434 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4435 if (str.isEmpty() || !isValid())
never evaluated: str.isEmpty()
never evaluated: !isValid()
0
4436 return;
never executed: return;
0
4437 -
4438 bool auto_swap = autoBufferSwap();
never executed (the execution status of this line is deduced): bool auto_swap = autoBufferSwap();
-
4439 -
4440 int width = d->glcx->device()->width();
never executed (the execution status of this line is deduced): int width = d->glcx->device()->width();
-
4441 int height = d->glcx->device()->height();
never executed (the execution status of this line is deduced): int height = d->glcx->device()->height();
-
4442 GLdouble model[4][4], proj[4][4];
never executed (the execution status of this line is deduced): GLdouble model[4][4], proj[4][4];
-
4443 GLint view[4];
never executed (the execution status of this line is deduced): GLint view[4];
-
4444 glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]);
never executed (the execution status of this line is deduced): glGetDoublev(0x0BA6, &model[0][0]);
-
4445 glGetDoublev(GL_PROJECTION_MATRIX, &proj[0][0]);
never executed (the execution status of this line is deduced): glGetDoublev(0x0BA7, &proj[0][0]);
-
4446 glGetIntegerv(GL_VIEWPORT, &view[0]);
never executed (the execution status of this line is deduced): glGetIntegerv(0x0BA2, &view[0]);
-
4447 GLdouble win_x = 0, win_y = 0, win_z = 0;
never executed (the execution status of this line is deduced): GLdouble win_x = 0, win_y = 0, win_z = 0;
-
4448 qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0],
never executed (the execution status of this line is deduced): qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0],
-
4449 &win_x, &win_y, &win_z);
never executed (the execution status of this line is deduced): &win_x, &win_y, &win_z);
-
4450 win_y = height - win_y; // y is inverted
never executed (the execution status of this line is deduced): win_y = height - win_y;
-
4451 -
4452 QPaintEngine *engine = paintEngine();
never executed (the execution status of this line is deduced): QPaintEngine *engine = paintEngine();
-
4453 -
4454 QPainter *p;
never executed (the execution status of this line is deduced): QPainter *p;
-
4455 bool reuse_painter = false;
never executed (the execution status of this line is deduced): bool reuse_painter = false;
-
4456 bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST);
never executed (the execution status of this line is deduced): bool use_depth_testing = glIsEnabled(0x0B71);
-
4457 bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): bool use_scissor_testing = glIsEnabled(0x0C11);
-
4458 -
4459 qt_save_gl_state();
never executed (the execution status of this line is deduced): qt_save_gl_state();
-
4460 -
4461 if (engine->isActive()) {
never evaluated: engine->isActive()
0
4462 reuse_painter = true;
never executed (the execution status of this line is deduced): reuse_painter = true;
-
4463 p = engine->painter();
never executed (the execution status of this line is deduced): p = engine->painter();
-
4464 } else {
never executed: }
0
4465 setAutoBufferSwap(false);
never executed (the execution status of this line is deduced): setAutoBufferSwap(false);
-
4466 // disable glClear() as a result of QPainter::begin() -
4467 d->disable_clear_on_painter_begin = true;
never executed (the execution status of this line is deduced): d->disable_clear_on_painter_begin = true;
-
4468 p = new QPainter(this);
never executed (the execution status of this line is deduced): p = new QPainter(this);
-
4469 }
never executed: }
0
4470 -
4471 QRect viewport(view[0], view[1], view[2], view[3]);
never executed (the execution status of this line is deduced): QRect viewport(view[0], view[1], view[2], view[3]);
-
4472 if (!use_scissor_testing && viewport != rect()) {
never evaluated: !use_scissor_testing
never evaluated: viewport != rect()
0
4473 glScissor(view[0], view[1], view[2], view[3]);
never executed (the execution status of this line is deduced): glScissor(view[0], view[1], view[2], view[3]);
-
4474 glEnable(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): glEnable(0x0C11);
-
4475 } else if (use_scissor_testing) {
never executed: }
never evaluated: use_scissor_testing
0
4476 glEnable(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): glEnable(0x0C11);
-
4477 }
never executed: }
0
4478 glMatrixMode(GL_PROJECTION);
never executed (the execution status of this line is deduced): glMatrixMode(0x1701);
-
4479 glLoadIdentity();
never executed (the execution status of this line is deduced): glLoadIdentity();
-
4480 glViewport(0, 0, width, height);
never executed (the execution status of this line is deduced): glViewport(0, 0, width, height);
-
4481 glOrtho(0, width, height, 0, 0, 1);
never executed (the execution status of this line is deduced): glOrtho(0, width, height, 0, 0, 1);
-
4482 glMatrixMode(GL_MODELVIEW);
never executed (the execution status of this line is deduced): glMatrixMode(0x1700);
-
4483 glLoadIdentity();
never executed (the execution status of this line is deduced): glLoadIdentity();
-
4484 glAlphaFunc(GL_GREATER, 0.0);
never executed (the execution status of this line is deduced): glAlphaFunc(0x0204, 0.0);
-
4485 glEnable(GL_ALPHA_TEST);
never executed (the execution status of this line is deduced): glEnable(0x0BC0);
-
4486 if (use_depth_testing)
never evaluated: use_depth_testing
0
4487 glEnable(GL_DEPTH_TEST);
never executed: glEnable(0x0B71);
0
4488 glTranslated(0, 0, -win_z);
never executed (the execution status of this line is deduced): glTranslated(0, 0, -win_z);
-
4489 qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font);
never executed (the execution status of this line is deduced): qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font);
-
4490 -
4491 if (!reuse_painter) {
never evaluated: !reuse_painter
0
4492 p->end();
never executed (the execution status of this line is deduced): p->end();
-
4493 delete p;
never executed (the execution status of this line is deduced): delete p;
-
4494 setAutoBufferSwap(auto_swap);
never executed (the execution status of this line is deduced): setAutoBufferSwap(auto_swap);
-
4495 d->disable_clear_on_painter_begin = false;
never executed (the execution status of this line is deduced): d->disable_clear_on_painter_begin = false;
-
4496 }
never executed: }
0
4497 -
4498 qt_restore_gl_state();
never executed (the execution status of this line is deduced): qt_restore_gl_state();
-
4499 -
4500#else // QT_OPENGL_ES -
4501 Q_UNUSED(x); -
4502 Q_UNUSED(y); -
4503 Q_UNUSED(z); -
4504 Q_UNUSED(str); -
4505 Q_UNUSED(font); -
4506 qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); -
4507#endif -
4508}
never executed: }
0
4509 -
4510QGLFormat QGLWidget::format() const -
4511{ -
4512 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4513 return d->glcx->format();
never executed: return d->glcx->format();
0
4514} -
4515 -
4516QGLContext *QGLWidget::context() const -
4517{ -
4518 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4519 return d->glcx;
never executed: return d->glcx;
0
4520} -
4521 -
4522bool QGLWidget::doubleBuffer() const -
4523{ -
4524 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4525 return d->glcx->d_ptr->glFormat.testOption(QGL::DoubleBuffer);
never executed: return d->glcx->d_ptr->glFormat.testOption(QGL::DoubleBuffer);
0
4526} -
4527 -
4528void QGLWidget::setAutoBufferSwap(bool on) -
4529{ -
4530 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4531 d->autoSwap = on;
never executed (the execution status of this line is deduced): d->autoSwap = on;
-
4532}
never executed: }
0
4533 -
4534bool QGLWidget::autoBufferSwap() const -
4535{ -
4536 Q_D(const QGLWidget);
never executed (the execution status of this line is deduced): const QGLWidgetPrivate * const d = d_func();
-
4537 return d->autoSwap;
never executed: return d->autoSwap;
0
4538} -
4539 -
4540/*! -
4541 Calls QGLContext:::bindTexture(\a image, \a target, \a format) on the currently -
4542 set context. -
4543 -
4544 \sa deleteTexture() -
4545*/ -
4546GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format) -
4547{ -
4548 if (image.isNull())
never evaluated: image.isNull()
0
4549 return 0;
never executed: return 0;
0
4550 -
4551 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4552 return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption);
never executed: return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption);
0
4553} -
4554 -
4555/*! -
4556 \overload -
4557 \since 4.6 -
4558 -
4559 The binding \a options are a set of options used to decide how to -
4560 bind the texture to the context. -
4561 */ -
4562GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) -
4563{ -
4564 if (image.isNull())
never evaluated: image.isNull()
0
4565 return 0;
never executed: return 0;
0
4566 -
4567 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4568 return d->glcx->bindTexture(image, target, format, options);
never executed: return d->glcx->bindTexture(image, target, format, options);
0
4569} -
4570 -
4571 -
4572/*! -
4573 Calls QGLContext:::bindTexture(\a pixmap, \a target, \a format) on the currently -
4574 set context. -
4575 -
4576 \sa deleteTexture() -
4577*/ -
4578GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) -
4579{ -
4580 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
4581 return 0;
never executed: return 0;
0
4582 -
4583 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4584 return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption);
never executed: return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption);
0
4585} -
4586 -
4587/*! -
4588 \overload -
4589 \since 4.6 -
4590 -
4591 Generates and binds a 2D GL texture to the current context, based -
4592 on \a pixmap. The generated texture id is returned and can be used in -
4593 -
4594 The binding \a options are a set of options used to decide how to -
4595 bind the texture to the context. -
4596 */ -
4597GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, -
4598 QGLContext::BindOptions options) -
4599{ -
4600 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4601 return d->glcx->bindTexture(pixmap, target, format, options);
never executed: return d->glcx->bindTexture(pixmap, target, format, options);
0
4602} -
4603 -
4604/*! \overload -
4605 -
4606 Calls QGLContext::bindTexture(\a fileName) on the currently set context. -
4607 -
4608 \sa deleteTexture() -
4609*/ -
4610GLuint QGLWidget::bindTexture(const QString &fileName) -
4611{ -
4612 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4613 return d->glcx->bindTexture(fileName);
never executed: return d->glcx->bindTexture(fileName);
0
4614} -
4615 -
4616/*! -
4617 Calls QGLContext::deleteTexture(\a id) on the currently set -
4618 context. -
4619 -
4620 \sa bindTexture() -
4621*/ -
4622void QGLWidget::deleteTexture(GLuint id) -
4623{ -
4624 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4625 d->glcx->deleteTexture(id);
never executed (the execution status of this line is deduced): d->glcx->deleteTexture(id);
-
4626}
never executed: }
0
4627 -
4628/*! -
4629 \since 4.4 -
4630 -
4631 Calls the corresponding QGLContext::drawTexture() with -
4632 \a target, \a textureId, and \a textureTarget for this -
4633 widget's context. -
4634*/ -
4635void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -
4636{ -
4637 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4638 d->glcx->drawTexture(target, textureId, textureTarget);
never executed (the execution status of this line is deduced): d->glcx->drawTexture(target, textureId, textureTarget);
-
4639}
never executed: }
0
4640 -
4641/*! -
4642 \since 4.4 -
4643 -
4644 Calls the corresponding QGLContext::drawTexture() with -
4645 \a point, \a textureId, and \a textureTarget for this -
4646 widget's context. -
4647*/ -
4648void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -
4649{ -
4650 Q_D(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidgetPrivate * const d = d_func();
-
4651 d->glcx->drawTexture(point, textureId, textureTarget);
never executed (the execution status of this line is deduced): d->glcx->drawTexture(point, textureId, textureTarget);
-
4652}
never executed: }
0
4653 -
4654Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_gl_2_engine)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
4655 -
4656Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() -
4657{ -
4658 return qt_gl_2_engine()->engine();
never executed: return qt_gl_2_engine()->engine();
0
4659} -
4660 -
4661/*! -
4662 \internal -
4663 -
4664 Returns the GL widget's paint engine. -
4665*/ -
4666QPaintEngine *QGLWidget::paintEngine() const -
4667{ -
4668 return qt_qgl_paint_engine();
never executed: return qt_qgl_paint_engine();
0
4669} -
4670 -
4671typedef const GLubyte * (QGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint); -
4672 -
4673#ifndef GL_NUM_EXTENSIONS -
4674#define GL_NUM_EXTENSIONS 0x821D -
4675#endif -
4676 -
4677QGLExtensionMatcher::QGLExtensionMatcher(const char *str) -
4678{ -
4679 init(str);
never executed (the execution status of this line is deduced): init(str);
-
4680}
never executed: }
0
4681 -
4682QGLExtensionMatcher::QGLExtensionMatcher() -
4683{ -
4684 const char *extensionStr = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
never executed (the execution status of this line is deduced): const char *extensionStr = reinterpret_cast<const char *>(glGetString(0x1F03));
-
4685 -
4686 if (extensionStr) {
never evaluated: extensionStr
0
4687 init(extensionStr);
never executed (the execution status of this line is deduced): init(extensionStr);
-
4688 } else {
never executed: }
0
4689 // clear error state -
4690 while (glGetError()) {}
never executed: }
never evaluated: glGetError()
0
4691 -
4692 const QGLContext *ctx = QGLContext::currentContext();
never executed (the execution status of this line is deduced): const QGLContext *ctx = QGLContext::currentContext();
-
4693 if (ctx) {
never evaluated: ctx
0
4694 qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress(QLatin1String("glGetStringi"));
never executed (the execution status of this line is deduced): qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress(QLatin1String("glGetStringi"));
-
4695 -
4696 GLint numExtensions;
never executed (the execution status of this line is deduced): GLint numExtensions;
-
4697 glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
never executed (the execution status of this line is deduced): glGetIntegerv(0x821D, &numExtensions);
-
4698 -
4699 for (int i = 0; i < numExtensions; ++i) {
never evaluated: i < numExtensions
0
4700 const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
never executed (the execution status of this line is deduced): const char *str = reinterpret_cast<const char *>(glGetStringi(0x1F03, i));
-
4701 -
4702 m_offsets << m_extensions.size();
never executed (the execution status of this line is deduced): m_offsets << m_extensions.size();
-
4703 -
4704 while (*str != 0)
never evaluated: *str != 0
0
4705 m_extensions.append(*str++);
never executed: m_extensions.append(*str++);
0
4706 m_extensions.append(' ');
never executed (the execution status of this line is deduced): m_extensions.append(' ');
-
4707 }
never executed: }
0
4708 }
never executed: }
0
4709 }
never executed: }
0
4710} -
4711 -
4712void QGLExtensionMatcher::init(const char *str) -
4713{ -
4714 m_extensions = str;
never executed (the execution status of this line is deduced): m_extensions = str;
-
4715 -
4716 // make sure extension string ends with a space -
4717 if (!m_extensions.endsWith(' '))
never evaluated: !m_extensions.endsWith(' ')
0
4718 m_extensions.append(' ');
never executed: m_extensions.append(' ');
0
4719 -
4720 int index = 0;
never executed (the execution status of this line is deduced): int index = 0;
-
4721 int next = 0;
never executed (the execution status of this line is deduced): int next = 0;
-
4722 while ((next = m_extensions.indexOf(' ', index)) >= 0) {
never evaluated: (next = m_extensions.indexOf(' ', index)) >= 0
0
4723 m_offsets << index;
never executed (the execution status of this line is deduced): m_offsets << index;
-
4724 index = next + 1;
never executed (the execution status of this line is deduced): index = next + 1;
-
4725 }
never executed: }
0
4726}
never executed: }
0
4727 -
4728// ####TODO Properly #ifdef this class to use #define symbols actually defined -
4729// by OpenGL/ES includes -
4730#ifndef GL_FRAMEBUFFER_SRGB_CAPABLE_EXT -
4731#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -
4732#endif -
4733 -
4734/* -
4735 Returns the GL extensions for the current context. -
4736*/ -
4737QGLExtensions::Extensions QGLExtensions::currentContextExtensions() -
4738{ -
4739 QGLExtensionMatcher extensions;
never executed (the execution status of this line is deduced): QGLExtensionMatcher extensions;
-
4740 Extensions glExtensions;
never executed (the execution status of this line is deduced): Extensions glExtensions;
-
4741 -
4742 if (extensions.match("GL_ARB_texture_rectangle"))
never evaluated: extensions.match("GL_ARB_texture_rectangle")
0
4743 glExtensions |= TextureRectangle;
never executed: glExtensions |= TextureRectangle;
0
4744 if (extensions.match("GL_ARB_multisample"))
never evaluated: extensions.match("GL_ARB_multisample")
0
4745 glExtensions |= SampleBuffers;
never executed: glExtensions |= SampleBuffers;
0
4746 if (extensions.match("GL_SGIS_generate_mipmap"))
never evaluated: extensions.match("GL_SGIS_generate_mipmap")
0
4747 glExtensions |= GenerateMipmap;
never executed: glExtensions |= GenerateMipmap;
0
4748 if (extensions.match("GL_ARB_texture_compression"))
never evaluated: extensions.match("GL_ARB_texture_compression")
0
4749 glExtensions |= TextureCompression;
never executed: glExtensions |= TextureCompression;
0
4750 if (extensions.match("GL_EXT_texture_compression_s3tc"))
never evaluated: extensions.match("GL_EXT_texture_compression_s3tc")
0
4751 glExtensions |= DDSTextureCompression;
never executed: glExtensions |= DDSTextureCompression;
0
4752 if (extensions.match("GL_OES_compressed_ETC1_RGB8_texture"))
never evaluated: extensions.match("GL_OES_compressed_ETC1_RGB8_texture")
0
4753 glExtensions |= ETC1TextureCompression;
never executed: glExtensions |= ETC1TextureCompression;
0
4754 if (extensions.match("GL_IMG_texture_compression_pvrtc"))
never evaluated: extensions.match("GL_IMG_texture_compression_pvrtc")
0
4755 glExtensions |= PVRTCTextureCompression;
never executed: glExtensions |= PVRTCTextureCompression;
0
4756 if (extensions.match("GL_ARB_fragment_program"))
never evaluated: extensions.match("GL_ARB_fragment_program")
0
4757 glExtensions |= FragmentProgram;
never executed: glExtensions |= FragmentProgram;
0
4758 if (extensions.match("GL_ARB_fragment_shader"))
never evaluated: extensions.match("GL_ARB_fragment_shader")
0
4759 glExtensions |= FragmentShader;
never executed: glExtensions |= FragmentShader;
0
4760 if (extensions.match("GL_ARB_shader_objects"))
never evaluated: extensions.match("GL_ARB_shader_objects")
0
4761 glExtensions |= FragmentShader;
never executed: glExtensions |= FragmentShader;
0
4762 if (extensions.match("GL_ARB_texture_mirrored_repeat"))
never evaluated: extensions.match("GL_ARB_texture_mirrored_repeat")
0
4763 glExtensions |= MirroredRepeat;
never executed: glExtensions |= MirroredRepeat;
0
4764 if (extensions.match("GL_EXT_framebuffer_object"))
never evaluated: extensions.match("GL_EXT_framebuffer_object")
0
4765 glExtensions |= FramebufferObject;
never executed: glExtensions |= FramebufferObject;
0
4766 if (extensions.match("GL_EXT_stencil_two_side"))
never evaluated: extensions.match("GL_EXT_stencil_two_side")
0
4767 glExtensions |= StencilTwoSide;
never executed: glExtensions |= StencilTwoSide;
0
4768 if (extensions.match("GL_EXT_stencil_wrap"))
never evaluated: extensions.match("GL_EXT_stencil_wrap")
0
4769 glExtensions |= StencilWrap;
never executed: glExtensions |= StencilWrap;
0
4770 if (extensions.match("GL_EXT_packed_depth_stencil"))
never evaluated: extensions.match("GL_EXT_packed_depth_stencil")
0
4771 glExtensions |= PackedDepthStencil;
never executed: glExtensions |= PackedDepthStencil;
0
4772 if (extensions.match("GL_NV_float_buffer"))
never evaluated: extensions.match("GL_NV_float_buffer")
0
4773 glExtensions |= NVFloatBuffer;
never executed: glExtensions |= NVFloatBuffer;
0
4774 if (extensions.match("GL_ARB_pixel_buffer_object"))
never evaluated: extensions.match("GL_ARB_pixel_buffer_object")
0
4775 glExtensions |= PixelBufferObject;
never executed: glExtensions |= PixelBufferObject;
0
4776 if (extensions.match("GL_IMG_texture_format_BGRA8888"))
never evaluated: extensions.match("GL_IMG_texture_format_BGRA8888")
0
4777 glExtensions |= BGRATextureFormat;
never executed: glExtensions |= BGRATextureFormat;
0
4778#if defined(QT_OPENGL_ES_2) -
4779 glExtensions |= FramebufferObject; -
4780 glExtensions |= GenerateMipmap; -
4781 glExtensions |= FragmentShader; -
4782#endif -
4783#if defined(QT_OPENGL_ES) -
4784 if (extensions.match("GL_OES_packed_depth_stencil")) -
4785 glExtensions |= PackedDepthStencil; -
4786 if (extensions.match("GL_OES_element_index_uint")) -
4787 glExtensions |= ElementIndexUint; -
4788 if (extensions.match("GL_OES_depth24")) -
4789 glExtensions |= Depth24; -
4790#else -
4791 glExtensions |= ElementIndexUint;
never executed (the execution status of this line is deduced): glExtensions |= ElementIndexUint;
-
4792#endif -
4793 if (extensions.match("GL_ARB_framebuffer_object")) {
never evaluated: extensions.match("GL_ARB_framebuffer_object")
0
4794 // ARB_framebuffer_object also includes EXT_framebuffer_blit. -
4795 glExtensions |= FramebufferObject;
never executed (the execution status of this line is deduced): glExtensions |= FramebufferObject;
-
4796 glExtensions |= FramebufferBlit;
never executed (the execution status of this line is deduced): glExtensions |= FramebufferBlit;
-
4797 }
never executed: }
0
4798 -
4799 if (extensions.match("GL_EXT_framebuffer_blit"))
never evaluated: extensions.match("GL_EXT_framebuffer_blit")
0
4800 glExtensions |= FramebufferBlit;
never executed: glExtensions |= FramebufferBlit;
0
4801 -
4802 if (extensions.match("GL_ARB_texture_non_power_of_two"))
never evaluated: extensions.match("GL_ARB_texture_non_power_of_two")
0
4803 glExtensions |= NPOTTextures;
never executed: glExtensions |= NPOTTextures;
0
4804 -
4805 if (extensions.match("GL_EXT_bgra"))
never evaluated: extensions.match("GL_EXT_bgra")
0
4806 glExtensions |= BGRATextureFormat;
never executed: glExtensions |= BGRATextureFormat;
0
4807 -
4808#if !defined(QT_OPENGL_ES) -
4809 { -
4810 GLboolean srgbCapableFramebuffers = false;
never executed (the execution status of this line is deduced): GLboolean srgbCapableFramebuffers = false;
-
4811 glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
never executed (the execution status of this line is deduced): glGetBooleanv(0x8DBA, &srgbCapableFramebuffers);
-
4812 if (srgbCapableFramebuffers)
never evaluated: srgbCapableFramebuffers
0
4813 glExtensions |= SRGBFrameBuffer;
never executed: glExtensions |= SRGBFrameBuffer;
0
4814 } -
4815#endif -
4816 -
4817 return glExtensions;
never executed: return glExtensions;
0
4818} -
4819 -
4820 -
4821class QGLDefaultExtensions -
4822{ -
4823public: -
4824 QGLDefaultExtensions() { -
4825 QGLTemporaryContext tempContext;
never executed (the execution status of this line is deduced): QGLTemporaryContext tempContext;
-
4826 extensions = QGLExtensions::currentContextExtensions();
never executed (the execution status of this line is deduced): extensions = QGLExtensions::currentContextExtensions();
-
4827 }
never executed: }
0
4828 -
4829 QGLExtensions::Extensions extensions; -
4830}; -
4831 -
4832Q_GLOBAL_STATIC(QGLDefaultExtensions, qtDefaultExtensions)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
4833 -
4834/* -
4835 Returns the GL extensions for the current QGLContext. If there is no -
4836 current QGLContext, a default context will be created and the extensions -
4837 for that context will be returned instead. -
4838*/ -
4839QGLExtensions::Extensions QGLExtensions::glExtensions() -
4840{ -
4841 Extensions extensionFlags = 0;
never executed (the execution status of this line is deduced): Extensions extensionFlags = 0;
-
4842 QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
-
4843 -
4844 if (currentCtx && currentCtx->d_func()->extension_flags_cached)
never evaluated: currentCtx
never evaluated: currentCtx->d_func()->extension_flags_cached
0
4845 return currentCtx->d_func()->extension_flags;
never executed: return currentCtx->d_func()->extension_flags;
0
4846 -
4847 if (!currentCtx) {
never evaluated: !currentCtx
0
4848 extensionFlags = qtDefaultExtensions()->extensions;
never executed (the execution status of this line is deduced): extensionFlags = qtDefaultExtensions()->extensions;
-
4849 } else {
never executed: }
0
4850 extensionFlags = currentContextExtensions();
never executed (the execution status of this line is deduced): extensionFlags = currentContextExtensions();
-
4851 currentCtx->d_func()->extension_flags_cached = true;
never executed (the execution status of this line is deduced): currentCtx->d_func()->extension_flags_cached = true;
-
4852 currentCtx->d_func()->extension_flags = extensionFlags;
never executed (the execution status of this line is deduced): currentCtx->d_func()->extension_flags = extensionFlags;
-
4853 }
never executed: }
0
4854 return extensionFlags;
never executed: return extensionFlags;
0
4855} -
4856 -
4857/* -
4858 This is the shared initialization for all platforms. Called from QGLWidgetPrivate::init() -
4859*/ -
4860void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWidget) -
4861{ -
4862 Q_Q(QGLWidget);
never executed (the execution status of this line is deduced): QGLWidget * const q = q_func();
-
4863 -
4864 glDevice.setWidget(q);
never executed (the execution status of this line is deduced): glDevice.setWidget(q);
-
4865 -
4866 glcx = 0;
never executed (the execution status of this line is deduced): glcx = 0;
-
4867 autoSwap = true;
never executed (the execution status of this line is deduced): autoSwap = true;
-
4868 -
4869 if (context && !context->device())
never evaluated: context
never evaluated: !context->device()
0
4870 context->setDevice(q);
never executed: context->setDevice(q);
0
4871 q->setContext(context, shareWidget ? shareWidget->context() : 0);
never executed (the execution status of this line is deduced): q->setContext(context, shareWidget ? shareWidget->context() : 0);
-
4872 -
4873 if (!glcx)
never evaluated: !glcx
0
4874 glcx = new QGLContext(QGLFormat::defaultFormat(), q);
never executed: glcx = new QGLContext(QGLFormat::defaultFormat(), q);
0
4875}
never executed: }
0
4876 -
4877Q_GLOBAL_STATIC(QString, qt_gl_lib_name)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
4878 -
4879void qt_set_gl_library_name(const QString& name) -
4880{ -
4881 qt_gl_lib_name()->operator=(name);
never executed (the execution status of this line is deduced): qt_gl_lib_name()->operator=(name);
-
4882}
never executed: }
0
4883 -
4884const QString qt_gl_library_name() -
4885{ -
4886 if (qt_gl_lib_name()->isNull()) {
never evaluated: qt_gl_lib_name()->isNull()
0
4887# if defined(QT_OPENGL_ES_2) -
4888 return QLatin1String("GLESv2"); -
4889# else -
4890 return QLatin1String("GL");
never executed: return QLatin1String("GL");
0
4891# endif -
4892 } -
4893 return *qt_gl_lib_name();
never executed: return *qt_gl_lib_name();
0
4894} -
4895 -
4896void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *share) { -
4897 Q_ASSERT(context && share);
never executed (the execution status of this line is deduced): qt_noop();
-
4898 if (context->d_ptr->group == share->d_ptr->group)
never evaluated: context->d_ptr->group == share->d_ptr->group
0
4899 return;
never executed: return;
0
4900 -
4901 // Make sure 'context' is not already shared with another group of contexts. -
4902 Q_ASSERT(context->d_ptr->group->m_refs.load() == 1);
never executed (the execution status of this line is deduced): qt_noop();
-
4903 -
4904 // Free 'context' group resources and make it use the same resources as 'share'. -
4905 QGLContextGroup *group = share->d_ptr->group;
never executed (the execution status of this line is deduced): QGLContextGroup *group = share->d_ptr->group;
-
4906 delete context->d_ptr->group;
never executed (the execution status of this line is deduced): delete context->d_ptr->group;
-
4907 context->d_ptr->group = group;
never executed (the execution status of this line is deduced): context->d_ptr->group = group;
-
4908 group->m_refs.ref();
never executed (the execution status of this line is deduced): group->m_refs.ref();
-
4909 -
4910 // Maintain a list of all the contexts in each group of sharing contexts. -
4911 // The list is empty if the "share" context wasn't sharing already. -
4912 if (group->m_shares.isEmpty())
never evaluated: group->m_shares.isEmpty()
0
4913 group->m_shares.append(share);
never executed: group->m_shares.append(share);
0
4914 group->m_shares.append(context);
never executed (the execution status of this line is deduced): group->m_shares.append(context);
-
4915}
never executed: }
0
4916 -
4917void QGLContextGroup::removeShare(const QGLContext *context) { -
4918 // Remove the context from the group. -
4919 QGLContextGroup *group = context->d_ptr->group;
never executed (the execution status of this line is deduced): QGLContextGroup *group = context->d_ptr->group;
-
4920 if (group->m_shares.isEmpty())
never evaluated: group->m_shares.isEmpty()
0
4921 return;
never executed: return;
0
4922 group->m_shares.removeAll(context);
never executed (the execution status of this line is deduced): group->m_shares.removeAll(context);
-
4923 -
4924 // Update context group representative. -
4925 Q_ASSERT(group->m_shares.size() != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
4926 if (group->m_context == context)
never evaluated: group->m_context == context
0
4927 group->m_context = group->m_shares[0];
never executed: group->m_context = group->m_shares[0];
0
4928 -
4929 // If there is only one context left, then make the list empty. -
4930 if (group->m_shares.size() == 1)
never evaluated: group->m_shares.size() == 1
0
4931 group->m_shares.clear();
never executed: group->m_shares.clear();
0
4932}
never executed: }
0
4933 -
4934QSize QGLTexture::bindCompressedTexture -
4935 (const QString& fileName, const char *format) -
4936{ -
4937 QFile file(fileName);
never executed (the execution status of this line is deduced): QFile file(fileName);
-
4938 if (!file.open(QIODevice::ReadOnly))
never evaluated: !file.open(QIODevice::ReadOnly)
0
4939 return QSize();
never executed: return QSize();
0
4940 QByteArray contents = file.readAll();
never executed (the execution status of this line is deduced): QByteArray contents = file.readAll();
-
4941 file.close();
never executed (the execution status of this line is deduced): file.close();
-
4942 return bindCompressedTexture
never executed: return bindCompressedTexture (contents.constData(), contents.size(), format);
0
4943 (contents.constData(), contents.size(), format);
never executed: return bindCompressedTexture (contents.constData(), contents.size(), format);
0
4944} -
4945 -
4946// PVR header format for container files that store textures compressed -
4947// with the ETC1, PVRTC2, and PVRTC4 encodings. Format information from the -
4948// PowerVR SDK at http://www.imgtec.com/powervr/insider/powervr-sdk.asp -
4949// "PVRTexTool Reference Manual, version 1.11f". -
4950struct PvrHeader -
4951{ -
4952 quint32 headerSize; -
4953 quint32 height; -
4954 quint32 width; -
4955 quint32 mipMapCount; -
4956 quint32 flags; -
4957 quint32 dataSize; -
4958 quint32 bitsPerPixel; -
4959 quint32 redMask; -
4960 quint32 greenMask; -
4961 quint32 blueMask; -
4962 quint32 alphaMask; -
4963 quint32 magic; -
4964 quint32 surfaceCount; -
4965}; -
4966 -
4967#define PVR_MAGIC 0x21525650 // "PVR!" in little-endian -
4968 -
4969#define PVR_FORMAT_MASK 0x000000FF -
4970#define PVR_FORMAT_PVRTC2 0x00000018 -
4971#define PVR_FORMAT_PVRTC4 0x00000019 -
4972#define PVR_FORMAT_ETC1 0x00000036 -
4973 -
4974#define PVR_HAS_MIPMAPS 0x00000100 -
4975#define PVR_TWIDDLED 0x00000200 -
4976#define PVR_NORMAL_MAP 0x00000400 -
4977#define PVR_BORDER_ADDED 0x00000800 -
4978#define PVR_CUBE_MAP 0x00001000 -
4979#define PVR_FALSE_COLOR_MIPMAPS 0x00002000 -
4980#define PVR_VOLUME_TEXTURE 0x00004000 -
4981#define PVR_ALPHA_IN_TEXTURE 0x00008000 -
4982#define PVR_VERTICAL_FLIP 0x00010000 -
4983 -
4984#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG -
4985#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -
4986#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -
4987#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -
4988#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -
4989#endif -
4990 -
4991#ifndef GL_ETC1_RGB8_OES -
4992#define GL_ETC1_RGB8_OES 0x8D64 -
4993#endif -
4994 -
4995bool QGLTexture::canBindCompressedTexture -
4996 (const char *buf, int len, const char *format, bool *hasAlpha) -
4997{ -
4998 if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) {
never evaluated: QSysInfo::ByteOrder != QSysInfo::LittleEndian
0
4999 // Compressed texture loading only supported on little-endian -
5000 // systems such as x86 and ARM at the moment. -
5001 return false;
never executed: return false;
0
5002 } -
5003 if (!format) {
never evaluated: !format
0
5004 // Auto-detect the format from the header. -
5005 if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) {
never evaluated: len >= 4
never evaluated: !qstrncmp(buf, "DDS ", 4)
0
5006 *hasAlpha = true;
never executed (the execution status of this line is deduced): *hasAlpha = true;
-
5007 return true;
never executed: return true;
0
5008 } else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) {
never evaluated: len >= 52
never evaluated: !qstrncmp(buf + 44, "PVR!", 4)
0
5009 const PvrHeader *pvrHeader =
never executed (the execution status of this line is deduced): const PvrHeader *pvrHeader =
-
5010 reinterpret_cast<const PvrHeader *>(buf);
never executed (the execution status of this line is deduced): reinterpret_cast<const PvrHeader *>(buf);
-
5011 *hasAlpha = (pvrHeader->alphaMask != 0);
never executed (the execution status of this line is deduced): *hasAlpha = (pvrHeader->alphaMask != 0);
-
5012 return true;
never executed: return true;
0
5013 } -
5014 } else { -
5015 // Validate the format against the header. -
5016 if (!qstricmp(format, "DDS")) {
never evaluated: !qstricmp(format, "DDS")
0
5017 if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) {
never evaluated: len >= 4
never evaluated: !qstrncmp(buf, "DDS ", 4)
0
5018 *hasAlpha = true;
never executed (the execution status of this line is deduced): *hasAlpha = true;
-
5019 return true;
never executed: return true;
0
5020 } -
5021 } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) {
never executed: }
never evaluated: !qstricmp(format, "PVR")
never evaluated: !qstricmp(format, "ETC1")
0
5022 if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) {
never evaluated: len >= 52
never evaluated: !qstrncmp(buf + 44, "PVR!", 4)
0
5023 const PvrHeader *pvrHeader =
never executed (the execution status of this line is deduced): const PvrHeader *pvrHeader =
-
5024 reinterpret_cast<const PvrHeader *>(buf);
never executed (the execution status of this line is deduced): reinterpret_cast<const PvrHeader *>(buf);
-
5025 *hasAlpha = (pvrHeader->alphaMask != 0);
never executed (the execution status of this line is deduced): *hasAlpha = (pvrHeader->alphaMask != 0);
-
5026 return true;
never executed: return true;
0
5027 } -
5028 }
never executed: }
0
5029 } -
5030 return false;
never executed: return false;
0
5031} -
5032 -
5033#define ctx QGLContext::currentContext() -
5034 -
5035QSize QGLTexture::bindCompressedTexture -
5036 (const char *buf, int len, const char *format) -
5037{ -
5038 if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) {
never evaluated: QSysInfo::ByteOrder != QSysInfo::LittleEndian
0
5039 // Compressed texture loading only supported on little-endian -
5040 // systems such as x86 and ARM at the moment. -
5041 return QSize();
never executed: return QSize();
0
5042 } -
5043#if !defined(QT_OPENGL_ES) -
5044 if (!glCompressedTexImage2D) {
never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glCompressedTexImage2DARB
0
5045 if (!(QGLExtensions::glExtensions() & QGLExtensions::TextureCompression)) {
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::TextureCompression)
0
5046 qWarning("QGLContext::bindTexture(): The GL implementation does "
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5046, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): The GL implementation does "
-
5047 "not support texture compression extensions.");
never executed (the execution status of this line is deduced): "not support texture compression extensions.");
-
5048 return QSize();
never executed: return QSize();
0
5049 } -
5050 glCompressedTexImage2D = (_glCompressedTexImage2DARB) ctx->getProcAddress(QLatin1String("glCompressedTexImage2DARB"));
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glCompressedTexImage2DARB = (_glCompressedTexImage2DARB) QGLContext::currentContext()->getProcAddress(QLatin1String("glCompressedTexImage2DARB"));
-
5051 if (!glCompressedTexImage2D) {
never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glCompressedTexImage2DARB
0
5052 qWarning("QGLContext::bindTexture(): could not resolve "
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5052, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): could not resolve "
-
5053 "glCompressedTexImage2DARB.");
never executed (the execution status of this line is deduced): "glCompressedTexImage2DARB.");
-
5054 return QSize();
never executed: return QSize();
0
5055 } -
5056 }
never executed: }
0
5057#endif -
5058 if (!format) {
never evaluated: !format
0
5059 // Auto-detect the format from the header. -
5060 if (len >= 4 && !qstrncmp(buf, "DDS ", 4))
never evaluated: len >= 4
never evaluated: !qstrncmp(buf, "DDS ", 4)
0
5061 return bindCompressedTextureDDS(buf, len);
never executed: return bindCompressedTextureDDS(buf, len);
0
5062 else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4))
never evaluated: len >= 52
never evaluated: !qstrncmp(buf + 44, "PVR!", 4)
0
5063 return bindCompressedTexturePVR(buf, len);
never executed: return bindCompressedTexturePVR(buf, len);
0
5064 } else { -
5065 // Validate the format against the header. -
5066 if (!qstricmp(format, "DDS")) {
never evaluated: !qstricmp(format, "DDS")
0
5067 if (len >= 4 && !qstrncmp(buf, "DDS ", 4))
never evaluated: len >= 4
never evaluated: !qstrncmp(buf, "DDS ", 4)
0
5068 return bindCompressedTextureDDS(buf, len);
never executed: return bindCompressedTextureDDS(buf, len);
0
5069 } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) {
never executed: }
never evaluated: !qstricmp(format, "PVR")
never evaluated: !qstricmp(format, "ETC1")
0
5070 if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4))
never evaluated: len >= 52
never evaluated: !qstrncmp(buf + 44, "PVR!", 4)
0
5071 return bindCompressedTexturePVR(buf, len);
never executed: return bindCompressedTexturePVR(buf, len);
0
5072 }
never executed: }
0
5073 } -
5074 return QSize();
never executed: return QSize();
0
5075} -
5076 -
5077QSize QGLTexture::bindCompressedTextureDDS(const char *buf, int len) -
5078{ -
5079 // We only support 2D texture loading at present. -
5080 if (target != GL_TEXTURE_2D)
never evaluated: target != 0x0DE1
0
5081 return QSize();
never executed: return QSize();
0
5082 -
5083 // Bail out if the necessary extension is not present. -
5084 if (!(QGLExtensions::glExtensions() & QGLExtensions::DDSTextureCompression)) {
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::DDSTextureCompression)
0
5085 qWarning("QGLContext::bindTexture(): DDS texture compression is not supported.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5085, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): DDS texture compression is not supported.");
-
5086 return QSize();
never executed: return QSize();
0
5087 } -
5088 -
5089 const DDSFormat *ddsHeader = reinterpret_cast<const DDSFormat *>(buf + 4);
never executed (the execution status of this line is deduced): const DDSFormat *ddsHeader = reinterpret_cast<const DDSFormat *>(buf + 4);
-
5090 if (!ddsHeader->dwLinearSize) {
never evaluated: !ddsHeader->dwLinearSize
0
5091 qWarning("QGLContext::bindTexture(): DDS image size is not valid.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5091, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): DDS image size is not valid.");
-
5092 return QSize();
never executed: return QSize();
0
5093 } -
5094 -
5095 int blockSize = 16;
never executed (the execution status of this line is deduced): int blockSize = 16;
-
5096 GLenum format;
never executed (the execution status of this line is deduced): GLenum format;
-
5097 -
5098 switch(ddsHeader->ddsPixelFormat.dwFourCC) { -
5099 case FOURCC_DXT1: -
5100 format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
never executed (the execution status of this line is deduced): format = 0x83F1;
-
5101 blockSize = 8;
never executed (the execution status of this line is deduced): blockSize = 8;
-
5102 break;
never executed: break;
0
5103 case FOURCC_DXT3: -
5104 format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
never executed (the execution status of this line is deduced): format = 0x83F2;
-
5105 break;
never executed: break;
0
5106 case FOURCC_DXT5: -
5107 format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
never executed (the execution status of this line is deduced): format = 0x83F3;
-
5108 break;
never executed: break;
0
5109 default: -
5110 qWarning("QGLContext::bindTexture(): DDS image format not supported.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5110, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): DDS image format not supported.");
-
5111 return QSize();
never executed: return QSize();
0
5112 } -
5113 -
5114 const GLubyte *pixels =
never executed (the execution status of this line is deduced): const GLubyte *pixels =
-
5115 reinterpret_cast<const GLubyte *>(buf + ddsHeader->dwSize + 4);
never executed (the execution status of this line is deduced): reinterpret_cast<const GLubyte *>(buf + ddsHeader->dwSize + 4);
-
5116 -
5117 glGenTextures(1, &id);
never executed (the execution status of this line is deduced): glGenTextures(1, &id);
-
5118 glBindTexture(GL_TEXTURE_2D, id);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, id);
-
5119 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2601);
-
5120 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2601);
-
5121 -
5122 int size;
never executed (the execution status of this line is deduced): int size;
-
5123 int offset = 0;
never executed (the execution status of this line is deduced): int offset = 0;
-
5124 int available = len - int(ddsHeader->dwSize + 4);
never executed (the execution status of this line is deduced): int available = len - int(ddsHeader->dwSize + 4);
-
5125 int w = ddsHeader->dwWidth;
never executed (the execution status of this line is deduced): int w = ddsHeader->dwWidth;
-
5126 int h = ddsHeader->dwHeight;
never executed (the execution status of this line is deduced): int h = ddsHeader->dwHeight;
-
5127 -
5128 // load mip-maps -
5129 for(int i = 0; i < (int) ddsHeader->dwMipMapCount; ++i) {
never evaluated: i < (int) ddsHeader->dwMipMapCount
0
5130 if (w == 0) w = 1;
never executed: w = 1;
never evaluated: w == 0
0
5131 if (h == 0) h = 1;
never executed: h = 1;
never evaluated: h == 0
0
5132 -
5133 size = ((w+3)/4) * ((h+3)/4) * blockSize;
never executed (the execution status of this line is deduced): size = ((w+3)/4) * ((h+3)/4) * blockSize;
-
5134 if (size > available)
never evaluated: size > available
0
5135 break;
never executed: break;
0
5136 glCompressedTexImage2D(GL_TEXTURE_2D, i, format, w, h, 0,
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glCompressedTexImage2DARB(0x0DE1, i, format, w, h, 0,
-
5137 size, pixels + offset);
never executed (the execution status of this line is deduced): size, pixels + offset);
-
5138 offset += size;
never executed (the execution status of this line is deduced): offset += size;
-
5139 available -= size;
never executed (the execution status of this line is deduced): available -= size;
-
5140 -
5141 // half size for each mip-map level -
5142 w = w/2;
never executed (the execution status of this line is deduced): w = w/2;
-
5143 h = h/2;
never executed (the execution status of this line is deduced): h = h/2;
-
5144 }
never executed: }
0
5145 -
5146 // DDS images are not inverted. -
5147 options &= ~QGLContext::InvertedYBindOption;
never executed (the execution status of this line is deduced): options &= ~QGLContext::InvertedYBindOption;
-
5148 -
5149 return QSize(ddsHeader->dwWidth, ddsHeader->dwHeight);
never executed: return QSize(ddsHeader->dwWidth, ddsHeader->dwHeight);
0
5150} -
5151 -
5152QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len) -
5153{ -
5154 // We only support 2D texture loading at present. Cube maps later. -
5155 if (target != GL_TEXTURE_2D)
never evaluated: target != 0x0DE1
0
5156 return QSize();
never executed: return QSize();
0
5157 -
5158 // Determine which texture format we will be loading. -
5159 const PvrHeader *pvrHeader = reinterpret_cast<const PvrHeader *>(buf);
never executed (the execution status of this line is deduced): const PvrHeader *pvrHeader = reinterpret_cast<const PvrHeader *>(buf);
-
5160 GLenum textureFormat;
never executed (the execution status of this line is deduced): GLenum textureFormat;
-
5161 quint32 minWidth, minHeight;
never executed (the execution status of this line is deduced): quint32 minWidth, minHeight;
-
5162 switch (pvrHeader->flags & PVR_FORMAT_MASK) { -
5163 case PVR_FORMAT_PVRTC2: -
5164 if (pvrHeader->alphaMask)
never evaluated: pvrHeader->alphaMask
0
5165 textureFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
never executed: textureFormat = 0x8C03;
0
5166 else -
5167 textureFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
never executed: textureFormat = 0x8C01;
0
5168 minWidth = 16;
never executed (the execution status of this line is deduced): minWidth = 16;
-
5169 minHeight = 8;
never executed (the execution status of this line is deduced): minHeight = 8;
-
5170 break;
never executed: break;
0
5171 -
5172 case PVR_FORMAT_PVRTC4: -
5173 if (pvrHeader->alphaMask)
never evaluated: pvrHeader->alphaMask
0
5174 textureFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
never executed: textureFormat = 0x8C02;
0
5175 else -
5176 textureFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
never executed: textureFormat = 0x8C00;
0
5177 minWidth = 8;
never executed (the execution status of this line is deduced): minWidth = 8;
-
5178 minHeight = 8;
never executed (the execution status of this line is deduced): minHeight = 8;
-
5179 break;
never executed: break;
0
5180 -
5181 case PVR_FORMAT_ETC1: -
5182 textureFormat = GL_ETC1_RGB8_OES;
never executed (the execution status of this line is deduced): textureFormat = 0x8D64;
-
5183 minWidth = 4;
never executed (the execution status of this line is deduced): minWidth = 4;
-
5184 minHeight = 4;
never executed (the execution status of this line is deduced): minHeight = 4;
-
5185 break;
never executed: break;
0
5186 -
5187 default: -
5188 qWarning("QGLContext::bindTexture(): PVR image format 0x%x not supported.", int(pvrHeader->flags & PVR_FORMAT_MASK));
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5188, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): PVR image format 0x%x not supported.", int(pvrHeader->flags & 0x000000FF));
-
5189 return QSize();
never executed: return QSize();
0
5190 } -
5191 -
5192 // Bail out if the necessary extension is not present. -
5193 if (textureFormat == GL_ETC1_RGB8_OES) {
never evaluated: textureFormat == 0x8D64
0
5194 if (!(QGLExtensions::glExtensions() &
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::ETC1TextureCompression)
0
5195 QGLExtensions::ETC1TextureCompression)) {
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::ETC1TextureCompression)
0
5196 qWarning("QGLContext::bindTexture(): ETC1 texture compression is not supported.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5196, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): ETC1 texture compression is not supported.");
-
5197 return QSize();
never executed: return QSize();
0
5198 } -
5199 } else {
never executed: }
0
5200 if (!(QGLExtensions::glExtensions() &
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::PVRTCTextureCompression)
0
5201 QGLExtensions::PVRTCTextureCompression)) {
never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::PVRTCTextureCompression)
0
5202 qWarning("QGLContext::bindTexture(): PVRTC texture compression is not supported.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5202, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): PVRTC texture compression is not supported.");
-
5203 return QSize();
never executed: return QSize();
0
5204 } -
5205 }
never executed: }
0
5206 -
5207 // Boundary check on the buffer size. -
5208 quint32 bufferSize = pvrHeader->headerSize + pvrHeader->dataSize;
never executed (the execution status of this line is deduced): quint32 bufferSize = pvrHeader->headerSize + pvrHeader->dataSize;
-
5209 if (bufferSize > quint32(len)) {
never evaluated: bufferSize > quint32(len)
0
5210 qWarning("QGLContext::bindTexture(): PVR image size is not valid.");
never executed (the execution status of this line is deduced): QMessageLogger("qgl.cpp", 5210, __PRETTY_FUNCTION__).warning("QGLContext::bindTexture(): PVR image size is not valid.");
-
5211 return QSize();
never executed: return QSize();
0
5212 } -
5213 -
5214 // Create the texture. -
5215 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
never executed (the execution status of this line is deduced): glPixelStorei(0x0CF5, 1);
-
5216 glGenTextures(1, &id);
never executed (the execution status of this line is deduced): glGenTextures(1, &id);
-
5217 glBindTexture(GL_TEXTURE_2D, id);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, id);
-
5218 if (pvrHeader->mipMapCount) {
never evaluated: pvrHeader->mipMapCount
0
5219 if ((options & QGLContext::LinearFilteringBindOption) != 0) {
never evaluated: (options & QGLContext::LinearFilteringBindOption) != 0
0
5220 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2601);
-
5221 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2703);
-
5222 } else {
never executed: }
0
5223 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2600);
-
5224 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2700);
-
5225 }
never executed: }
0
5226 } else if ((options & QGLContext::LinearFilteringBindOption) != 0) {
never evaluated: (options & QGLContext::LinearFilteringBindOption) != 0
0
5227 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2601);
-
5228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2601);
-
5229 } else {
never executed: }
0
5230 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2600);
-
5231 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2600);
-
5232 }
never executed: }
0
5233 -
5234 // Load the compressed mipmap levels. -
5235 const GLubyte *buffer =
never executed (the execution status of this line is deduced): const GLubyte *buffer =
-
5236 reinterpret_cast<const GLubyte *>(buf + pvrHeader->headerSize);
never executed (the execution status of this line is deduced): reinterpret_cast<const GLubyte *>(buf + pvrHeader->headerSize);
-
5237 bufferSize = pvrHeader->dataSize;
never executed (the execution status of this line is deduced): bufferSize = pvrHeader->dataSize;
-
5238 quint32 level = 0;
never executed (the execution status of this line is deduced): quint32 level = 0;
-
5239 quint32 width = pvrHeader->width;
never executed (the execution status of this line is deduced): quint32 width = pvrHeader->width;
-
5240 quint32 height = pvrHeader->height;
never executed (the execution status of this line is deduced): quint32 height = pvrHeader->height;
-
5241 while (bufferSize > 0 && level <= pvrHeader->mipMapCount) {
never evaluated: bufferSize > 0
never evaluated: level <= pvrHeader->mipMapCount
0
5242 quint32 size =
never executed (the execution status of this line is deduced): quint32 size =
-
5243 (qMax(width, minWidth) * qMax(height, minHeight) *
never executed (the execution status of this line is deduced): (qMax(width, minWidth) * qMax(height, minHeight) *
-
5244 pvrHeader->bitsPerPixel) / 8;
never executed (the execution status of this line is deduced): pvrHeader->bitsPerPixel) / 8;
-
5245 if (size > bufferSize)
never evaluated: size > bufferSize
0
5246 break;
never executed: break;
0
5247 glCompressedTexImage2D(GL_TEXTURE_2D, GLint(level), textureFormat,
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glCompressedTexImage2DARB(0x0DE1, GLint(level), textureFormat,
-
5248 GLsizei(width), GLsizei(height), 0,
never executed (the execution status of this line is deduced): GLsizei(width), GLsizei(height), 0,
-
5249 GLsizei(size), buffer);
never executed (the execution status of this line is deduced): GLsizei(size), buffer);
-
5250 width /= 2;
never executed (the execution status of this line is deduced): width /= 2;
-
5251 height /= 2;
never executed (the execution status of this line is deduced): height /= 2;
-
5252 buffer += size;
never executed (the execution status of this line is deduced): buffer += size;
-
5253 ++level;
never executed (the execution status of this line is deduced): ++level;
-
5254 }
never executed: }
0
5255 -
5256 // Restore the default pixel alignment for later texture uploads. -
5257 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
never executed (the execution status of this line is deduced): glPixelStorei(0x0CF5, 4);
-
5258 -
5259 // Set the invert flag for the texture. The "vertical flip" -
5260 // flag in PVR is the opposite sense to our sense of inversion. -
5261 if ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0)
never evaluated: (pvrHeader->flags & 0x00010000) != 0
0
5262 options &= ~QGLContext::InvertedYBindOption;
never executed: options &= ~QGLContext::InvertedYBindOption;
0
5263 else -
5264 options |= QGLContext::InvertedYBindOption;
never executed: options |= QGLContext::InvertedYBindOption;
0
5265 -
5266 return QSize(pvrHeader->width, pvrHeader->height);
never executed: return QSize(pvrHeader->width, pvrHeader->height);
0
5267} -
5268 -
5269#undef ctx -
5270 -
5271QT_END_NAMESPACE -
5272 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial