48 {
50 if (!input.isValid()) {
51 return nullptr;
52 }
53
54 constexpr int kKTXIdentifierSize = 12;
55 constexpr int kKTXHeaderSize = kKTXIdentifierSize + 13 * sizeof(uint32_t);
56 uint8_t
header[kKTXHeaderSize];
57
58 if (input.read(
header, kKTXHeaderSize) != kKTXHeaderSize) {
59 return nullptr;
60 }
61
62 static const uint8_t kExpectedIdentifier[kKTXIdentifierSize] = {
63 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
64 };
65
66 if (0 != memcmp(
header, kExpectedIdentifier, kKTXIdentifierSize)) {
67 return nullptr;
68 }
69
71 if (endianness != 0x04030201) {
72
73
74 return nullptr;
75 }
76
81
85
89
90 if (glType != 0 || glFormat != 0) {
91 return nullptr;
92 }
94
95
96 switch (glInternalFormat) {
100 break;
103 break;
106 break;
107 default:
108 return nullptr;
109 }
110
113
114 if (pixelDepth != 0) {
115 return nullptr;
116 }
117
118 if (numberOfFaces != 1) {
119 return nullptr;
120 }
121
122 if (numberOfMipmapLevels == 1) {
124 } else {
126 if (numberOfMipmapLevels != numRequiredMipLevels) {
127 return nullptr;
128 }
130 }
131
132 if (bytesOfKeyValueData != 0) {
133 return nullptr;
134 }
135
137
139 {(int)pixelWidth, (int)pixelHeight},
140 &individualMipOffsets,
142 SkASSERT(individualMipOffsets.size() == numberOfMipmapLevels);
143
145
146 uint8_t*
dest = (uint8_t*)
data->writable_data();
147
149 for (
int i = 0;
i < numberOfMipmapLevels; ++
i) {
150 uint32_t imageSize;
151
152 if (input.read(&imageSize, 4) != 4) {
153 return nullptr;
154 }
155
158
159 if (input.read(&
dest[
offset], imageSize) != imageSize) {
160 return nullptr;
161 }
162
164 }
165
167}
#define GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
#define GR_GL_COMPRESSED_ETC1_RGB8
#define GR_GL_COMPRESSED_RGB8_ETC2
#define GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()