diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-10 10:38:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-31 22:10:48 +0000 |
commit | 0a63d5fed6e020e81d3c570d299d1292c33fa284 (patch) | |
tree | 82711503fda935a931110035ff384bb34697760a /src/widgets/kernel/qwidget.cpp | |
parent | 7e2177464fce7bd2bb2a09d57bd9a44f6746bd2b (diff) |
Render QOpenGLWidget/QQuickWidget with AlwaysStackOnTop
QWidget::render was ignoring QOpenGLWidget/QQuickWidget with
AlwaysStackOnTop set, because normally they will be composited later,
however when not doing a backing store render, they need to be painted
right away as there is no later.
Task-number: QTBUG-67533
Change-Id: I08e2eeee5e7a8f0dbbf43f659fcfa9068e8c46d1
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 12dab9870a..41f9d69c12 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5593,21 +5593,23 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (renderToTexture) { // This widget renders into a texture which is composed later. We just need to // punch a hole in the backingstore, so the texture will be visible. - if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) { - beginBackingStorePainting(); - if (backingStore) { - QPainter p(q); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(q->rect(), Qt::transparent); - } else { - QImage img = grabFramebuffer(); - QPainter p(q); - // We are not drawing to a backingstore: fall back to QImage - p.drawImage(q->rect(), img); - skipPaintEvent = true; - } - endBackingStorePainting(); + beginBackingStorePainting(); + if (!q->testAttribute(Qt::WA_AlwaysStackOnTop) && backingStore) { + QPainter p(q); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(q->rect(), Qt::transparent); + } else if (!backingStore) { + // We are not drawing to a backingstore: fall back to QImage + QImage img = grabFramebuffer(); + // grabFramebuffer() always sets the format to RGB32 + // regardless of whether it is transparent or not. + if (img.format() == QImage::Format_RGB32) + img.reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied); + QPainter p(q); + p.drawImage(q->rect(), img); + skipPaintEvent = true; } + endBackingStorePainting(); if (renderToTextureReallyDirty) renderToTextureReallyDirty = 0; else |