| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/qglpixelbuffer.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | extern QImage qt_gl_read_frame_buffer(const QSize&, bool, bool); | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | QGLContext* QGLPBufferGLPaintDevice::context() const | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | return never executed: pbuf->d_func()->qctx;return pbuf->d_func()->qctx;never executed: return pbuf->d_func()->qctx; | 0 | ||||||||||||
| 13 | } | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | void QGLPBufferGLPaintDevice::beginPaint() | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | pbuf->makeCurrent(); | - | ||||||||||||
| 18 | QGLPaintDevice::beginPaint(); | - | ||||||||||||
| 19 | } never executed: end of block | 0 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | void QGLPBufferGLPaintDevice::endPaint() | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | QOpenGLContext::currentContext()->functions()->glFlush(); | - | ||||||||||||
| 24 | QGLPaintDevice::endPaint(); | - | ||||||||||||
| 25 | } never executed: end of block | 0 | ||||||||||||
| 26 | - | |||||||||||||
| 27 | void QGLPBufferGLPaintDevice::setFbo(GLuint fbo) | - | ||||||||||||
| 28 | { | - | ||||||||||||
| 29 | m_thisFBO = fbo; | - | ||||||||||||
| 30 | } never executed: end of block | 0 | ||||||||||||
| 31 | - | |||||||||||||
| 32 | void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) | - | ||||||||||||
| 33 | { | - | ||||||||||||
| 34 | pbuf = pb; | - | ||||||||||||
| 35 | } never executed: end of block | 0 | ||||||||||||
| 36 | - | |||||||||||||
| 37 | void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) | - | ||||||||||||
| 38 | { | - | ||||||||||||
| 39 | QGLPixelBuffer * const q = q_func(); | - | ||||||||||||
| 40 | if(init(size, format, shareWidget)
| 0 | ||||||||||||
| 41 | req_size = size; | - | ||||||||||||
| 42 | req_format = format; | - | ||||||||||||
| 43 | req_shareWidget = shareWidget; | - | ||||||||||||
| 44 | invalid = false; | - | ||||||||||||
| 45 | glDevice.setPBuffer(q); | - | ||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||
| 47 | } never executed: end of block | 0 | ||||||||||||
| 48 | QGLPixelBuffer::QGLPixelBuffer(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) | - | ||||||||||||
| 49 | : d_ptr(new QGLPixelBufferPrivate(this)) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 52 | d->common_init(size, format, shareWidget); | - | ||||||||||||
| 53 | } never executed: end of block | 0 | ||||||||||||
| 54 | QGLPixelBuffer::QGLPixelBuffer(int width, int height, const QGLFormat &format, QGLWidget *shareWidget) | - | ||||||||||||
| 55 | : d_ptr(new QGLPixelBufferPrivate(this)) | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 58 | d->common_init(QSize(width, height), format, shareWidget); | - | ||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||
| 60 | - | |||||||||||||
| 61 | - | |||||||||||||
| 62 | - | |||||||||||||
| 63 | - | |||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | QGLPixelBuffer::~QGLPixelBuffer() | - | ||||||||||||
| 67 | { | - | ||||||||||||
| 68 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 69 | - | |||||||||||||
| 70 | - | |||||||||||||
| 71 | QGLContext *current = const_cast<QGLContext *>(QGLContext::currentContext()); | - | ||||||||||||
| 72 | if (current != d->qctx
| 0 | ||||||||||||
| 73 | makeCurrent(); never executed: makeCurrent(); | 0 | ||||||||||||
| 74 | d->cleanup(); | - | ||||||||||||
| 75 | if (current
| 0 | ||||||||||||
| 76 | current->makeCurrent(); never executed: current->makeCurrent(); | 0 | ||||||||||||
| 77 | } never executed: end of block | 0 | ||||||||||||
| 78 | bool QGLPixelBuffer::makeCurrent() | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 81 | if (d->invalid
| 0 | ||||||||||||
| 82 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 83 | d->qctx->makeCurrent(); | - | ||||||||||||
| 84 | if (!d->fbo
| 0 | ||||||||||||
| 85 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||
| 86 | if (d->req_format.stencil()
| 0 | ||||||||||||
| 87 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); never executed: format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | 0 | ||||||||||||
| 88 | else if (d->req_format.depth()
| 0 | ||||||||||||
| 89 | format.setAttachment(QOpenGLFramebufferObject::Depth); never executed: format.setAttachment(QOpenGLFramebufferObject::Depth); | 0 | ||||||||||||
| 90 | if (d->req_format.sampleBuffers()
| 0 | ||||||||||||
| 91 | format.setSamples(d->req_format.samples()); never executed: format.setSamples(d->req_format.samples()); | 0 | ||||||||||||
| 92 | d->fbo = new QOpenGLFramebufferObject(d->req_size, format); | - | ||||||||||||
| 93 | d->fbo->bind(); | - | ||||||||||||
| 94 | d->glDevice.setFbo(d->fbo->handle()); | - | ||||||||||||
| 95 | QOpenGLContext::currentContext()->functions()->glViewport(0, 0, d->req_size.width(), d->req_size.height()); | - | ||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||
| 97 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | - | |||||||||||||
| 101 | - | |||||||||||||
| 102 | - | |||||||||||||
| 103 | - | |||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 | bool QGLPixelBuffer::doneCurrent() | - | ||||||||||||
| 107 | { | - | ||||||||||||
| 108 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 109 | if (d->invalid
| 0 | ||||||||||||
| 110 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 111 | d->qctx->doneCurrent(); | - | ||||||||||||
| 112 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | - | |||||||||||||
| 116 | - | |||||||||||||
| 117 | - | |||||||||||||
| 118 | QGLContext *QGLPixelBuffer::context() const | - | ||||||||||||
| 119 | { | - | ||||||||||||
| 120 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 121 | return never executed: d->qctx;return d->qctx;never executed: return d->qctx; | 0 | ||||||||||||
| 122 | } | - | ||||||||||||
| 123 | void QGLPixelBuffer::updateDynamicTexture(GLuint texture_id) const | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 126 | if (d->invalid
| 0 | ||||||||||||
| 127 | return; never executed: return; | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | const QGLContext *ctx = QGLContext::currentContext(); | - | ||||||||||||
| 130 | if (!ctx
| 0 | ||||||||||||
| 131 | return; never executed: return; | 0 | ||||||||||||
| 132 | QOpenGLExtensions extensions(ctx->contextHandle()); | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | ctx->d_ptr->refreshCurrentFbo(); | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | if (d->blit_fbo
| 0 | ||||||||||||
| 137 | QOpenGLFramebufferObject::blitFramebuffer(d->blit_fbo, d->fbo); | - | ||||||||||||
| 138 | extensions.glBindFramebuffer(0x8CA8, d->blit_fbo->handle()); | - | ||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | extensions.glBindTexture(0x0DE1, texture_id); | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | GLenum format = ctx->contextHandle()->isOpenGLES()
| 0 | ||||||||||||
| 144 | extensions.glCopyTexImage2D(0x0DE1, 0, format, 0, 0, d->req_size.width(), d->req_size.height(), 0); | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | if (d->blit_fbo
| 0 | ||||||||||||
| 150 | extensions.glBindFramebuffer(0x8CA8, ctx->d_func()->current_fbo); never executed: extensions.glBindFramebuffer(0x8CA8, ctx->d_func()->current_fbo); | 0 | ||||||||||||
| 151 | } never executed: end of block | 0 | ||||||||||||
| 152 | - | |||||||||||||
| 153 | - | |||||||||||||
| 154 | - | |||||||||||||
| 155 | - | |||||||||||||
| 156 | QSize QGLPixelBuffer::size() const | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 159 | return never executed: d->req_size;return d->req_size;never executed: return d->req_size; | 0 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | - | |||||||||||||
| 163 | - | |||||||||||||
| 164 | - | |||||||||||||
| 165 | QImage QGLPixelBuffer::toImage() const | - | ||||||||||||
| 166 | { | - | ||||||||||||
| 167 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 168 | if (d->invalid
| 0 | ||||||||||||
| 169 | return never executed: QImage();return QImage();never executed: return QImage(); | 0 | ||||||||||||
| 170 | - | |||||||||||||
| 171 | const_cast<QGLPixelBuffer *>(this)->makeCurrent(); | - | ||||||||||||
| 172 | if (d->fbo
| 0 | ||||||||||||
| 173 | d->fbo->bind(); never executed: d->fbo->bind(); | 0 | ||||||||||||
| 174 | return never executed: qt_gl_read_frame_buffer(d->req_size, d->format.alpha(), true);return qt_gl_read_frame_buffer(d->req_size, d->format.alpha(), true);never executed: return qt_gl_read_frame_buffer(d->req_size, d->format.alpha(), true); | 0 | ||||||||||||
| 175 | } | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | - | |||||||||||||
| 179 | - | |||||||||||||
| 180 | Qt::HANDLE QGLPixelBuffer::handle() const | - | ||||||||||||
| 181 | { | - | ||||||||||||
| 182 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 183 | if (d->invalid
| 0 | ||||||||||||
| 184 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 185 | return never executed: (Qt::HANDLE) d->pbuf;return (Qt::HANDLE) d->pbuf;never executed: return (Qt::HANDLE) d->pbuf; | 0 | ||||||||||||
| 186 | } | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | - | |||||||||||||
| 189 | - | |||||||||||||
| 190 | - | |||||||||||||
| 191 | bool QGLPixelBuffer::isValid() const | - | ||||||||||||
| 192 | { | - | ||||||||||||
| 193 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 194 | return never executed: !d->invalid;return !d->invalid;never executed: return !d->invalid; | 0 | ||||||||||||
| 195 | } | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | namespace { namespace Q_QGS_qt_buffer_2_engine { typedef QGLEngineThreadStorage<QGL2PaintEngineEx> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QGLEngineThreadStorage<QGL2PaintEngineEx>, Q_QGS_qt_buffer_2_engine::innerFunction, Q_QGS_qt_buffer_2_engine::guard> qt_buffer_2_engine;return &holder.value; | 0 | ||||||||||||
| 198 | - | |||||||||||||
| 199 | - | |||||||||||||
| 200 | QPaintEngine *QGLPixelBuffer::paintEngine() const | - | ||||||||||||
| 201 | { | - | ||||||||||||
| 202 | return never executed: qt_buffer_2_engine()->engine();return qt_buffer_2_engine()->engine();never executed: return qt_buffer_2_engine()->engine(); | 0 | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | - | |||||||||||||
| 206 | int QGLPixelBuffer::metric(PaintDeviceMetric metric) const | - | ||||||||||||
| 207 | { | - | ||||||||||||
| 208 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | float dpmx = qt_defaultDpiX()*100./2.54; | - | ||||||||||||
| 211 | float dpmy = qt_defaultDpiY()*100./2.54; | - | ||||||||||||
| 212 | int w = d->req_size.width(); | - | ||||||||||||
| 213 | int h = d->req_size.height(); | - | ||||||||||||
| 214 | switch (metric) { | - | ||||||||||||
| 215 | case never executed: PdmWidth:case PdmWidth:never executed: case PdmWidth: | 0 | ||||||||||||
| 216 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||
| 217 | - | |||||||||||||
| 218 | case never executed: PdmHeight:case PdmHeight:never executed: case PdmHeight: | 0 | ||||||||||||
| 219 | return never executed: h;return h;never executed: return h; | 0 | ||||||||||||
| 220 | - | |||||||||||||
| 221 | case never executed: PdmWidthMM:case PdmWidthMM:never executed: case PdmWidthMM: | 0 | ||||||||||||
| 222 | return never executed: qRound(w * 1000 / dpmx);return qRound(w * 1000 / dpmx);never executed: return qRound(w * 1000 / dpmx); | 0 | ||||||||||||
| 223 | - | |||||||||||||
| 224 | case never executed: PdmHeightMM:case PdmHeightMM:never executed: case PdmHeightMM: | 0 | ||||||||||||
| 225 | return never executed: qRound(h * 1000 / dpmy);return qRound(h * 1000 / dpmy);never executed: return qRound(h * 1000 / dpmy); | 0 | ||||||||||||
| 226 | - | |||||||||||||
| 227 | case never executed: PdmNumColors:case PdmNumColors:never executed: case PdmNumColors: | 0 | ||||||||||||
| 228 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 229 | - | |||||||||||||
| 230 | case never executed: PdmDepth:case PdmDepth:never executed: case PdmDepth: | 0 | ||||||||||||
| 231 | return never executed: 32;return 32;never executed: return 32; | 0 | ||||||||||||
| 232 | - | |||||||||||||
| 233 | case never executed: PdmDpiX:case PdmDpiX:never executed: case PdmDpiX: | 0 | ||||||||||||
| 234 | return never executed: qRound(dpmx * 0.0254);return qRound(dpmx * 0.0254);never executed: return qRound(dpmx * 0.0254); | 0 | ||||||||||||
| 235 | - | |||||||||||||
| 236 | case never executed: PdmDpiY:case PdmDpiY:never executed: case PdmDpiY: | 0 | ||||||||||||
| 237 | return never executed: qRound(dpmy * 0.0254);return qRound(dpmy * 0.0254);never executed: return qRound(dpmy * 0.0254); | 0 | ||||||||||||
| 238 | - | |||||||||||||
| 239 | case never executed: PdmPhysicalDpiX:case PdmPhysicalDpiX:never executed: case PdmPhysicalDpiX: | 0 | ||||||||||||
| 240 | return never executed: qRound(dpmx * 0.0254);return qRound(dpmx * 0.0254);never executed: return qRound(dpmx * 0.0254); | 0 | ||||||||||||
| 241 | - | |||||||||||||
| 242 | case never executed: PdmPhysicalDpiY:case PdmPhysicalDpiY:never executed: case PdmPhysicalDpiY: | 0 | ||||||||||||
| 243 | return never executed: qRound(dpmy * 0.0254);return qRound(dpmy * 0.0254);never executed: return qRound(dpmy * 0.0254); | 0 | ||||||||||||
| 244 | - | |||||||||||||
| 245 | case never executed: QPaintDevice::PdmDevicePixelRatio:case QPaintDevice::PdmDevicePixelRatio:never executed: case QPaintDevice::PdmDevicePixelRatio: | 0 | ||||||||||||
| 246 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||
| 247 | - | |||||||||||||
| 248 | case never executed: QPaintDevice::PdmDevicePixelRatioScaled:case QPaintDevice::PdmDevicePixelRatioScaled:never executed: case QPaintDevice::PdmDevicePixelRatioScaled: | 0 | ||||||||||||
| 249 | return never executed: QPaintDevice::devicePixelRatioFScale();return QPaintDevice::devicePixelRatioFScale();never executed: return QPaintDevice::devicePixelRatioFScale(); | 0 | ||||||||||||
| 250 | - | |||||||||||||
| 251 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 252 | QMessageLogger(__FILE__, 465, __PRETTY_FUNCTION__).warning("QGLPixelBuffer::metric(), Unhandled metric type: %d\n", metric); | - | ||||||||||||
| 253 | break; never executed: break; | 0 | ||||||||||||
| 254 | } | - | ||||||||||||
| 255 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 256 | } | - | ||||||||||||
| 257 | GLuint QGLPixelBuffer::bindTexture(const QImage &image, GLenum target) | - | ||||||||||||
| 258 | { | - | ||||||||||||
| 259 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | GLenum format = QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||
| 262 | return never executed: d->qctx->bindTexture(image, target, GLint(format));return d->qctx->bindTexture(image, target, GLint(format));never executed: return d->qctx->bindTexture(image, target, GLint(format)); | 0 | ||||||||||||
| 263 | - | |||||||||||||
| 264 | - | |||||||||||||
| 265 | - | |||||||||||||
| 266 | } | - | ||||||||||||
| 267 | GLuint QGLPixelBuffer::bindTexture(const QPixmap &pixmap, GLenum target) | - | ||||||||||||
| 268 | { | - | ||||||||||||
| 269 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | GLenum format = QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||
| 272 | return never executed: d->qctx->bindTexture(pixmap, target, GLint(format));return d->qctx->bindTexture(pixmap, target, GLint(format));never executed: return d->qctx->bindTexture(pixmap, target, GLint(format)); | 0 | ||||||||||||
| 273 | - | |||||||||||||
| 274 | - | |||||||||||||
| 275 | - | |||||||||||||
| 276 | } | - | ||||||||||||
| 277 | GLuint QGLPixelBuffer::bindTexture(const QString &fileName) | - | ||||||||||||
| 278 | { | - | ||||||||||||
| 279 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 280 | return never executed: d->qctx->bindTexture(fileName);return d->qctx->bindTexture(fileName);never executed: return d->qctx->bindTexture(fileName); | 0 | ||||||||||||
| 281 | } | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | - | |||||||||||||
| 284 | - | |||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | - | |||||||||||||
| 288 | void QGLPixelBuffer::deleteTexture(GLuint texture_id) | - | ||||||||||||
| 289 | { | - | ||||||||||||
| 290 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 291 | d->qctx->deleteTexture(texture_id); | - | ||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||
| 293 | void QGLPixelBuffer::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) | - | ||||||||||||
| 294 | { | - | ||||||||||||
| 295 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 296 | d->qctx->drawTexture(target, textureId, textureTarget); | - | ||||||||||||
| 297 | } never executed: end of block | 0 | ||||||||||||
| 298 | void QGLPixelBuffer::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) | - | ||||||||||||
| 299 | { | - | ||||||||||||
| 300 | QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 301 | d->qctx->drawTexture(point, textureId, textureTarget); | - | ||||||||||||
| 302 | } never executed: end of block | 0 | ||||||||||||
| 303 | - | |||||||||||||
| 304 | - | |||||||||||||
| 305 | - | |||||||||||||
| 306 | - | |||||||||||||
| 307 | - | |||||||||||||
| 308 | QGLFormat QGLPixelBuffer::format() const | - | ||||||||||||
| 309 | { | - | ||||||||||||
| 310 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 311 | return never executed: d->format;return d->format;never executed: return d->format; | 0 | ||||||||||||
| 312 | } | - | ||||||||||||
| 313 | - | |||||||||||||
| 314 | - | |||||||||||||
| 315 | - | |||||||||||||
| 316 | - | |||||||||||||
| 317 | - | |||||||||||||
| 318 | bool QGLPixelBufferPrivate::init(const QSize &, const QGLFormat &f, QGLWidget *shareWidget) | - | ||||||||||||
| 319 | { | - | ||||||||||||
| 320 | widget = new QGLWidget(f, 0, shareWidget); | - | ||||||||||||
| 321 | widget->resize(1, 1); | - | ||||||||||||
| 322 | qctx = const_cast<QGLContext *>(widget->context()); | - | ||||||||||||
| 323 | return never executed: widget->isValid();return widget->isValid();never executed: return widget->isValid(); | 0 | ||||||||||||
| 324 | } | - | ||||||||||||
| 325 | - | |||||||||||||
| 326 | bool QGLPixelBufferPrivate::cleanup() | - | ||||||||||||
| 327 | { | - | ||||||||||||
| 328 | delete fbo; | - | ||||||||||||
| 329 | fbo = 0; | - | ||||||||||||
| 330 | delete blit_fbo; | - | ||||||||||||
| 331 | blit_fbo = 0; | - | ||||||||||||
| 332 | delete widget; | - | ||||||||||||
| 333 | widget = 0; | - | ||||||||||||
| 334 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 335 | } | - | ||||||||||||
| 336 | - | |||||||||||||
| 337 | bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id) | - | ||||||||||||
| 338 | { | - | ||||||||||||
| 339 | (void)texture_id;; | - | ||||||||||||
| 340 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 341 | } | - | ||||||||||||
| 342 | - | |||||||||||||
| 343 | void QGLPixelBuffer::releaseFromDynamicTexture() | - | ||||||||||||
| 344 | { | - | ||||||||||||
| 345 | } | - | ||||||||||||
| 346 | - | |||||||||||||
| 347 | GLuint QGLPixelBuffer::generateDynamicTexture() const | - | ||||||||||||
| 348 | { | - | ||||||||||||
| 349 | const QGLPixelBufferPrivate * const d = d_func(); | - | ||||||||||||
| 350 | if (!d->fbo
| 0 | ||||||||||||
| 351 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 352 | - | |||||||||||||
| 353 | if (d->fbo->format().samples() > 0
| 0 | ||||||||||||
| 354 | && QOpenGLExtensions(QOpenGLContext::currentContext())
| 0 | ||||||||||||
| 355 | .hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)
| 0 | ||||||||||||
| 356 | { | - | ||||||||||||
| 357 | if (!d->blit_fbo
| 0 | ||||||||||||
| 358 | const_cast< never executed: QOpenGLFramebufferObject *&>(d->blit_fbo) = new QOpenGLFramebufferObject(d->req_size);const_cast<QOpenGLFramebufferObject *&>(d->blit_fbo) = new QOpenGLFramebufferObject(d->req_size);never executed: const_cast<QOpenGLFramebufferObject *&>(d->blit_fbo) = new QOpenGLFramebufferObject(d->req_size); | 0 | ||||||||||||
| 359 | } never executed: else {end of block | 0 | ||||||||||||
| 360 | return never executed: d->fbo->texture();return d->fbo->texture();never executed: return d->fbo->texture(); | 0 | ||||||||||||
| 361 | } | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | GLuint texture; | - | ||||||||||||
| 364 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||
| 365 | - | |||||||||||||
| 366 | funcs->glGenTextures(1, &texture); | - | ||||||||||||
| 367 | funcs->glBindTexture(0x0DE1, texture); | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | funcs->glTexParameteri(0x0DE1, 0x2801, 0x2600); | - | ||||||||||||
| 370 | funcs->glTexParameteri(0x0DE1, 0x2800, 0x2600); | - | ||||||||||||
| 371 | funcs->glTexParameteri(0x0DE1, 0x2802, 0x812F); | - | ||||||||||||
| 372 | funcs->glTexParameteri(0x0DE1, 0x2803, 0x812F); | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | funcs->glTexImage2D(0x0DE1, 0, 0x1908, d->req_size.width(), d->req_size.height(), 0, | - | ||||||||||||
| 375 | 0x1908, 0x1401, 0); | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | return never executed: texture;return texture;never executed: return texture; | 0 | ||||||||||||
| 378 | } | - | ||||||||||||
| 379 | - | |||||||||||||
| 380 | bool QGLPixelBuffer::hasOpenGLPbuffers() | - | ||||||||||||
| 381 | { | - | ||||||||||||
| 382 | return never executed: QGLFramebufferObject::hasOpenGLFramebufferObjects();return QGLFramebufferObject::hasOpenGLFramebufferObjects();never executed: return QGLFramebufferObject::hasOpenGLFramebufferObjects(); | 0 | ||||||||||||
| 383 | } | - | ||||||||||||
| 384 | - | |||||||||||||
| 385 | - | |||||||||||||
| Switch to Source code | Preprocessed file |