Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtexturefilereader.cpp
Go to the documentation of this file.
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
// Qt-Security score:significant reason:no-parsing
4
5
#
include
"qtexturefilereader_p.h"
6
7
#
include
"qpkmhandler_p.h"
8
#
include
"qktxhandler_p.h"
9
#
include
"qastchandler_p.h"
10
11
#
include
<
QFileInfo
>
12
13
QT_BEGIN_NAMESPACE
14
15
QTextureFileHandler::~QTextureFileHandler() =
default
;
16
17
QTextureFileReader::QTextureFileReader(QIODevice *device,
const
QString &fileName)
18
: m_device(device), m_fileName(fileName)
19
{
20
}
21
22
QTextureFileReader::~QTextureFileReader()
23
{
24
delete
m_handler;
25
}
26
27
QTextureFileData QTextureFileReader::read()
28
{
29
if
(!canRead())
30
return
QTextureFileData();
31
return
m_handler->read();
32
}
33
34
bool
QTextureFileReader::canRead()
35
{
36
if
(!checked) {
37
checked =
true
;
38
if
(!init())
39
return
false
;
40
41
QByteArray headerBlock = m_device->peek(64);
42
QFileInfo fi(m_fileName);
43
QByteArray suffix = fi.suffix().toLower().toLatin1();
44
QByteArray logName = fi.fileName().toUtf8();
45
46
// Currently the handlers are hardcoded; later maybe a list of plugins
47
if
(QPkmHandler::canRead(suffix, headerBlock)) {
48
m_handler =
new
QPkmHandler(m_device, logName);
49
}
else
if
(QKtxHandler::canRead(suffix, headerBlock)) {
50
m_handler =
new
QKtxHandler(m_device, logName);
51
}
else
if
(QAstcHandler::canRead(suffix, headerBlock)) {
52
m_handler =
new
QAstcHandler(m_device, logName);
53
}
54
// else if OtherHandler::canRead() ...etc.
55
}
56
return
(m_handler !=
nullptr
);
57
}
58
59
QList<QByteArray> QTextureFileReader::supportedFileFormats()
60
{
61
// Hardcoded for now
62
return
{QByteArrayLiteral(
"pkm"
), QByteArrayLiteral(
"ktx"
), QByteArrayLiteral(
"astc"
)};
63
}
64
65
bool
QTextureFileReader::init()
66
{
67
if
(!m_device)
68
return
false
;
69
return
m_device->isReadable();
70
}
71
72
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
gui
util
qtexturefilereader.cpp
Generated on
for Qt by
1.18.0