qopenglvertexarrayobject.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglvertexarrayobject.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7class QOpenGLFunctions_3_0;-
8class QOpenGLFunctions_3_2_Core;-
9-
10void qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, QOpenGLContext *context)-
11{-
12 ((!(helper)) ? qt_assert("helper",__FILE__,59) : qt_noop());-
13 ((!(context)) ? qt_assert("context",__FILE__,60) : qt_noop());-
14-
15 bool tryARB = true;-
16-
17 if (context->isOpenGLES()
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
18 if (context->format().majorVersion() >= 3
context->forma...Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
19 QOpenGLExtraFunctionsPrivate *extra = static_cast<QOpenGLExtensions *>(context->extraFunctions())->d();-
20 helper->GenVertexArrays = extra->f.GenVertexArrays;-
21 helper->DeleteVertexArrays = extra->f.DeleteVertexArrays;-
22 helper->BindVertexArray = extra->f.BindVertexArray;-
23 helper->IsVertexArray = extra->f.IsVertexArray;-
24 tryARB = false;-
25 }
never executed: end of block
else if (context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_OES_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_OES_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
26 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArraysOES"));-
27 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArraysOES"));-
28 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArrayOES"));-
29 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArrayOES"));-
30 tryARB = false;-
31 }
never executed: end of block
0
32 }
never executed: end of block
else if (context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_APPLE_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_APPLE_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
33 !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
34 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArraysAPPLE"));-
35 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArraysAPPLE"));-
36 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArrayAPPLE"));-
37 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArrayAPPLE"));-
38 tryARB = false;-
39 }
never executed: end of block
0
40-
41 if (tryARB
tryARBDescription
TRUEnever evaluated
FALSEnever evaluated
&& context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
42 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArrays"));-
43 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArrays"));-
44 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArray"));-
45 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArray"));-
46 }
never executed: end of block
0
47}
never executed: end of block
0
48-
49class QOpenGLVertexArrayObjectPrivate : public QObjectPrivate-
50{-
51public:-
52 QOpenGLVertexArrayObjectPrivate()-
53 : vao(0)-
54 , vaoFuncsType(NotSupported)-
55 , context(0)-
56 {-
57 }
never executed: end of block
0
58-
59 ~QOpenGLVertexArrayObjectPrivate()-
60 {-
61 if (vaoFuncsType == ARB
vaoFuncsType == ARBDescription
TRUEnever evaluated
FALSEnever evaluated
|| vaoFuncsType == APPLE
vaoFuncsType == APPLEDescription
TRUEnever evaluated
FALSEnever evaluated
|| vaoFuncsType == OES
vaoFuncsType == OESDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
62 delete vaoFuncs.helper;
never executed: delete vaoFuncs.helper;
0
63 }
never executed: end of block
0
64-
65 bool create();-
66 void destroy();-
67 void bind();-
68 void release();-
69 void _q_contextAboutToBeDestroyed();-
70-
71 inline QOpenGLVertexArrayObject* q_func() { return static_cast<QOpenGLVertexArrayObject *>(q_ptr); } inline const QOpenGLVertexArrayObject* q_func() const { return static_cast<const QOpenGLVertexArrayObject *>(q_ptr); } friend class QOpenGLVertexArrayObject;-
72-
73 GLuint vao;-
74-
75 union {-
76 QOpenGLFunctions_3_0 *core_3_0;-
77 QOpenGLFunctions_3_2_Core *core_3_2;-
78 QOpenGLVertexArrayObjectHelper *helper;-
79 } vaoFuncs;-
80 enum {-
81 NotSupported,-
82 Core_3_0,-
83 Core_3_2,-
84 ARB,-
85 APPLE,-
86 OES-
87 } vaoFuncsType;-
88-
89 QOpenGLContext *context;-
90};-
91-
92bool QOpenGLVertexArrayObjectPrivate::create()-
93{-
94 if (vao
vaoDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
95 QMessageLogger(__FILE__, 142, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::create() VAO is already created");-
96 return
never executed: return false;
false;
never executed: return false;
0
97 }-
98-
99 QOpenGLVertexArrayObject * const q = q_func();-
100-
101 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
102 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
103 QMessageLogger(__FILE__, 150, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context");-
104 return
never executed: return false;
false;
never executed: return false;
0
105 }-
106-
107-
108 if (ctx == context
ctx == contextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
109 return
never executed: return false;
false;
never executed: return false;
0
110-
111 context = ctx;-
112 QObject::connect(context, qFlagLocation("2""aboutToBeDestroyed()" "\0" __FILE__ ":" "159"), q, qFlagLocation("1""_q_contextAboutToBeDestroyed()" "\0" __FILE__ ":" "159"));-
113-
114 if (ctx->isOpenGLES()
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 if (ctx->format().majorVersion() >= 3
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
|| ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_OES_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_OES_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
116 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
117 vaoFuncsType = OES;-
118 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
119 }
never executed: end of block
0
120 }
never executed: end of block
else {
0
121 vaoFuncs.core_3_0 = 0;-
122 vaoFuncsType = NotSupported;-
123 QSurfaceFormat format = ctx->format();-
124-
125 if (format.version() >= qMakePair<int, int>(3,2)
format.version...int, int>(3,2)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
126 vaoFuncs.core_3_2 = ctx->versionFunctions<QOpenGLFunctions_3_2_Core>();-
127 vaoFuncsType = Core_3_2;-
128 vaoFuncs.core_3_2->glGenVertexArrays(1, &vao);-
129 }
never executed: end of block
else if (format.majorVersion() >= 3
format.majorVersion() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
130 vaoFuncs.core_3_0 = ctx->versionFunctions<QOpenGLFunctions_3_0>();-
131 vaoFuncsType = Core_3_0;-
132 vaoFuncs.core_3_0->glGenVertexArrays(1, &vao);-
133 }
never executed: end of block
else
0
134-
135 if (ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
137 vaoFuncsType = ARB;-
138 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
139 }
never executed: end of block
else if (ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_APPLE_vertex_array_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_APPLE_vertex_array_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
140 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
141 vaoFuncsType = APPLE;-
142 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
143 }
never executed: end of block
0
144 }
never executed: end of block
0
145-
146 return
never executed: return (vao != 0);
(vao != 0);
never executed: return (vao != 0);
0
147}-
148-
149void QOpenGLVertexArrayObjectPrivate::destroy()-
150{-
151 QOpenGLVertexArrayObject * const q = q_func();-
152-
153 if (context
contextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
154 QObject::disconnect(context, qFlagLocation("2""aboutToBeDestroyed()" "\0" __FILE__ ":" "201"), q, qFlagLocation("1""_q_contextAboutToBeDestroyed()" "\0" __FILE__ ":" "201"));-
155 context = 0;-
156 }
never executed: end of block
0
157-
158 if (!vao
!vaoDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
159 return;
never executed: return;
0
160-
161 switch (vaoFuncsType) {-
162-
163 case
never executed: case Core_3_2:
Core_3_2:
never executed: case Core_3_2:
0
164 vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao);-
165 break;
never executed: break;
0
166 case
never executed: case Core_3_0:
Core_3_0:
never executed: case Core_3_0:
0
167 vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao);-
168 break;
never executed: break;
0
169-
170 case
never executed: case ARB:
ARB:
never executed: case ARB:
0
171 case
never executed: case APPLE:
APPLE:
never executed: case APPLE:
0
172 case
never executed: case OES:
OES:
never executed: case OES:
0
173 vaoFuncs.helper->glDeleteVertexArrays(1, &vao);-
174 break;
never executed: break;
0
175 default
never executed: default:
:
never executed: default:
0
176 break;
never executed: break;
0
177 }-
178-
179 vao = 0;-
180}
never executed: end of block
0
181-
182-
183-
184-
185void QOpenGLVertexArrayObjectPrivate::_q_contextAboutToBeDestroyed()-
186{-
187 destroy();-
188}
never executed: end of block
0
189-
190void QOpenGLVertexArrayObjectPrivate::bind()-
191{-
192 switch (vaoFuncsType) {-
193-
194 case
never executed: case Core_3_2:
Core_3_2:
never executed: case Core_3_2:
0
195 vaoFuncs.core_3_2->glBindVertexArray(vao);-
196 break;
never executed: break;
0
197 case
never executed: case Core_3_0:
Core_3_0:
never executed: case Core_3_0:
0
198 vaoFuncs.core_3_0->glBindVertexArray(vao);-
199 break;
never executed: break;
0
200-
201 case
never executed: case ARB:
ARB:
never executed: case ARB:
0
202 case
never executed: case APPLE:
APPLE:
never executed: case APPLE:
0
203 case
never executed: case OES:
OES:
never executed: case OES:
0
204 vaoFuncs.helper->glBindVertexArray(vao);-
205 break;
never executed: break;
0
206 default
never executed: default:
:
never executed: default:
0
207 break;
never executed: break;
0
208 }-
209}-
210-
211void QOpenGLVertexArrayObjectPrivate::release()-
212{-
213 switch (vaoFuncsType) {-
214-
215 case
never executed: case Core_3_2:
Core_3_2:
never executed: case Core_3_2:
0
216 vaoFuncs.core_3_2->glBindVertexArray(0);-
217 break;
never executed: break;
0
218 case
never executed: case Core_3_0:
Core_3_0:
never executed: case Core_3_0:
0
219 vaoFuncs.core_3_0->glBindVertexArray(0);-
220 break;
never executed: break;
0
221-
222 case
never executed: case ARB:
ARB:
never executed: case ARB:
0
223 case
never executed: case APPLE:
APPLE:
never executed: case APPLE:
0
224 case
never executed: case OES:
OES:
never executed: case OES:
0
225 vaoFuncs.helper->glBindVertexArray(0);-
226 break;
never executed: break;
0
227 default
never executed: default:
:
never executed: default:
0
228 break;
never executed: break;
0
229 }-
230}-
231QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QObject* parent)-
232 : QObject(*new QOpenGLVertexArrayObjectPrivate, parent)-
233{-
234}
never executed: end of block
0
235-
236-
237-
238-
239QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPrivate &dd)-
240 : QObject(dd)-
241{-
242}
never executed: end of block
0
243-
244-
245-
246-
247QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()-
248{-
249 QOpenGLContext* ctx = QOpenGLContext::currentContext();-
250-
251 QOpenGLVertexArrayObjectPrivate * const d = d_func();-
252 QOpenGLContext *oldContext = 0;-
253 QSurface *oldContextSurface = 0;-
254 QScopedPointer<QOffscreenSurface> offscreenSurface;-
255 if (d->context
d->contextDescription
TRUEnever evaluated
FALSEnever evaluated
&& ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->context != ctx
d->context != ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
256 oldContext = ctx;-
257 oldContextSurface = ctx->surface();-
258-
259-
260-
261-
262 offscreenSurface.reset(new QOffscreenSurface);-
263 offscreenSurface->setFormat(d->context->format());-
264 offscreenSurface->create();-
265 if (d->context->makeCurrent(offscreenSurface.data())
d->context->ma...urface.data())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 ctx = d->context;-
267 }
never executed: end of block
else {
0
268 QMessageLogger(__FILE__, 376, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current");-
269 ctx = 0;-
270 }
never executed: end of block
0
271 }-
272-
273 if (ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
274 destroy();
never executed: destroy();
0
275-
276 if (oldContext
oldContextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
277 if (!oldContext->makeCurrent(oldContextSurface)
!oldContext->m...ontextSurface)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
278 QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
never executed: QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
0
279 }
never executed: end of block
0
280}
never executed: end of block
0
281bool QOpenGLVertexArrayObject::create()-
282{-
283 QOpenGLVertexArrayObjectPrivate * const d = d_func();-
284 return
never executed: return d->create();
d->create();
never executed: return d->create();
0
285}-
286-
287-
288-
289-
290-
291void QOpenGLVertexArrayObject::destroy()-
292{-
293 QOpenGLVertexArrayObjectPrivate * const d = d_func();-
294 d->destroy();-
295}
never executed: end of block
0
296-
297-
298-
299-
300-
301-
302bool QOpenGLVertexArrayObject::isCreated() const-
303{-
304 const QOpenGLVertexArrayObjectPrivate * const d = d_func();-
305 return
never executed: return (d->vao != 0);
(d->vao != 0);
never executed: return (d->vao != 0);
0
306}-
307-
308-
309-
310-
311GLuint QOpenGLVertexArrayObject::objectId() const-
312{-
313 const QOpenGLVertexArrayObjectPrivate * const d = d_func();-
314 return
never executed: return d->vao;
d->vao;
never executed: return d->vao;
0
315}-
316void QOpenGLVertexArrayObject::bind()-
317{-
318 QOpenGLVertexArrayObjectPrivate * const d = d_func();-
319 d->bind();-
320}
never executed: end of block
0
321-
322-
323-
324-
325void QOpenGLVertexArrayObject::release()-
326{-
327 QOpenGLVertexArrayObjectPrivate * const d = d_func();-
328 d->release();-
329}
never executed: end of block
0
330-
331-
Switch to Source codePreprocessed file

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