1 | // Copyright (C) 2017 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 | #include "qsgtexturereader_p.h" |
5 | #include <private/qtexturefilereader_p.h> |
6 | |
7 | #include <private/qsgcompressedtexture_p.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | QSGTextureReader::QSGTextureReader(QIODevice *device, const QString &fileName) |
12 | { |
13 | m_reader = new QTextureFileReader(device, fileName); |
14 | } |
15 | |
16 | QSGTextureReader::~QSGTextureReader() |
17 | { |
18 | delete m_reader; |
19 | } |
20 | |
21 | QQuickTextureFactory *QSGTextureReader::read() |
22 | { |
23 | if (!m_reader) |
24 | return nullptr; |
25 | |
26 | QTextureFileData texData = m_reader->read(); |
27 | if (!texData.isValid()) |
28 | return nullptr; |
29 | |
30 | return new QSGCompressedTextureFactory(texData); |
31 | } |
32 | |
33 | bool QSGTextureReader::isTexture() |
34 | { |
35 | return m_reader ? m_reader->canRead() : false; |
36 | } |
37 | |
38 | QList<QByteArray> QSGTextureReader::supportedFileFormats() |
39 | { |
40 | return QTextureFileReader::supportedFileFormats(); |
41 | } |
42 | |
43 | QT_END_NAMESPACE |
44 |