| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | class QGLBufferPrivate | - |
| 4 | { | - |
| 5 | public: | - |
| 6 | QGLBufferPrivate(QGLBuffer::Type t) | - |
| 7 | : ref(1), | - |
| 8 | type(t), | - |
| 9 | guard(0), | - |
| 10 | usagePattern(QGLBuffer::StaticDraw), | - |
| 11 | actualUsagePattern(QGLBuffer::StaticDraw) | - |
| 12 | { | - |
| 13 | } | 0 |
| 14 | | - |
| 15 | QAtomicInt ref; | - |
| 16 | QGLBuffer::Type type; | - |
| 17 | QGLSharedResourceGuardBase *guard; | - |
| 18 | QGLBuffer::UsagePattern usagePattern; | - |
| 19 | QGLBuffer::UsagePattern actualUsagePattern; | - |
| 20 | }; | - |
| 21 | QGLBuffer::QGLBuffer() | - |
| 22 | : d_ptr(new QGLBufferPrivate(QGLBuffer::VertexBuffer)) | - |
| 23 | { | - |
| 24 | } | 0 |
| 25 | QGLBuffer::QGLBuffer(QGLBuffer::Type type) | - |
| 26 | : d_ptr(new QGLBufferPrivate(type)) | - |
| 27 | { | - |
| 28 | } | 0 |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | QGLBuffer::QGLBuffer(const QGLBuffer &other) | - |
| 37 | : d_ptr(other.d_ptr) | - |
| 38 | { | - |
| 39 | d_ptr->ref.ref(); | - |
| 40 | } | 0 |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | QGLBuffer::~QGLBuffer() | - |
| 49 | { | - |
| 50 | if (!d_ptr->ref.deref()) { never evaluated: !d_ptr->ref.deref() | 0 |
| 51 | destroy(); | - |
| 52 | delete d_ptr; | - |
| 53 | } | 0 |
| 54 | } | 0 |
| 55 | | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | | - |
| 60 | | - |
| 61 | | - |
| 62 | QGLBuffer &QGLBuffer::operator=(const QGLBuffer &other) | - |
| 63 | { | - |
| 64 | if (d_ptr != other.d_ptr) { never evaluated: d_ptr != other.d_ptr | 0 |
| 65 | other.d_ptr->ref.ref(); | - |
| 66 | if (!d_ptr->ref.deref()) { never evaluated: !d_ptr->ref.deref() | 0 |
| 67 | destroy(); | - |
| 68 | delete d_ptr; | - |
| 69 | } | 0 |
| 70 | d_ptr = other.d_ptr; | - |
| 71 | } | 0 |
| 72 | return *this; never executed: return *this; | 0 |
| 73 | } | - |
| 74 | | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | QGLBuffer::Type QGLBuffer::type() const | - |
| 79 | { | - |
| 80 | const QGLBufferPrivate * const d = d_func(); | - |
| 81 | return d->type; never executed: return d->type; | 0 |
| 82 | } | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | | - |
| 89 | | - |
| 90 | QGLBuffer::UsagePattern QGLBuffer::usagePattern() const | - |
| 91 | { | - |
| 92 | const QGLBufferPrivate * const d = d_func(); | - |
| 93 | return d->usagePattern; never executed: return d->usagePattern; | 0 |
| 94 | } | - |
| 95 | | - |
| 96 | | - |
| 97 | | - |
| 98 | | - |
| 99 | | - |
| 100 | | - |
| 101 | | - |
| 102 | void QGLBuffer::setUsagePattern(QGLBuffer::UsagePattern value) | - |
| 103 | { | - |
| 104 | QGLBufferPrivate * const d = d_func(); | - |
| 105 | d->usagePattern = d->actualUsagePattern = value; | - |
| 106 | } | 0 |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | namespace { | - |
| 111 | void freeBufferFunc(QGLContext *ctx, GLuint id) | - |
| 112 | { | - |
| 113 | (void)ctx;; | - |
| 114 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers(1, &id); | - |
| 115 | } | 0 |
| 116 | } | - |
| 117 | bool QGLBuffer::create() | - |
| 118 | { | - |
| 119 | QGLBufferPrivate * const d = d_func(); | - |
| 120 | if (d->guard && d->guard->id()) never evaluated: d->guard never evaluated: d->guard->id() | 0 |
| 121 | return true; never executed: return true; | 0 |
| 122 | QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); | - |
| 123 | if (ctx) { | 0 |
| 124 | if (!qt_resolve_buffer_extensions(ctx)) never evaluated: !qt_resolve_buffer_extensions(ctx) | 0 |
| 125 | return false; never executed: return false; | 0 |
| 126 | GLuint bufferId = 0; | - |
| 127 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers(1, &bufferId); | - |
| 128 | if (bufferId) { never evaluated: bufferId | 0 |
| 129 | if (d->guard) never evaluated: d->guard | 0 |
| 130 | d->guard->free(); never executed: d->guard->free(); | 0 |
| 131 | | - |
| 132 | d->guard = createSharedResourceGuard(ctx, bufferId, freeBufferFunc); | - |
| 133 | return true; never executed: return true; | 0 |
| 134 | } | - |
| 135 | } | 0 |
| 136 | return false; never executed: return false; | 0 |
| 137 | } | - |
| 138 | bool QGLBuffer::isCreated() const | - |
| 139 | { | - |
| 140 | const QGLBufferPrivate * const d = d_func(); | - |
| 141 | return d->guard && d->guard->id(); never executed: return d->guard && d->guard->id(); | 0 |
| 142 | } | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | | - |
| 147 | | - |
| 148 | | - |
| 149 | void QGLBuffer::destroy() | - |
| 150 | { | - |
| 151 | QGLBufferPrivate * const d = d_func(); | - |
| 152 | if (d->guard) { never evaluated: d->guard | 0 |
| 153 | d->guard->free(); | - |
| 154 | d->guard = 0; | - |
| 155 | } | 0 |
| 156 | } | 0 |
| 157 | bool QGLBuffer::read(int offset, void *data, int count) | - |
| 158 | { | - |
| 159 | | - |
| 160 | QGLBufferPrivate * const d = d_func(); | - |
| 161 | if (!QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferSubData || !d->guard->id()) never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferSubData never evaluated: !d->guard->id() | 0 |
| 162 | return false; never executed: return false; | 0 |
| 163 | while (glGetError() != 0x0) ; never evaluated: glGetError() != 0x0 | 0 |
| 164 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferSubData(d->type, offset, count, data); | - |
| 165 | return glGetError() == 0x0; never executed: return glGetError() == 0x0; | 0 |
| 166 | | - |
| 167 | | - |
| 168 | | - |
| 169 | | - |
| 170 | | - |
| 171 | | - |
| 172 | } | - |
| 173 | void QGLBuffer::write(int offset, const void *data, int count) | - |
| 174 | { | - |
| 175 | | - |
| 176 | | - |
| 177 | | - |
| 178 | | - |
| 179 | QGLBufferPrivate * const d = d_func(); | - |
| 180 | if (d->guard && d->guard->id()) never evaluated: d->guard never evaluated: d->guard->id() | 0 |
| 181 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferSubData(d->type, offset, count, data); never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferSubData(d->type, offset, count, data); | 0 |
| 182 | } | 0 |
| 183 | void QGLBuffer::allocate(const void *data, int count) | - |
| 184 | { | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | QGLBufferPrivate * const d = d_func(); | - |
| 190 | if (d->guard && d->guard->id()) never evaluated: d->guard never evaluated: d->guard->id() | 0 |
| 191 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferData(d->type, count, data, d->actualUsagePattern); never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferData(d->type, count, data, d->actualUsagePattern); | 0 |
| 192 | } | 0 |
| 193 | bool QGLBuffer::bind() | - |
| 194 | { | - |
| 195 | | - |
| 196 | | - |
| 197 | | - |
| 198 | | - |
| 199 | const QGLBufferPrivate * const d = d_func(); | - |
| 200 | GLuint bufferId = d->guard ? d->guard->id() : 0; never evaluated: d->guard | 0 |
| 201 | if (bufferId) { never evaluated: bufferId | 0 |
| 202 | if (d->guard->group() != QOpenGLContextGroup::currentContextGroup()) { never evaluated: d->guard->group() != QOpenGLContextGroup::currentContextGroup() | 0 |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | return false; never executed: return false; | 0 |
| 207 | } | - |
| 208 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBindBuffer(d->type, bufferId); | - |
| 209 | return true; never executed: return true; | 0 |
| 210 | } else { | - |
| 211 | return false; never executed: return false; | 0 |
| 212 | } | - |
| 213 | } | - |
| 214 | void QGLBuffer::release() | - |
| 215 | { | - |
| 216 | | - |
| 217 | | - |
| 218 | | - |
| 219 | | - |
| 220 | const QGLBufferPrivate * const d = d_func(); | - |
| 221 | if (d->guard && d->guard->id()) never evaluated: d->guard never evaluated: d->guard->id() | 0 |
| 222 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBindBuffer(d->type, 0); never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBindBuffer(d->type, 0); | 0 |
| 223 | } | 0 |
| 224 | void QGLBuffer::release(QGLBuffer::Type type) | - |
| 225 | { | - |
| 226 | const QGLContext *ctx = QGLContext::currentContext(); | - |
| 227 | if (ctx && qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx))) never evaluated: qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx)) | 0 |
| 228 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer(GLenum(type), 0); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer(GLenum(type), 0); | 0 |
| 229 | } | 0 |
| 230 | GLuint QGLBuffer::bufferId() const | - |
| 231 | { | - |
| 232 | const QGLBufferPrivate * const d = d_func(); | - |
| 233 | return d->guard ? d->guard->id() : 0; never executed: return d->guard ? d->guard->id() : 0; | 0 |
| 234 | } | - |
| 235 | int QGLBuffer::size() const | - |
| 236 | { | - |
| 237 | const QGLBufferPrivate * const d = d_func(); | - |
| 238 | if (!d->guard || !d->guard->id()) never evaluated: !d->guard never evaluated: !d->guard->id() | 0 |
| 239 | return -1; never executed: return -1; | 0 |
| 240 | GLint value = -1; | - |
| 241 | QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferParameteriv(d->type, 0x8764, &value); | - |
| 242 | return value; never executed: return value; | 0 |
| 243 | } | - |
| 244 | void *QGLBuffer::map(QGLBuffer::Access access) | - |
| 245 | { | - |
| 246 | QGLBufferPrivate * const d = d_func(); | - |
| 247 | | - |
| 248 | | - |
| 249 | | - |
| 250 | | - |
| 251 | if (!d->guard || !d->guard->id()) never evaluated: !d->guard never evaluated: !d->guard->id() | 0 |
| 252 | return 0; never executed: return 0; | 0 |
| 253 | if (!QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB) never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB | 0 |
| 254 | return 0; never executed: return 0; | 0 |
| 255 | return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB(d->type, access); never executed: return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB(d->type, access); | 0 |
| 256 | } | - |
| 257 | bool QGLBuffer::unmap() | - |
| 258 | { | - |
| 259 | QGLBufferPrivate * const d = d_func(); | - |
| 260 | | - |
| 261 | | - |
| 262 | | - |
| 263 | | - |
| 264 | if (!d->guard || !d->guard->id()) never evaluated: !d->guard never evaluated: !d->guard->id() | 0 |
| 265 | return false; never executed: return false; | 0 |
| 266 | if (!QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB) never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB | 0 |
| 267 | return false; never executed: return false; | 0 |
| 268 | return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB(d->type) == 0x1; never executed: return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB(d->type) == 0x1; | 0 |
| 269 | } | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| | |