OpenCoverage

qsgktxhandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/compressedtexture/qsgktxhandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static const char ktxIdentifier[12] = { '\xAB', 'K', 'T', 'X', ' ', '1', '1', '\xBB', '\r', '\n', '\x1A', '\n' };-
8static const quint32 platformEndianIdentifier = 0x04030201;-
9static const quint32 inversePlatformEndianIdentifier = 0x01020304;-
10-
11struct KTXHeader {-
12 quint8 identifier[12];-
13 quint32 endianness;-
14 quint32 glType;-
15 quint32 glTypeSize;-
16 quint32 glFormat;-
17 quint32 glInternalFormat;-
18 quint32 glBaseInternalFormat;-
19 quint32 pixelWidth;-
20 quint32 pixelHeight;-
21 quint32 pixelDepth;-
22 quint32 numberOfArrayElements;-
23 quint32 numberOfFaces;-
24 quint32 numberOfMipmapLevels;-
25 quint32 bytesOfKeyValueData;-
26};-
27-
28static const int headerSize = sizeof(KTXHeader);-
29-
30-
31struct KTXKeyValuePairItem {-
32 quint32 keyAndValueByteSize;-
33-
34-
35-
36-
37};-
38-
39struct KTXMipmapLevel {-
40 quint32 imageSize;-
41};-
42-
43bool QSGKtxHandler::canRead(const QByteArray &suffix, const QByteArray &block)-
44{-
45 (void)suffix;-
46-
47 return
executed 712 times by 34 tests: return (qstrncmp(block.constData(), ktxIdentifier, 12) == 0);
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpixmapcache
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • ...
(qstrncmp(block.constData(), ktxIdentifier, 12) == 0);
executed 712 times by 34 tests: return (qstrncmp(block.constData(), ktxIdentifier, 12) == 0);
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpixmapcache
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • ...
712
48}-
49-
50QQuickTextureFactory *QSGKtxHandler::read()-
51{-
52 if (!device()
!device()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
)
0-2
53 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
54-
55 QByteArray buf = device()->readAll();-
56 if (buf.size() < headerSize
buf.size() < headerSizeDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
|| !canRead(QByteArray(), buf)
!canRead(QByteArray(), buf)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
) {
0-2
57 for (bool qt_category_enabled = QSG_LOG_TEXTUREIO().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 115, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Invalid KTX file %s", logName().constData());
never executed: QMessageLogger(__FILE__, 115, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Invalid KTX file %s", logName().constData());
0
58 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
59 }-
60-
61 const KTXHeader *header = reinterpret_cast<const KTXHeader *>(buf.constData());-
62 if (!checkHeader(*header)
!checkHeader(*header)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
) {
0-2
63 for (bool qt_category_enabled = QSG_LOG_TEXTUREIO().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Unsupported KTX file format in %s", logName().constData());
never executed: QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Unsupported KTX file format in %s", logName().constData());
0
64 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
65 }-
66-
67 QSGCompressedTexture::DataPtr texData(QSGCompressedTexture::DataPtr::create());-
68-
69 texData->size = QSize(decode(header->pixelWidth), decode(header->pixelHeight));-
70 texData->format = decode(header->glInternalFormat);-
71 texData->hasAlpha = !QSGCompressedTexture::formatIsOpaque(texData->format);-
72-
73-
74 int preambleSize = headerSize + decode(header->bytesOfKeyValueData);-
75 if (buf.size() >= preambleSize + int(sizeof(KTXMipmapLevel))
buf.size() >= ...XMipmapLevel))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
) {
0-2
76 texData->data = buf;-
77 texData->dataOffset = preambleSize + sizeof(quint32);-
78 const KTXMipmapLevel *level = reinterpret_cast<const KTXMipmapLevel *>(buf.constData() + preambleSize);-
79 texData->dataLength = decode(level->imageSize);-
80 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickimage
2
81-
82 if (!texData->isValid()
!texData->isValid()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
) {
0-2
83 for (bool qt_category_enabled = QSG_LOG_TEXTUREIO().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 141, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Invalid values in header of KTX file %s", logName().constData());
never executed: QMessageLogger(__FILE__, 141, __PRETTY_FUNCTION__, QSG_LOG_TEXTUREIO().categoryName()).debug("Invalid values in header of KTX file %s", logName().constData());
0
84 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
85 }-
86-
87 texData->logName = logName();-
88-
89-
90-
91-
92 return
executed 2 times by 1 test: return new QSGCompressedTextureFactory(texData);
Executed by:
  • tst_qquickimage
new QSGCompressedTextureFactory(texData);
executed 2 times by 1 test: return new QSGCompressedTextureFactory(texData);
Executed by:
  • tst_qquickimage
2
93}-
94-
95bool QSGKtxHandler::checkHeader(const KTXHeader &header)-
96{-
97 if (header.endianness != platformEndianIdentifier
header.endiann...dianIdentifierDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickimage
&& header.endianness != inversePlatformEndianIdentifier
header.endiann...dianIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-2
98 return
never executed: return false;
false;
never executed: return false;
0
99 inverseEndian = (header.endianness == inversePlatformEndianIdentifier);-
100 return
executed 2 times by 1 test: return ((decode(header.glType) == 0) && (decode(header.glFormat) == 0) && (decode(header.pixelDepth) == 0) && (decode(header.numberOfFaces) == 1));
Executed by:
  • tst_qquickimage
((decode(header.glType) == 0) &&
executed 2 times by 1 test: return ((decode(header.glType) == 0) && (decode(header.glFormat) == 0) && (decode(header.pixelDepth) == 0) && (decode(header.numberOfFaces) == 1));
Executed by:
  • tst_qquickimage
2
101 (decode(header.glFormat) == 0) &&
executed 2 times by 1 test: return ((decode(header.glType) == 0) && (decode(header.glFormat) == 0) && (decode(header.pixelDepth) == 0) && (decode(header.numberOfFaces) == 1));
Executed by:
  • tst_qquickimage
2
102 (decode(header.pixelDepth) == 0) &&
executed 2 times by 1 test: return ((decode(header.glType) == 0) && (decode(header.glFormat) == 0) && (decode(header.pixelDepth) == 0) && (decode(header.numberOfFaces) == 1));
Executed by:
  • tst_qquickimage
2
103 (decode(header.numberOfFaces) == 1));
executed 2 times by 1 test: return ((decode(header.glType) == 0) && (decode(header.glFormat) == 0) && (decode(header.pixelDepth) == 0) && (decode(header.numberOfFaces) == 1));
Executed by:
  • tst_qquickimage
2
104}-
105-
106quint32 QSGKtxHandler::decode(quint32 val)-
107{-
108 return
executed 18 times by 1 test: return inverseEndian ? qbswap<quint32>(val) : val;
Executed by:
  • tst_qquickimage
inverseEndian ? qbswap<quint32>(val) : val;
executed 18 times by 1 test: return inverseEndian ? qbswap<quint32>(val) : val;
Executed by:
  • tst_qquickimage
18
109}-
110-
111-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0