diff options
author | Andy Nichols <andy.nichols@qt.io> | 2016-06-07 12:57:04 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-07 22:36:20 +0000 |
commit | 0201c7dd3fbbe2a3ce9e6c6d91ae3c841e103971 (patch) | |
tree | 71e1c18f87e5919948a2a4071c03836825eb279d /src/quick/scenegraph/adaptations | |
parent | ad5b72ab28ad91a5be498f0424cdf50678574ff8 (diff) |
Software Adaptation: Obey QQuickWindow::TextureIsOpaque flag
Force a image format conversion when requesting an Opaque texture.
There seems to be no way to do this with QPixmap::fromImage(...) so a
copy of the QImage must be made first which is unfortunate. This is
further evidence that the Texture should be QImage based instead of
QPixmap based by default.
Change-Id: I89fb380e8e786d4ff93f01eb6466e118c2851f7a
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/quick/scenegraph/adaptations')
3 files changed, 11 insertions, 6 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp index dee1ac8954..ce726e342b 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp @@ -153,8 +153,7 @@ void QSGSoftwareRenderContext::invalidate() QSGTexture *QSGSoftwareRenderContext::createTexture(const QImage &image, uint flags) const { - Q_UNUSED(flags) - return new QSGSoftwarePixmapTexture(image); + return new QSGSoftwarePixmapTexture(image, flags); } QSGRenderer *QSGSoftwareRenderContext::createRenderer() diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp index e04c400af3..534a0a4ec6 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp @@ -41,11 +41,17 @@ QT_BEGIN_NAMESPACE -QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QImage &image) +QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QImage &image, uint flags) +{ // Prevent pixmap format conversion to reduce memory consumption // and surprises in calling code. (See QTBUG-47328) - : m_pixmap(QPixmap::fromImage(image, Qt::NoFormatConversion)) -{ + if (flags & QSGRenderContext::CreateTexture_Alpha) { + //If texture should have an alpha + m_pixmap = QPixmap::fromImage(image, Qt::NoFormatConversion); + } else { + //Force opaque texture + m_pixmap = QPixmap::fromImage(image.convertToFormat(QImage::Format_RGB32), Qt::NoFormatConversion); + } } QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QPixmap &pixmap) diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h index 01bfe19471..034fa25da9 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h @@ -59,7 +59,7 @@ class QSGSoftwarePixmapTexture : public QSGTexture { Q_OBJECT public: - QSGSoftwarePixmapTexture(const QImage &image); + QSGSoftwarePixmapTexture(const QImage &image, uint flags); QSGSoftwarePixmapTexture(const QPixmap &pixmap); int textureId() const override; |