| 1 | // Copyright (C) 2025 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGLIGHTMAPIO_H |
| 5 | #define QSSGLIGHTMAPIO_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 "qtquick3druntimerenderexports.h" |
| 19 | |
| 20 | #include <QByteArray> |
| 21 | #include <QMap> |
| 22 | #include <QSharedPointer> |
| 23 | #include <QIODevice> |
| 24 | #include <QVariantMap> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | struct QSSGLoadedTexture; |
| 29 | struct QSSGRenderTextureFormat; |
| 30 | |
| 31 | enum class QSSGLightmapIODataTag : quint32 { |
| 32 | Unset = 0, |
| 33 | Mask, |
| 34 | Texture_Final, |
| 35 | Texture_Direct, |
| 36 | Texture_Indirect, |
| 37 | Metadata, |
| 38 | Mesh, |
| 39 | // ... |
| 40 | Count |
| 41 | }; |
| 42 | |
| 43 | struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGLightmapLoader |
| 44 | { |
| 45 | ~QSSGLightmapLoader(); |
| 46 | |
| 47 | static QSharedPointer<QSSGLightmapLoader> open(const QSharedPointer<QIODevice> &stream); |
| 48 | static QSharedPointer<QSSGLightmapLoader> open(const QString &path); |
| 49 | |
| 50 | QByteArray readF32Image(const QString &key, QSSGLightmapIODataTag tag) const; |
| 51 | QByteArray readU32Image(const QString &key, QSSGLightmapIODataTag tag) const; |
| 52 | QByteArray readData(const QString &key, QSSGLightmapIODataTag tag) const; |
| 53 | QVariantMap readMetadata(const QString &key) const; |
| 54 | |
| 55 | QList<std::pair<QString, QSSGLightmapIODataTag>> getKeys() const; |
| 56 | static QSSGLoadedTexture *createTexture(QSharedPointer<QIODevice> stream, const QSSGRenderTextureFormat &format, const QString &key); |
| 57 | |
| 58 | private: |
| 59 | QSSGLightmapLoader(); |
| 60 | Q_DISABLE_COPY(QSSGLightmapLoader) |
| 61 | |
| 62 | struct QSSGLightmapIOPrivate *d = nullptr; |
| 63 | }; |
| 64 | |
| 65 | struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGLightmapWriter |
| 66 | { |
| 67 | ~QSSGLightmapWriter(); |
| 68 | |
| 69 | static QSharedPointer<QSSGLightmapWriter> open(const QSharedPointer<QIODevice> &stream); |
| 70 | static QSharedPointer<QSSGLightmapWriter> open(const QString &path); |
| 71 | |
| 72 | bool writeF32Image(const QString &key, QSSGLightmapIODataTag tag, const QByteArray &imageFP32); |
| 73 | bool writeU32Image(const QString &key, QSSGLightmapIODataTag tag, const QByteArray &imageU32); |
| 74 | bool writeData(const QString &key, QSSGLightmapIODataTag tag, const QByteArray &buffer); |
| 75 | bool writeMetadata(const QString &key, const QVariantMap &metadata); |
| 76 | |
| 77 | bool close() const; |
| 78 | |
| 79 | private: |
| 80 | Q_DISABLE_COPY(QSSGLightmapWriter) |
| 81 | QSSGLightmapWriter(); |
| 82 | |
| 83 | struct QSSGLightmapIOPrivate *d = nullptr; |
| 84 | }; |
| 85 | |
| 86 | QT_END_NAMESPACE |
| 87 | |
| 88 | #endif // QSSGLIGHTMAPIO_H |
| 89 | |