OpenCoverage

qglbuffer.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/opengl/qglbuffer.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3class QGLBufferPrivate-
4{-
5public:-
6 QGLBufferPrivate(QGLBuffer::Type t)-
7 : ref(1),-
8 type(t),-
9 guard(0),-
10 usagePattern(QGLBuffer::StaticDraw),-
11 actualUsagePattern(QGLBuffer::StaticDraw),-
12 funcs(0)-
13 {-
14 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
15-
16 QAtomicInt ref;-
17 QGLBuffer::Type type;-
18 QGLSharedResourceGuardBase *guard;-
19 QGLBuffer::UsagePattern usagePattern;-
20 QGLBuffer::UsagePattern actualUsagePattern;-
21 QOpenGLExtensions *funcs;-
22};-
23QGLBuffer::QGLBuffer()-
24 : d_ptr(new QGLBufferPrivate(QGLBuffer::VertexBuffer))-
25{-
26}
never executed: end of block
0
27QGLBuffer::QGLBuffer(QGLBuffer::Type type)-
28 : d_ptr(new QGLBufferPrivate(type))-
29{-
30}
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
31-
32-
33-
34-
35-
36-
37-
38QGLBuffer::QGLBuffer(const QGLBuffer &other)-
39 : d_ptr(other.d_ptr)-
40{-
41 d_ptr->ref.ref();-
42}
never executed: end of block
0
43-
44-
45-
46-
47-
48-
49-
50QGLBuffer::~QGLBuffer()-
51{-
52 if (!d_ptr->ref.deref()
!d_ptr->ref.deref()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
) {
0-7
53 destroy();-
54 delete d_ptr;-
55 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
56}
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
57-
58-
59-
60-
61-
62-
63-
64QGLBuffer &QGLBuffer::operator=(const QGLBuffer &other)-
65{-
66 if (d_ptr != other.d_ptr
d_ptr != other.d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
67 other.d_ptr->ref.ref();-
68 if (!d_ptr->ref.deref()
!d_ptr->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
69 destroy();-
70 delete d_ptr;-
71 }
never executed: end of block
0
72 d_ptr = other.d_ptr;-
73 }
never executed: end of block
0
74 return
never executed: return *this;
*this;
never executed: return *this;
0
75}-
76-
77-
78-
79-
80QGLBuffer::Type QGLBuffer::type() const-
81{-
82 const QGLBufferPrivate * const d = d_func();-
83 return
executed 6 times by 1 test: return d->type;
Executed by:
  • tst_qglbuffer - unknown status
d->type;
executed 6 times by 1 test: return d->type;
Executed by:
  • tst_qglbuffer - unknown status
6
84}-
85-
86-
87-
88-
89-
90-
91-
92QGLBuffer::UsagePattern QGLBuffer::usagePattern() const-
93{-
94 const QGLBufferPrivate * const d = d_func();-
95 return
executed 12 times by 1 test: return d->usagePattern;
Executed by:
  • tst_qglbuffer - unknown status
d->usagePattern;
executed 12 times by 1 test: return d->usagePattern;
Executed by:
  • tst_qglbuffer - unknown status
12
96}-
97-
98-
99-
100-
101-
102-
103-
104void QGLBuffer::setUsagePattern(QGLBuffer::UsagePattern value)-
105{-
106 QGLBufferPrivate * const d = d_func();-
107 d->usagePattern = d->actualUsagePattern = value;-
108}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
6
109-
110-
111-
112namespace {-
113 void freeBufferFunc(QGLContext *ctx, GLuint id)-
114 {-
115 ((!(ctx)) ? qt_assert("ctx",__FILE__,262) : qt_noop());-
116 ctx->contextHandle()->functions()->glDeleteBuffers(1, &id);-
117 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
6
118}-
119bool QGLBuffer::create()-
120{-
121 QGLBufferPrivate * const d = d_func();-
122 if (d->guard
d->guardDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
&& d->guard->id()
d->guard->id()Description
TRUEnever evaluated
FALSEnever evaluated
)
0-7
123 return
never executed: return true;
true;
never executed: return true;
0
124 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());-
125 if (ctx
ctxDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
) {
0-7
126 delete d->funcs;-
127 d->funcs = new QOpenGLExtensions(ctx->contextHandle());-
128 if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers)
!d->funcs->has...ions::Buffers)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-7
129 return
never executed: return false;
false;
never executed: return false;
0
130-
131 GLuint bufferId = 0;-
132 d->funcs->glGenBuffers(1, &bufferId);-
133 if (bufferId
bufferIdDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
) {
0-7
134 if (d->guard
d->guardDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-7
135 d->guard->free();
never executed: d->guard->free();
0
136-
137 d->guard = createSharedResourceGuard(ctx, bufferId, freeBufferFunc);-
138 return
executed 7 times by 1 test: return true;
Executed by:
  • tst_qglbuffer - unknown status
true;
executed 7 times by 1 test: return true;
Executed by:
  • tst_qglbuffer - unknown status
7
139 }-
140 }
never executed: end of block
0
141 return
never executed: return false;
false;
never executed: return false;
0
142}-
143bool QGLBuffer::isCreated() const-
144{-
145 const QGLBufferPrivate * const d = d_func();-
146 return
executed 106 times by 1 test: return d->guard && d->guard->id();
Executed by:
  • tst_qglbuffer - unknown status
d->guard && d->guard->id();
executed 106 times by 1 test: return d->guard && d->guard->id();
Executed by:
  • tst_qglbuffer - unknown status
106
147}-
148-
149-
150-
151-
152-
153-
154void QGLBuffer::destroy()-
155{-
156 QGLBufferPrivate * const d = d_func();-
157 if (d->guard
d->guardDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
) {
0-7
158 d->guard->free();-
159 d->guard = 0;-
160 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
161}
executed 7 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
7
162bool QGLBuffer::read(int offset, void *data, int count)-
163{-
164-
165 QGLBufferPrivate * const d = d_func();-
166 if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers)
!d->funcs->has...ions::Buffers)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
|| !d->guard->id()
!d->guard->id()Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-13
167 return
never executed: return false;
false;
never executed: return false;
0
168 while (d->funcs->glGetError() != 0
d->funcs->glGetError() != 0Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
) ;
never executed: ;
0-13
169 d->funcs->glGetBufferSubData(d->type, offset, count, data);-
170 return
executed 13 times by 1 test: return d->funcs->glGetError() == 0;
Executed by:
  • tst_qglbuffer - unknown status
d->funcs->glGetError() == 0;
executed 13 times by 1 test: return d->funcs->glGetError() == 0;
Executed by:
  • tst_qglbuffer - unknown status
13
171-
172-
173-
174-
175-
176-
177}-
178void QGLBuffer::write(int offset, const void *data, int count)-
179{-
180-
181 if (!isCreated()
!isCreated()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-6
182 QMessageLogger(__FILE__, 373, __PRETTY_FUNCTION__).warning("QGLBuffer::allocate(): buffer not created");
never executed: QMessageLogger(__FILE__, 373, __PRETTY_FUNCTION__).warning("QGLBuffer::allocate(): buffer not created");
0
183-
184 QGLBufferPrivate * const d = d_func();-
185 if (d->guard
d->guardDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
&& d->guard->id()
d->guard->id()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
)
0-6
186 d->funcs->glBufferSubData(d->type, offset, count, data);
executed 6 times by 1 test: d->funcs->glBufferSubData(d->type, offset, count, data);
Executed by:
  • tst_qglbuffer - unknown status
6
187}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
6
188void QGLBuffer::allocate(const void *data, int count)-
189{-
190-
191 if (!isCreated()
!isCreated()Description
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-19
192 QMessageLogger(__FILE__, 393, __PRETTY_FUNCTION__).warning("QGLBuffer::allocate(): buffer not created");
never executed: QMessageLogger(__FILE__, 393, __PRETTY_FUNCTION__).warning("QGLBuffer::allocate(): buffer not created");
0
193-
194 QGLBufferPrivate * const d = d_func();-
195 if (d->guard
d->guardDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
&& d->guard->id()
d->guard->id()Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
)
0-19
196 d->funcs->glBufferData(d->type, count, data, d->actualUsagePattern);
executed 19 times by 1 test: d->funcs->glBufferData(d->type, count, data, d->actualUsagePattern);
Executed by:
  • tst_qglbuffer - unknown status
19
197}
executed 19 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
19
198bool QGLBuffer::bind()-
199{-
200-
201 if (!isCreated()
!isCreated()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
6-9
202 QMessageLogger(__FILE__, 428, __PRETTY_FUNCTION__).warning("QGLBuffer::bind(): buffer not created");
executed 6 times by 1 test: QMessageLogger(__FILE__, 428, __PRETTY_FUNCTION__).warning("QGLBuffer::bind(): buffer not created");
Executed by:
  • tst_qglbuffer - unknown status
6
203-
204 const QGLBufferPrivate * const d = d_func();-
205 GLuint bufferId = d->guard
d->guardDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
? d->guard->id() : 0;
6-9
206 if (bufferId
bufferIdDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
) {
6-9
207 if (d->guard->group() != QOpenGLContextGroup::currentContextGroup()
d->guard->grou...ContextGroup()Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
) {
0-9
208-
209 QMessageLogger(__FILE__, 435, __PRETTY_FUNCTION__).warning("QGLBuffer::bind: buffer is not valid in the current context");-
210-
211 return
never executed: return false;
false;
never executed: return false;
0
212 }-
213 d->funcs->glBindBuffer(d->type, bufferId);-
214 return
executed 9 times by 1 test: return true;
Executed by:
  • tst_qglbuffer - unknown status
true;
executed 9 times by 1 test: return true;
Executed by:
  • tst_qglbuffer - unknown status
9
215 } else {-
216 return
executed 6 times by 1 test: return false;
Executed by:
  • tst_qglbuffer - unknown status
false;
executed 6 times by 1 test: return false;
Executed by:
  • tst_qglbuffer - unknown status
6
217 }-
218}-
219void QGLBuffer::release()-
220{-
221-
222 if (!isCreated()
!isCreated()Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-9
223 QMessageLogger(__FILE__, 459, __PRETTY_FUNCTION__).warning("QGLBuffer::release(): buffer not created");
never executed: QMessageLogger(__FILE__, 459, __PRETTY_FUNCTION__).warning("QGLBuffer::release(): buffer not created");
0
224-
225 const QGLBufferPrivate * const d = d_func();-
226 if (d->guard
d->guardDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
&& d->guard->id()
d->guard->id()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEnever evaluated
)
0-9
227 d->funcs->glBindBuffer(d->type, 0);
executed 9 times by 1 test: d->funcs->glBindBuffer(d->type, 0);
Executed by:
  • tst_qglbuffer - unknown status
9
228}
executed 9 times by 1 test: end of block
Executed by:
  • tst_qglbuffer - unknown status
9
229void QGLBuffer::release(QGLBuffer::Type type)-
230{-
231 if (QOpenGLContext *ctx = QOpenGLContext::currentContext()
QOpenGLContext...rrentContext()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
232 ctx->functions()->glBindBuffer(GLenum(type), 0);
never executed: ctx->functions()->glBindBuffer(GLenum(type), 0);
0
233}
never executed: end of block
0
234GLuint QGLBuffer::bufferId() const-
235{-
236 const QGLBufferPrivate * const d = d_func();-
237 return
executed 14 times by 1 test: return d->guard ? d->guard->id() : 0;
Executed by:
  • tst_qglbuffer - unknown status
d->guard ? d->guard->id() : 0;
executed 14 times by 1 test: return d->guard ? d->guard->id() : 0;
Executed by:
  • tst_qglbuffer - unknown status
14
238}-
239int QGLBuffer::size() const-
240{-
241 const QGLBufferPrivate * const d = d_func();-
242 if (!d->guard
!d->guardDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
|| !d->guard->id()
!d->guard->id()Description
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-21
243 return
executed 6 times by 1 test: return -1;
Executed by:
  • tst_qglbuffer - unknown status
-1;
executed 6 times by 1 test: return -1;
Executed by:
  • tst_qglbuffer - unknown status
6
244 GLint value = -1;-
245 d->funcs->glGetBufferParameteriv(d->type, 0x8764, &value);-
246 return
executed 21 times by 1 test: return value;
Executed by:
  • tst_qglbuffer - unknown status
value;
executed 21 times by 1 test: return value;
Executed by:
  • tst_qglbuffer - unknown status
21
247}-
248void *QGLBuffer::map(QGLBuffer::Access access)-
249{-
250 QGLBufferPrivate * const d = d_func();-
251-
252 if (!isCreated()
!isCreated()Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-24
253 QMessageLogger(__FILE__, 543, __PRETTY_FUNCTION__).warning("QGLBuffer::map(): buffer not created");
never executed: QMessageLogger(__FILE__, 543, __PRETTY_FUNCTION__).warning("QGLBuffer::map(): buffer not created");
0
254-
255 if (!d->guard
!d->guardDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
|| !d->guard->id()
!d->guard->id()Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-24
256 return
never executed: return 0;
0;
never executed: return 0;
0
257 return
executed 24 times by 1 test: return d->funcs->glMapBuffer(d->type, access);
Executed by:
  • tst_qglbuffer - unknown status
d->funcs->glMapBuffer(d->type, access);
executed 24 times by 1 test: return d->funcs->glMapBuffer(d->type, access);
Executed by:
  • tst_qglbuffer - unknown status
24
258}-
259bool QGLBuffer::unmap()-
260{-
261 QGLBufferPrivate * const d = d_func();-
262-
263 if (!isCreated()
!isCreated()Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-24
264 QMessageLogger(__FILE__, 568, __PRETTY_FUNCTION__).warning("QGLBuffer::unmap(): buffer not created");
never executed: QMessageLogger(__FILE__, 568, __PRETTY_FUNCTION__).warning("QGLBuffer::unmap(): buffer not created");
0
265-
266 if (!d->guard
!d->guardDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
|| !d->guard->id()
!d->guard->id()Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qglbuffer - unknown status
)
0-24
267 return
never executed: return false;
false;
never executed: return false;
0
268 return
executed 24 times by 1 test: return d->funcs->glUnmapBuffer(d->type) == 1;
Executed by:
  • tst_qglbuffer - unknown status
d->funcs->glUnmapBuffer(d->type) == 1;
executed 24 times by 1 test: return d->funcs->glUnmapBuffer(d->type) == 1;
Executed by:
  • tst_qglbuffer - unknown status
24
269}-
270-
271-
Switch to Source codePreprocessed file

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