1 | // Copyright (C) 2018 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 QSGCOMPRESSEDATLASTEXTURE_P_H |
5 | #define QSGCOMPRESSEDATLASTEXTURE_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 <QtCore/QSize> |
19 | |
20 | #include <QtQuick/QSGTexture> |
21 | #include <QtQuick/private/qsgareaallocator_p.h> |
22 | #include <QtQuick/private/qsgrhiatlastexture_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QSGCompressedTextureFactory; |
27 | |
28 | namespace QSGCompressedAtlasTexture { |
29 | |
30 | class Texture; |
31 | |
32 | class Atlas : public QSGRhiAtlasTexture::AtlasBase |
33 | { |
34 | public: |
35 | Atlas(QSGDefaultRenderContext *rc, const QSize &size, uint format); |
36 | ~Atlas(); |
37 | |
38 | bool generateTexture() override; |
39 | void enqueueTextureUpload(QSGRhiAtlasTexture::TextureBase *t, |
40 | QRhiResourceUpdateBatch *rcub) override; |
41 | |
42 | Texture *create(QByteArrayView data, const QSize &size); |
43 | |
44 | uint format() const { return m_format; } |
45 | |
46 | private: |
47 | uint m_format; |
48 | }; |
49 | |
50 | class Texture : public QSGRhiAtlasTexture::TextureBase |
51 | { |
52 | Q_OBJECT |
53 | public: |
54 | Texture(Atlas *atlas, const QRect &textureRect, QByteArrayView data, const QSize &size); |
55 | ~Texture(); |
56 | |
57 | QSize textureSize() const override { return m_size; } |
58 | bool hasAlphaChannel() const override; |
59 | bool hasMipmaps() const override { return false; } |
60 | |
61 | QRectF normalizedTextureSubRect() const override { return m_texture_coords_rect; } |
62 | |
63 | QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *) const override; |
64 | |
65 | const QByteArray &data() const { return m_data; } |
66 | int sizeInBytes() const { return m_data.size(); } |
67 | |
68 | private: |
69 | QRectF m_texture_coords_rect; |
70 | mutable QSGTexture *m_nonatlas_texture; |
71 | QByteArray m_data; |
72 | QSize m_size; |
73 | }; |
74 | |
75 | } |
76 | |
77 | QT_END_NAMESPACE |
78 | |
79 | #endif |
80 |