Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgtexturereader.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2017 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #include "qsgtexturereader_p.h" | - | ||||||
41 | - | |||||||
42 | #include <private/qtquickglobal_p.h> | - | ||||||
43 | - | |||||||
44 | #include <private/qsgtexturefilehandler_p.h> | - | ||||||
45 | - | |||||||
46 | #if QT_CONFIG(opengl) | - | ||||||
47 | #include <private/qsgpkmhandler_p.h> | - | ||||||
48 | #include <private/qsgktxhandler_p.h> | - | ||||||
49 | #endif | - | ||||||
50 | - | |||||||
51 | #include <QFileInfo> | - | ||||||
52 | - | |||||||
53 | QT_BEGIN_NAMESPACE | - | ||||||
54 | - | |||||||
55 | QSGTextureReader::QSGTextureReader(QIODevice *device, const QString &fileName) | - | ||||||
56 | : m_device(device), m_fileInfo(fileName) | - | ||||||
57 | { | - | ||||||
58 | } executed 718 times by 34 tests: end of block Executed by:
| 718 | ||||||
59 | - | |||||||
60 | QSGTextureReader::~QSGTextureReader() | - | ||||||
61 | { | - | ||||||
62 | delete m_handler; | - | ||||||
63 | } executed 718 times by 34 tests: end of block Executed by:
| 718 | ||||||
64 | - | |||||||
65 | QQuickTextureFactory *QSGTextureReader::read() | - | ||||||
66 | { | - | ||||||
67 | #if QT_CONFIG(opengl) | - | ||||||
68 | if (!isTexture())
| 0-10 | ||||||
69 | return nullptr; never executed: return nullptr; | 0 | ||||||
70 | return m_handler->read(); executed 10 times by 1 test: return m_handler->read(); Executed by:
| 10 | ||||||
71 | #else | - | ||||||
72 | return nullptr; | - | ||||||
73 | #endif | - | ||||||
74 | } | - | ||||||
75 | - | |||||||
76 | bool QSGTextureReader::isTexture() | - | ||||||
77 | { | - | ||||||
78 | #if QT_CONFIG(opengl) | - | ||||||
79 | if (!checked) {
| 10-718 | ||||||
80 | checked = true; | - | ||||||
81 | if (!init())
| 0-718 | ||||||
82 | return false; never executed: return false; | 0 | ||||||
83 | - | |||||||
84 | QByteArray headerBlock = m_device->peek(64); | - | ||||||
85 | QByteArray suffix = m_fileInfo.suffix().toLower().toLatin1(); | - | ||||||
86 | QByteArray logName = m_fileInfo.fileName().toUtf8(); | - | ||||||
87 | - | |||||||
88 | // Currently the handlers are hardcoded; later maybe a list of plugins | - | ||||||
89 | if (QSGPkmHandler::canRead(suffix, headerBlock)) {
| 8-710 | ||||||
90 | m_handler = new QSGPkmHandler(m_device, logName); | - | ||||||
91 | } else if (QSGKtxHandler::canRead(suffix, headerBlock)) { executed 8 times by 1 test: end of block Executed by:
| 2-708 | ||||||
92 | m_handler = new QSGKtxHandler(m_device, logName); | - | ||||||
93 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
94 | // else if OtherHandler::canRead() ...etc. | - | ||||||
95 | } executed 718 times by 34 tests: end of block Executed by:
| 718 | ||||||
96 | return (m_handler != nullptr); executed 728 times by 34 tests: return (m_handler != nullptr); Executed by:
| 728 | ||||||
97 | #else | - | ||||||
98 | return false; | - | ||||||
99 | #endif | - | ||||||
100 | } | - | ||||||
101 | - | |||||||
102 | QList<QByteArray> QSGTextureReader::supportedFileFormats() | - | ||||||
103 | { | - | ||||||
104 | // Hardcoded for now | - | ||||||
105 | return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx")}; executed 68 times by 34 tests: return {([]() -> QByteArray { enum { Size = sizeof("pkm") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "pkm" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; cons...= sizeof("ktx") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ktx" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())}; Executed by:
executed 68 times by 34 tests: return ba; Executed by:
executed 68 times by 34 tests: return ba; Executed by:
| 68 | ||||||
106 | } | - | ||||||
107 | - | |||||||
108 | bool QSGTextureReader::init() | - | ||||||
109 | { | - | ||||||
110 | if (!m_device)
| 0-718 | ||||||
111 | return false; never executed: return false; | 0 | ||||||
112 | return m_device->isReadable(); executed 718 times by 34 tests: return m_device->isReadable(); Executed by:
| 718 | ||||||
113 | } | - | ||||||
114 | - | |||||||
115 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |