1// Copyright (C) 2017 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#ifndef QSGCOMPRESSEDTEXTURE_P_H
5#define QSGCOMPRESSEDTEXTURE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qtexturefiledata_p.h>
19#include <private/qsgcontext_p.h>
20#include <private/qsgtexture_p.h>
21#include <rhi/qrhi.h>
22#include <QQuickTextureFactory>
23#include <QOpenGLFunctions>
24
25QT_BEGIN_NAMESPACE
26
27Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TEXTUREIO);
28
29class Q_QUICK_PRIVATE_EXPORT QSGCompressedTexture : public QSGTexture
30{
31 Q_OBJECT
32public:
33 QSGCompressedTexture(const QTextureFileData& texData);
34 virtual ~QSGCompressedTexture();
35
36 QSize textureSize() const override;
37 bool hasAlphaChannel() const override;
38 bool hasMipmaps() const override;
39
40 qint64 comparisonKey() const override;
41 QRhiTexture *rhiTexture() const override;
42 void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
43
44 QTextureFileData textureData() const;
45
46 struct FormatInfo
47 {
48 QRhiTexture::Format rhiFormat;
49 bool isSRGB;
50 };
51 static FormatInfo formatInfo(quint32 glTextureFormat);
52 static bool formatIsOpaque(quint32 glTextureFormat);
53
54protected:
55 QTextureFileData m_textureData;
56 QSize m_size;
57 QRhiTexture *m_texture = nullptr;
58 bool m_hasAlpha = false;
59 bool m_uploaded = false;
60};
61
62namespace QSGOpenGLAtlasTexture {
63 class Manager;
64}
65
66class Q_QUICK_PRIVATE_EXPORT QSGCompressedTextureFactory : public QQuickTextureFactory
67{
68public:
69 QSGCompressedTextureFactory(const QTextureFileData& texData);
70 QSGTexture *createTexture(QQuickWindow *) const override;
71 int textureByteCount() const override;
72 QSize textureSize() const override;
73
74 const QTextureFileData *textureData() const { return &m_textureData; }
75
76protected:
77 QTextureFileData m_textureData;
78};
79
80QT_END_NAMESPACE
81
82#endif // QSGCOMPRESSEDTEXTURE_P_H
83

source code of qtdeclarative/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h