1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
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 QT3DRENDER_TEXTUREDATA_P_H |
5 | #define QT3DRENDER_TEXTUREDATA_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 for the convenience |
12 | // of other Qt classes. 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 "qtextureimagedata.h" |
19 | #include <Qt3DRender/private/qt3drender_global_p.h> |
20 | #include <functional> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | namespace Qt3DRender { |
25 | |
26 | class Q_3DRENDERSHARED_PRIVATE_EXPORT QTextureImageDataPrivate |
27 | { |
28 | public: |
29 | QTextureImageDataPrivate(); |
30 | |
31 | void setData(const QByteArray &data, int blockSize, bool isCompressed); |
32 | void setData(const QByteArray &data, |
33 | std::function<QByteArray(QByteArray, int, int, int)> , |
34 | bool isCompressed); |
35 | |
36 | bool setCompressedFile(const QString &source); |
37 | |
38 | QByteArray data(int layer, int face, int mipmapLevel) const; |
39 | |
40 | int m_width; |
41 | int m_height; |
42 | int m_depth; |
43 | int m_layers; |
44 | int m_faces; |
45 | int m_mipLevels; |
46 | int m_blockSize; |
47 | int m_alignment; |
48 | |
49 | QOpenGLTexture::Target m_target; |
50 | QOpenGLTexture::TextureFormat m_format; |
51 | QOpenGLTexture::PixelFormat m_pixelFormat; |
52 | QOpenGLTexture::PixelType m_pixelType; |
53 | |
54 | bool m_isCompressed; |
55 | // ### Qt 6 |
56 | // QTextureImageData was originally written with assumptions around the internal data format |
57 | // matching dds layout. This is an ugly, but easy, way to add basic ktx support without any |
58 | // public API changes. Consider https://codereview.qt-project.org/#/c/178474/ for Qt 6. |
59 | bool m_isKtx; |
60 | QByteArray m_data; |
61 | std::function<QByteArray(QByteArray rawData, int layer, int face, int mipmapLevel)> ; |
62 | |
63 | static QTextureImageDataPrivate *get(QTextureImageData *imageData); |
64 | |
65 | private: |
66 | int ddsLayerSize() const; |
67 | int ddsFaceSize() const; |
68 | int mipmapLevelSize(int level) const; |
69 | QByteArray ktxData(int layer, int face, int mipmapLevel) const; |
70 | }; |
71 | |
72 | } // namespace Qt3DRender |
73 | |
74 | |
75 | QT_END_NAMESPACE |
76 | |
77 | #endif // QT3DRENDER_TEXTUREDATA_P_H |
78 | |