| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qsgsoftwarepixmaptexture_p.h" |
| 5 | #include <private/qsgcontext_p.h> |
| 6 | |
| 7 | QT_BEGIN_NAMESPACE |
| 8 | |
| 9 | QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QImage &image, uint flags) |
| 10 | { |
| 11 | // Prevent pixmap format conversion to reduce memory consumption |
| 12 | // and surprises in calling code. (See QTBUG-47328) |
| 13 | if (flags & QSGRenderContext::CreateTexture_Alpha) { |
| 14 | //If texture should have an alpha |
| 15 | m_pixmap = QPixmap::fromImage(image, flags: Qt::NoFormatConversion); |
| 16 | } else { |
| 17 | //Force opaque texture |
| 18 | m_pixmap = QPixmap::fromImage(image: image.convertToFormat(f: QImage::Format_RGB32), flags: Qt::NoFormatConversion); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QPixmap &pixmap) |
| 23 | : m_pixmap(pixmap) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | QSize QSGSoftwarePixmapTexture::textureSize() const |
| 28 | { |
| 29 | return m_pixmap.size(); |
| 30 | } |
| 31 | |
| 32 | bool QSGSoftwarePixmapTexture::hasAlphaChannel() const |
| 33 | { |
| 34 | return m_pixmap.hasAlphaChannel(); |
| 35 | } |
| 36 | |
| 37 | bool QSGSoftwarePixmapTexture::hasMipmaps() const |
| 38 | { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | qint64 QSGSoftwarePixmapTexture::comparisonKey() const |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | QT_END_NAMESPACE |
| 48 | |
| 49 | #include "moc_qsgsoftwarepixmaptexture_p.cpp" |
| 50 |
