From e65a79a6e4898a19693eb5f65370f0f4c26db3f3 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Jun 2014 12:55:34 +0200 Subject: [PATCH] Enablers for QQuickWidget render() support. Add a QImage based fallback for renderToTexture widgets, and use that when rendering to something else than a QWidgetBackingStore. Change-Id: I415a3a27c4ecb4ddbac45181c5a568b01ac5cb7a Task-number: QTBUG-39562 Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidget.cpp | 9 +++++++-- src/widgets/kernel/qwidget_p.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 311f9547a1..a1f3fbe8db 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5506,8 +5506,13 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP // 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. QPainter p(q); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(q->rect(), Qt::transparent); + if (backingStore) { + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(q->rect(), Qt::transparent); + } else { + // We are not drawing to a backingstore: fall back to QImage + p.drawImage(q->rect(), grabFramebuffer()); + } } else { //actually send the paint event QPaintEvent e(toBePainted); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 14831efca8..6520832943 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -627,7 +627,7 @@ public: #ifndef QT_NO_OPENGL virtual GLuint textureId() const { return 0; } - + virtual QImage grabFramebuffer() const { return QImage(); } void setRenderToTexture() { renderToTexture = true; setTextureChildSeen(); } void setTextureChildSeen() {