| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | QOpenGLCompositorBackingStore::QOpenGLCompositorBackingStore(QWindow *window) | - | ||||||||||||||||||
| 9 | : QPlatformBackingStore(window), | - | ||||||||||||||||||
| 10 | m_window(window), | - | ||||||||||||||||||
| 11 | m_bsTexture(0), | - | ||||||||||||||||||
| 12 | m_bsTextureContext(0), | - | ||||||||||||||||||
| 13 | m_textures(new QPlatformTextureList), | - | ||||||||||||||||||
| 14 | m_lockedWidgetTextures(0) | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore() | - | ||||||||||||||||||
| 19 | { | - | ||||||||||||||||||
| 20 | if (m_bsTexture
| 0 | ||||||||||||||||||
| 21 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | QScopedPointer<QOffscreenSurface> tempSurface; | - | ||||||||||||||||||
| 26 | if (!ctx
| 0 | ||||||||||||||||||
| 27 | ctx = QOpenGLCompositor::instance()->context(); | - | ||||||||||||||||||
| 28 | tempSurface.reset(new QOffscreenSurface); | - | ||||||||||||||||||
| 29 | tempSurface->setFormat(ctx->format()); | - | ||||||||||||||||||
| 30 | tempSurface->create(); | - | ||||||||||||||||||
| 31 | ctx->makeCurrent(tempSurface.data()); | - | ||||||||||||||||||
| 32 | } never executed: end of block | 0 | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | if (ctx
| 0 | ||||||||||||||||||
| 35 | glDeleteTextures(1, &m_bsTexture); never executed: glDeleteTextures(1, &m_bsTexture); | 0 | ||||||||||||||||||
| 36 | else | - | ||||||||||||||||||
| 37 | QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__).warning("QOpenGLCompositorBackingStore: Texture is not valid in the current context"); never executed: QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__).warning("QOpenGLCompositorBackingStore: Texture is not valid in the current context"); | 0 | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | if (tempSurface
| 0 | ||||||||||||||||||
| 40 | ctx->doneCurrent(); never executed: ctx->doneCurrent(); | 0 | ||||||||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | delete m_textures; | - | ||||||||||||||||||
| 44 | } never executed: end of block | 0 | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QPaintDevice *QOpenGLCompositorBackingStore::paintDevice() | - | ||||||||||||||||||
| 47 | { | - | ||||||||||||||||||
| 48 | return never executed: &m_image;return &m_image;never executed: return &m_image; | 0 | ||||||||||||||||||
| 49 | } | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | void QOpenGLCompositorBackingStore::updateTexture() | - | ||||||||||||||||||
| 52 | { | - | ||||||||||||||||||
| 53 | if (!m_bsTexture
| 0 | ||||||||||||||||||
| 54 | m_bsTextureContext = QOpenGLContext::currentContext(); | - | ||||||||||||||||||
| 55 | ((!(m_bsTextureContext)) ? qt_assert("m_bsTextureContext",__FILE__,125) : qt_noop()); | - | ||||||||||||||||||
| 56 | glGenTextures(1, &m_bsTexture); | - | ||||||||||||||||||
| 57 | glBindTexture(0x0DE1, m_bsTexture); | - | ||||||||||||||||||
| 58 | glTexParameterf(0x0DE1, 0x2801, 0x2600); | - | ||||||||||||||||||
| 59 | glTexParameterf(0x0DE1, 0x2800, 0x2600); | - | ||||||||||||||||||
| 60 | glTexParameterf(0x0DE1, 0x2802, 0x812F); | - | ||||||||||||||||||
| 61 | glTexParameterf(0x0DE1, 0x2803, 0x812F); | - | ||||||||||||||||||
| 62 | glTexImage2D(0x0DE1, 0, 0x1908, m_image.width(), m_image.height(), 0, 0x1908, 0x1401, 0); | - | ||||||||||||||||||
| 63 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 64 | glBindTexture(0x0DE1, m_bsTexture); | - | ||||||||||||||||||
| 65 | } never executed: end of block | 0 | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | if (!m_dirty.isNull()
| 0 | ||||||||||||||||||
| 68 | QRegion fixed; | - | ||||||||||||||||||
| 69 | QRect imageRect = m_image.rect(); | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||||||||
| 72 | if (!ctx->isOpenGLES()
| 0 | ||||||||||||||||||
| 73 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_dirty.rects())>::type> _container_((m_dirty.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 74 | QRect r = imageRect & rect; | - | ||||||||||||||||||
| 75 | glPixelStorei(0x0CF2, m_image.width()); | - | ||||||||||||||||||
| 76 | glTexSubImage2D(0x0DE1, 0, r.x(), r.y(), r.width(), r.height(), 0x1908, 0x1401, | - | ||||||||||||||||||
| 77 | m_image.constScanLine(r.y()) + r.x() * 4); | - | ||||||||||||||||||
| 78 | glPixelStorei(0x0CF2, 0); | - | ||||||||||||||||||
| 79 | } never executed: end of block | 0 | ||||||||||||||||||
| 80 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 81 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_dirty.rects())>::type> _container_((m_dirty.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | QRect r = imageRect & rect; | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | if (r.width() >= imageRect.width() / 2
| 0 | ||||||||||||||||||
| 88 | r.setX(0); | - | ||||||||||||||||||
| 89 | r.setWidth(imageRect.width()); | - | ||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | fixed |= r; | - | ||||||||||||||||||
| 93 | } never executed: end of block | 0 | ||||||||||||||||||
| 94 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(fixed.rects())>::type> _container_((fixed.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | if (rect.width() == imageRect.width()
| 0 | ||||||||||||||||||
| 98 | glTexSubImage2D(0x0DE1, 0, 0, rect.y(), rect.width(), rect.height(), 0x1908, 0x1401, | - | ||||||||||||||||||
| 99 | m_image.constScanLine(rect.y())); | - | ||||||||||||||||||
| 100 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 101 | glTexSubImage2D(0x0DE1, 0, rect.x(), rect.y(), rect.width(), rect.height(), 0x1908, 0x1401, | - | ||||||||||||||||||
| 102 | m_image.copy(rect).constBits()); | - | ||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||
| 104 | } | - | ||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | m_dirty = QRegion(); | - | ||||||||||||||||||
| 108 | } never executed: end of block | 0 | ||||||||||||||||||
| 109 | } never executed: end of block | 0 | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) | - | ||||||||||||||||||
| 112 | { | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | (void)region;; | - | ||||||||||||||||||
| 116 | (void)offset;; | - | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); | - | ||||||||||||||||||
| 119 | QOpenGLContext *dstCtx = compositor->context(); | - | ||||||||||||||||||
| 120 | ((!(dstCtx)) ? qt_assert("dstCtx",__FILE__,190) : qt_noop()); | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | QWindow *dstWin = compositor->targetWindow(); | - | ||||||||||||||||||
| 123 | if (!dstWin
| 0 | ||||||||||||||||||
| 124 | return; never executed: return; | 0 | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | dstCtx->makeCurrent(dstWin); | - | ||||||||||||||||||
| 127 | updateTexture(); | - | ||||||||||||||||||
| 128 | m_textures->clear(); | - | ||||||||||||||||||
| 129 | m_textures->appendTexture(nullptr, m_bsTexture, window->geometry()); | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | compositor->update(); | - | ||||||||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, | - | ||||||||||||||||||
| 135 | QPlatformTextureList *textures, QOpenGLContext *context, | - | ||||||||||||||||||
| 136 | bool translucentBackground) | - | ||||||||||||||||||
| 137 | { | - | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | (void)region;; | - | ||||||||||||||||||
| 141 | (void)offset;; | - | ||||||||||||||||||
| 142 | (void)context;; | - | ||||||||||||||||||
| 143 | (void)translucentBackground;; | - | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); | - | ||||||||||||||||||
| 146 | QOpenGLContext *dstCtx = compositor->context(); | - | ||||||||||||||||||
| 147 | ((!(dstCtx)) ? qt_assert("dstCtx",__FILE__,217) : qt_noop()); | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | ((!(context->shareGroup() == dstCtx->shareGroup())) ? qt_assert("context->shareGroup() == dstCtx->shareGroup()",__FILE__,221) : qt_noop()); | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | QWindow *dstWin = compositor->targetWindow(); | - | ||||||||||||||||||
| 154 | if (!dstWin
| 0 | ||||||||||||||||||
| 155 | return; never executed: return; | 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | dstCtx->makeCurrent(dstWin); | - | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | QWindowPrivate::get(window)->lastComposeTime.start(); | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | m_textures->clear(); | - | ||||||||||||||||||
| 162 | for (int i = 0; i < textures->count()
| 0 | ||||||||||||||||||
| 163 | m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i), never executed: m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i), textures->clipRect(i), textures->flags(i)); | 0 | ||||||||||||||||||
| 164 | textures->clipRect(i), textures->flags(i)); never executed: m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i), textures->clipRect(i), textures->flags(i)); | 0 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | updateTexture(); | - | ||||||||||||||||||
| 167 | m_textures->appendTexture(nullptr, m_bsTexture, window->geometry()); | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | textures->lock(true); | - | ||||||||||||||||||
| 170 | m_lockedWidgetTextures = textures; | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | compositor->update(); | - | ||||||||||||||||||
| 173 | } never executed: end of block | 0 | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | void QOpenGLCompositorBackingStore::notifyComposited() | - | ||||||||||||||||||
| 176 | { | - | ||||||||||||||||||
| 177 | if (m_lockedWidgetTextures
| 0 | ||||||||||||||||||
| 178 | QPlatformTextureList *textureList = m_lockedWidgetTextures; | - | ||||||||||||||||||
| 179 | m_lockedWidgetTextures = 0; | - | ||||||||||||||||||
| 180 | textureList->lock(false); | - | ||||||||||||||||||
| 181 | } never executed: end of block | 0 | ||||||||||||||||||
| 182 | } never executed: end of block | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | void QOpenGLCompositorBackingStore::beginPaint(const QRegion ®ion) | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | m_dirty |= region; | - | ||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | if (m_image.hasAlphaChannel()
| 0 | ||||||||||||||||||
| 189 | QPainter p(&m_image); | - | ||||||||||||||||||
| 190 | p.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||
| 191 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(region.rects())>::type> _container_((region.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &r = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||
| 192 | p.fillRect(r, Qt::transparent); never executed: p.fillRect(r, Qt::transparent); | 0 | ||||||||||||||||||
| 193 | } never executed: end of block | 0 | ||||||||||||||||||
| 194 | } never executed: end of block | 0 | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &staticContents) | - | ||||||||||||||||||
| 197 | { | - | ||||||||||||||||||
| 198 | (void)staticContents;; | - | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); | - | ||||||||||||||||||
| 201 | QOpenGLContext *dstCtx = compositor->context(); | - | ||||||||||||||||||
| 202 | QWindow *dstWin = compositor->targetWindow(); | - | ||||||||||||||||||
| 203 | if (!dstWin
| 0 | ||||||||||||||||||
| 204 | return; never executed: return; | 0 | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | m_image = QImage(size, QImage::Format_RGBA8888); | - | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | m_window->create(); | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | dstCtx->makeCurrent(dstWin); | - | ||||||||||||||||||
| 211 | if (m_bsTexture
| 0 | ||||||||||||||||||
| 212 | glDeleteTextures(1, &m_bsTexture); | - | ||||||||||||||||||
| 213 | m_bsTexture = 0; | - | ||||||||||||||||||
| 214 | m_bsTextureContext = nullptr; | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | } never executed: end of block | 0 | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | QImage QOpenGLCompositorBackingStore::toImage() const | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | return never executed: m_image;return m_image;never executed: return m_image; | 0 | ||||||||||||||||||
| 221 | } | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |