1// Copyright (C) 2021 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 QTEXTUREFILEDATA_P_H
5#define QTEXTUREFILEDATA_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 <QtGui/qtguiglobal.h>
19#include <QSharedDataPointer>
20#include <QLoggingCategory>
21#include <QDebug>
22#include <private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26Q_DECLARE_LOGGING_CATEGORY(lcQtGuiTextureIO)
27
28class QTextureFileDataPrivate;
29
30class Q_GUI_EXPORT QTextureFileData
31{
32public:
33 enum Mode { ByteArrayMode, ImageMode };
34
35 QTextureFileData(Mode mode = ByteArrayMode);
36 QTextureFileData(const QTextureFileData &other);
37 QTextureFileData &operator=(const QTextureFileData &other);
38 ~QTextureFileData();
39
40 bool isNull() const;
41 bool isValid() const;
42
43 void clear();
44
45 QByteArray data() const;
46 void setData(const QByteArray &data);
47 void setData(const QImage &image, int level = 0, int face = 0);
48
49 int dataOffset(int level = 0, int face = 0) const;
50 void setDataOffset(int offset, int level = 0, int face = 0);
51
52 int dataLength(int level = 0, int face = 0) const;
53 void setDataLength(int length, int level = 0, int face = 0);
54
55 QByteArrayView getDataView(int level = 0, int face = 0) const;
56
57 int numLevels() const;
58 void setNumLevels(int num);
59
60 int numFaces() const;
61 void setNumFaces(int num);
62
63 QSize size() const;
64 void setSize(const QSize &size);
65
66 quint32 glFormat() const;
67 void setGLFormat(quint32 format);
68
69 quint32 glInternalFormat() const;
70 void setGLInternalFormat(quint32 format);
71
72 quint32 glBaseInternalFormat() const;
73 void setGLBaseInternalFormat(quint32 format);
74
75 QByteArray logName() const;
76 void setLogName(const QByteArray &name);
77
78 QMap<QByteArray, QByteArray> keyValueMetadata() const;
79 void setKeyValueMetadata(const QMap<QByteArray, QByteArray> &keyValues);
80
81private:
82 QSharedDataPointer<QTextureFileDataPrivate> d;
83 friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QTextureFileData &d);
84};
85
86Q_DECLARE_TYPEINFO(QTextureFileData, Q_RELOCATABLE_TYPE);
87
88Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QTextureFileData &d);
89
90QT_END_NAMESPACE
91
92#endif // QABSTRACTLAYOUTSTYLEINFO_P_H
93

source code of qtbase/src/gui/util/qtexturefiledata_p.h