| Line | Source Code | Coverage |
|---|
| 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 <private/qglpaintdevice_p.h> | - |
| 43 | #include <private/qgl_p.h> | - |
| 44 | #include <private/qglpixelbuffer_p.h> | - |
| 45 | #include <private/qglframebufferobject_p.h> | - |
| 46 | #include <qopenglfunctions.h> | - |
| 47 | | - |
| 48 | QT_BEGIN_NAMESPACE | - |
| 49 | | - |
| 50 | QGLPaintDevice::QGLPaintDevice() | - |
| 51 | : m_thisFBO(0) | - |
| 52 | { | - |
| 53 | } | 0 |
| 54 | | - |
| 55 | QGLPaintDevice::~QGLPaintDevice() | - |
| 56 | { | - |
| 57 | } | - |
| 58 | | - |
| 59 | int QGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const | - |
| 60 | { | - |
| 61 | switch(metric) { | - |
| 62 | case PdmWidth: | - |
| 63 | return size().width(); never executed: return size().width(); | 0 |
| 64 | case PdmHeight: | - |
| 65 | return size().height(); never executed: return size().height(); | 0 |
| 66 | case PdmDepth: { | - |
| 67 | const QGLFormat f = format(); never executed (the execution status of this line is deduced): const QGLFormat f = format(); | - |
| 68 | return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize(); never executed: return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize(); | 0 |
| 69 | } | - |
| 70 | default: | - |
| 71 | qWarning("QGLPaintDevice::metric() - metric %d not known", metric); never executed (the execution status of this line is deduced): QMessageLogger("qglpaintdevice.cpp", 71, __PRETTY_FUNCTION__).warning("QGLPaintDevice::metric() - metric %d not known", metric); | - |
| 72 | return 0; never executed: return 0; | 0 |
| 73 | } | - |
| 74 | } | 0 |
| 75 | | - |
| 76 | void QGLPaintDevice::beginPaint() | - |
| 77 | { | - |
| 78 | // Make sure our context is the current one: | - |
| 79 | QGLContext *ctx = context(); never executed (the execution status of this line is deduced): QGLContext *ctx = context(); | - |
| 80 | ctx->makeCurrent(); never executed (the execution status of this line is deduced): ctx->makeCurrent(); | - |
| 81 | | - |
| 82 | // Record the currently bound FBO so we can restore it again | - |
| 83 | // in endPaint() and bind this device's FBO | - |
| 84 | // | - |
| 85 | // Note: m_thisFBO could be zero if the paint device is not | - |
| 86 | // backed by an FBO (e.g. window back buffer). But there could | - |
| 87 | // be a previous FBO bound to the context which we need to | - |
| 88 | // explicitly unbind. Otherwise the painting will go into | - |
| 89 | // the previous FBO instead of to the window. | - |
| 90 | m_previousFBO = ctx->d_func()->current_fbo; never executed (the execution status of this line is deduced): m_previousFBO = ctx->d_func()->current_fbo; | - |
| 91 | | - |
| 92 | if (m_previousFBO != m_thisFBO) { never evaluated: m_previousFBO != m_thisFBO | 0 |
| 93 | ctx->d_ptr->current_fbo = m_thisFBO; never executed (the execution status of this line is deduced): ctx->d_ptr->current_fbo = m_thisFBO; | - |
| 94 | ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_thisFBO); never executed (the execution status of this line is deduced): ctx->contextHandle()->functions()->glBindFramebuffer(0x8D40, m_thisFBO); | - |
| 95 | } | 0 |
| 96 | | - |
| 97 | // Set the default fbo for the context to m_thisFBO so that | - |
| 98 | // if some raw GL code between beginNativePainting() and | - |
| 99 | // endNativePainting() calls QGLFramebufferObject::release(), | - |
| 100 | // painting will revert to the window surface's fbo. | - |
| 101 | ctx->d_ptr->default_fbo = m_thisFBO; never executed (the execution status of this line is deduced): ctx->d_ptr->default_fbo = m_thisFBO; | - |
| 102 | } | 0 |
| 103 | | - |
| 104 | void QGLPaintDevice::ensureActiveTarget() | - |
| 105 | { | - |
| 106 | QGLContext* ctx = context(); never executed (the execution status of this line is deduced): QGLContext* ctx = context(); | - |
| 107 | if (ctx != QGLContext::currentContext()) never evaluated: ctx != QGLContext::currentContext() | 0 |
| 108 | ctx->makeCurrent(); never executed: ctx->makeCurrent(); | 0 |
| 109 | | - |
| 110 | if (ctx->d_ptr->current_fbo != m_thisFBO) { never evaluated: ctx->d_ptr->current_fbo != m_thisFBO | 0 |
| 111 | ctx->d_ptr->current_fbo = m_thisFBO; never executed (the execution status of this line is deduced): ctx->d_ptr->current_fbo = m_thisFBO; | - |
| 112 | ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_thisFBO); never executed (the execution status of this line is deduced): ctx->contextHandle()->functions()->glBindFramebuffer(0x8D40, m_thisFBO); | - |
| 113 | } | 0 |
| 114 | | - |
| 115 | ctx->d_ptr->default_fbo = m_thisFBO; never executed (the execution status of this line is deduced): ctx->d_ptr->default_fbo = m_thisFBO; | - |
| 116 | } | 0 |
| 117 | | - |
| 118 | void QGLPaintDevice::endPaint() | - |
| 119 | { | - |
| 120 | // Make sure the FBO bound at beginPaint is re-bound again here: | - |
| 121 | QGLContext *ctx = context(); never executed (the execution status of this line is deduced): QGLContext *ctx = context(); | - |
| 122 | if (m_previousFBO != ctx->d_func()->current_fbo) { never evaluated: m_previousFBO != ctx->d_func()->current_fbo | 0 |
| 123 | ctx->d_ptr->current_fbo = m_previousFBO; never executed (the execution status of this line is deduced): ctx->d_ptr->current_fbo = m_previousFBO; | - |
| 124 | ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_previousFBO); never executed (the execution status of this line is deduced): ctx->contextHandle()->functions()->glBindFramebuffer(0x8D40, m_previousFBO); | - |
| 125 | } | 0 |
| 126 | | - |
| 127 | ctx->d_ptr->default_fbo = 0; never executed (the execution status of this line is deduced): ctx->d_ptr->default_fbo = 0; | - |
| 128 | } | 0 |
| 129 | | - |
| 130 | QGLFormat QGLPaintDevice::format() const | - |
| 131 | { | - |
| 132 | return context()->format(); never executed: return context()->format(); | 0 |
| 133 | } | - |
| 134 | | - |
| 135 | bool QGLPaintDevice::alphaRequested() const | - |
| 136 | { | - |
| 137 | return context()->d_func()->reqFormat.alpha(); never executed: return context()->d_func()->reqFormat.alpha(); | 0 |
| 138 | } | - |
| 139 | | - |
| 140 | bool QGLPaintDevice::isFlipped() const | - |
| 141 | { | - |
| 142 | return false; never executed: return false; | 0 |
| 143 | } | - |
| 144 | | - |
| 145 | ////////////////// QGLWidgetGLPaintDevice ////////////////// | - |
| 146 | | - |
| 147 | QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() | - |
| 148 | { | - |
| 149 | } | - |
| 150 | | - |
| 151 | QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const | - |
| 152 | { | - |
| 153 | return glWidget->paintEngine(); never executed: return glWidget->paintEngine(); | 0 |
| 154 | } | - |
| 155 | | - |
| 156 | void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) | - |
| 157 | { | - |
| 158 | glWidget = w; never executed (the execution status of this line is deduced): glWidget = w; | - |
| 159 | } | 0 |
| 160 | | - |
| 161 | void QGLWidgetGLPaintDevice::beginPaint() | - |
| 162 | { | - |
| 163 | QGLPaintDevice::beginPaint(); never executed (the execution status of this line is deduced): QGLPaintDevice::beginPaint(); | - |
| 164 | if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { never evaluated: !glWidget->d_func()->disable_clear_on_painter_begin never evaluated: glWidget->autoFillBackground() | 0 |
| 165 | if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) never evaluated: glWidget->testAttribute(Qt::WA_TranslucentBackground) | 0 |
| 166 | glClearColor(0.0, 0.0, 0.0, 0.0); never executed: glClearColor(0.0, 0.0, 0.0, 0.0); | 0 |
| 167 | else { | - |
| 168 | const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color(); never executed (the execution status of this line is deduced): const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color(); | - |
| 169 | float alpha = c.alphaF(); never executed (the execution status of this line is deduced): float alpha = c.alphaF(); | - |
| 170 | glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); never executed (the execution status of this line is deduced): glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); | - |
| 171 | } | 0 |
| 172 | if (context()->d_func()->workaround_needsFullClearOnEveryFrame) never evaluated: context()->d_func()->workaround_needsFullClearOnEveryFrame | 0 |
| 173 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); never executed: glClear(0x00004000 | 0x00000100 | 0x00000400); | 0 |
| 174 | else | - |
| 175 | glClear(GL_COLOR_BUFFER_BIT); never executed: glClear(0x00004000); | 0 |
| 176 | } | - |
| 177 | } | 0 |
| 178 | | - |
| 179 | void QGLWidgetGLPaintDevice::endPaint() | - |
| 180 | { | - |
| 181 | if (glWidget->autoBufferSwap()) never evaluated: glWidget->autoBufferSwap() | 0 |
| 182 | glWidget->swapBuffers(); never executed: glWidget->swapBuffers(); | 0 |
| 183 | QGLPaintDevice::endPaint(); never executed (the execution status of this line is deduced): QGLPaintDevice::endPaint(); | - |
| 184 | } | 0 |
| 185 | | - |
| 186 | | - |
| 187 | QSize QGLWidgetGLPaintDevice::size() const | - |
| 188 | { | - |
| 189 | return glWidget->size(); never executed: return glWidget->size(); | 0 |
| 190 | } | - |
| 191 | | - |
| 192 | QGLContext* QGLWidgetGLPaintDevice::context() const | - |
| 193 | { | - |
| 194 | return const_cast<QGLContext*>(glWidget->context()); never executed: return const_cast<QGLContext*>(glWidget->context()); | 0 |
| 195 | } | - |
| 196 | | - |
| 197 | // returns the QGLPaintDevice for the given QPaintDevice | - |
| 198 | QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) | - |
| 199 | { | - |
| 200 | QGLPaintDevice* glpd = 0; never executed (the execution status of this line is deduced): QGLPaintDevice* glpd = 0; | - |
| 201 | | - |
| 202 | switch(pd->devType()) { | - |
| 203 | case QInternal::Widget: | - |
| 204 | // Should not be called on a non-gl widget: | - |
| 205 | Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd))); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 206 | glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice); never executed (the execution status of this line is deduced): glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice); | - |
| 207 | break; | 0 |
| 208 | case QInternal::Pbuffer: | - |
| 209 | glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice); never executed (the execution status of this line is deduced): glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice); | - |
| 210 | break; | 0 |
| 211 | case QInternal::FramebufferObject: | - |
| 212 | glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice); never executed (the execution status of this line is deduced): glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice); | - |
| 213 | break; | 0 |
| 214 | case QInternal::Pixmap: { | - |
| 215 | qWarning("Pixmap type not supported for GL rendering"); never executed (the execution status of this line is deduced): QMessageLogger("qglpaintdevice.cpp", 215, __PRETTY_FUNCTION__).warning("Pixmap type not supported for GL rendering"); | - |
| 216 | break; | 0 |
| 217 | } | - |
| 218 | default: | - |
| 219 | qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); never executed (the execution status of this line is deduced): QMessageLogger("qglpaintdevice.cpp", 219, __PRETTY_FUNCTION__).warning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); | - |
| 220 | break; | 0 |
| 221 | } | - |
| 222 | | - |
| 223 | return glpd; never executed: return glpd; | 0 |
| 224 | } | - |
| 225 | | - |
| 226 | QT_END_NAMESPACE | - |
| 227 | | - |
| | |