Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrenderloadedtexture_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6
7#ifndef QSSG_RENDER_LOADED_TEXTURE_H
8#define QSSG_RENDER_LOADED_TEXTURE_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
22#include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
23
24#include <QtGui/QImage>
25
26#include <private/qtexturefiledata_p.h>
27
28QT_BEGIN_NAMESPACE
29class QSSGRenderTextureData;
30
37
38struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGInputUtil
39{
40public:
41 enum FileType { UnknownFile, ImageFile, TextureFile, HdrFile };
42 static QSharedPointer<QIODevice> getStreamForFile(const QString &inPath,
43 bool inQuiet = false,
44 QString *outPath = nullptr);
45 static QSharedPointer<QIODevice> getStreamForTextureFile(const QString &inPath,
46 bool inQuiet = false,
47 QString *outPath = nullptr,
48 FileType *outFileType = nullptr);
49};
50
51
52// Utility class used for loading image data from disk.
53struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGLoadedTexture
54{
55public:
56 qint32 width = 0;
57 qint32 height = 0;
58 qint32 depth = 0;
59 qint32 components = 0;
60 void *data = nullptr;
61 bool ownsData = true;
62 QTextureFileData textureFileData;
63 QImage image;
64 quint32 dataSizeInBytes = 0;
65 QSSGRenderTextureFormat format = QSSGRenderTextureFormat::RGBA8;
66 // #TODO: There should be more ways to influence this (hints on the texture)
67 bool isSRGB = false;
68
69 ~QSSGLoadedTexture();
70 void setFormatFromComponents()
71 {
72 switch (components) {
73 case 1: // undefined, but in this context probably luminance
74 format = QSSGRenderTextureFormat::R8;
75 break;
76 case 2:
77 format = QSSGRenderTextureFormat::RG8;
78 break;
79 case 3:
80 format = QSSGRenderTextureFormat::RGB8;
81 break;
82
83 default:
84 // fallthrough intentional
85 case 4:
86 format = QSSGRenderTextureFormat::RGBA8;
87 break;
88 }
89 }
90
91 // Returns true if this image has a pixel less than 255.
92 bool scanForTransparency() const;
93
94 static QSSGLoadedTexture *load(const QString &inPath,
95 const QSSGRenderTextureFormat &inFormat,
96 bool inFlipY = true);
97 static QSSGLoadedTexture *loadQImage(const QString &inPath, qint32 flipVertical);
98 static QSSGLoadedTexture *loadCompressedImage(const QString &inPath);
99 static QSSGLoadedTexture *loadHdrImage(const QSharedPointer<QIODevice> &source, const QSSGRenderTextureFormat &inFormat);
100 static QSSGLoadedTexture *loadTextureData(QSSGRenderTextureData *textureData);
101 static QSSGLoadedTexture *loadLightmapImage(const QString &inPath, const QSSGRenderTextureFormat &inFormat, const QString &key);
102};
103QT_END_NAMESPACE
104
105#endif
QSSGRenderTextureFormat format