diff options
Diffstat (limited to 'src/gui/painting/qrhibackingstore.cpp')
-rw-r--r-- | src/gui/painting/qrhibackingstore.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/gui/painting/qrhibackingstore.cpp b/src/gui/painting/qrhibackingstore.cpp index fd7045e3f6..586dfb44a4 100644 --- a/src/gui/painting/qrhibackingstore.cpp +++ b/src/gui/painting/qrhibackingstore.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qrhibackingstore_p.h" +#include <private/qimage_p.h> QT_BEGIN_NAMESPACE @@ -14,17 +15,24 @@ QRhiBackingStore::~QRhiBackingStore() { } -void QRhiBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QRhiBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(region); Q_UNUSED(offset); - if (window != this->window()) + if (flushedWindow->surfaceType() != window()->surfaceType()) { + qWarning() << "Cannot flush child window" << flushedWindow + << "with surface type" << flushedWindow->surfaceType() << ";" + << "Must match" << window()->surfaceType() << "of" << window(); + + // FIXME: Support different surface types by not tying the + // RHI config to the backing store itself (per window config). return; + } if (!rhi()) { QPlatformBackingStoreRhiConfig rhiConfig; - switch (window->surfaceType()) { + switch (window()->surfaceType()) { case QSurface::OpenGLSurface: rhiConfig.setApi(QPlatformBackingStoreRhiConfig::OpenGL); break; @@ -40,7 +48,21 @@ void QRhiBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin static QPlatformTextureList emptyTextureList; bool translucentBackground = m_image.hasAlphaChannel(); - rhiFlush(window, window->devicePixelRatio(), region, offset, &emptyTextureList, translucentBackground); + rhiFlush(flushedWindow, flushedWindow->devicePixelRatio(), + region, offset, &emptyTextureList, translucentBackground); +} + +QImage::Format QRhiBackingStore::format() const +{ + QImage::Format fmt = QRasterBackingStore::format(); + + // With render-to-texture widgets and QRhi-based flushing the backingstore + // image must have an alpha channel. Hence upgrading the format. Matches + // what other platforms (Windows, xcb) do. + if (QImage::toPixelFormat(fmt).alphaUsage() != QPixelFormat::UsesAlpha) + fmt = qt_maybeDataCompatibleAlphaVersion(fmt); + + return fmt; } QT_END_NAMESPACE |