159 {
160 size_t srcLen = srcStream ? srcStream->getLength() : 0;
162 if (!srcLen) {
163 return nullptr;
164 }
165
166
168 (void)srcStream->read(sourceBuffer.get(), srcLen);
169 sourceBuffer[
SkToInt(srcLen)] = 0;
170 const uint8_t*
src = sourceBuffer.get();
171
172 if (
parsePFB(
src, srcLen, headerLen, dataLen, trailerLen)) {
173 static const int kPFBSectionHeaderLength = 6;
174 const size_t length = *headerLen + *dataLen + *trailerLen;
177
179
180 const uint8_t*
const srcHeader =
src + kPFBSectionHeaderLength;
181
182
183 const uint8_t* const srcData = srcHeader + *headerLen + kPFBSectionHeaderLength;
184 const uint8_t* const srcTrailer = srcData + *headerLen;
185
186 uint8_t*
const resultHeader = (uint8_t*)
data->writable_data();
187 uint8_t* const resultData = resultHeader + *headerLen;
188 uint8_t* const resultTrailer = resultData + *dataLen;
189
191
192 memcpy(resultHeader, srcHeader, *headerLen);
193 memcpy(resultData, srcData, *dataLen);
194 memcpy(resultTrailer, srcTrailer, *trailerLen);
195
197 }
198
199
200 size_t hexDataLen;
201 if (!
parsePFA((
const char*)
src, srcLen, headerLen, &hexDataLen, dataLen,
202 trailerLen)) {
203 return nullptr;
204 }
205 const size_t length = *headerLen + *dataLen + *trailerLen;
208 uint8_t*
buffer = (uint8_t*)
data->writable_data();
209
211 uint8_t*
const resultData = &(
buffer[*headerLen]);
212
213 const uint8_t* hexData =
src + *headerLen;
214 const uint8_t* trailer = hexData + hexDataLen;
215 size_t outputOffset = 0;
216 uint8_t dataByte = 0;
217 bool highNibble = true;
218 for (; hexData < trailer; hexData++) {
219 int8_t curNibble =
hexToBin(*hexData);
220 if (curNibble < 0) {
221 continue;
222 }
223 if (highNibble) {
224 dataByte = curNibble << 4;
225 highNibble = false;
226 } else {
227 dataByte |= curNibble;
228 highNibble = true;
229 resultData[outputOffset++] = dataByte;
230 }
231 }
232 if (!highNibble) {
233 resultData[outputOffset++] = dataByte;
234 }
236
237 uint8_t*
const resultTrailer = &(
buffer[
SkToInt(*headerLen + outputOffset)]);
238 memcpy(resultTrailer,
src + *headerLen + hexDataLen, *trailerLen);
240}
static bool parsePFB(const uint8_t *src, size_t size, size_t *headerLen, size_t *dataLen, size_t *trailerLen)
static bool parsePFA(const char *src, size_t size, size_t *headerLen, size_t *hexDataLen, size_t *dataLen, size_t *trailerLen)
static int8_t hexToBin(uint8_t c)
constexpr int SkToInt(S x)
static sk_sp< SkData > MakeUninitialized(size_t length)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
std::shared_ptr< const fml::Mapping > data