16#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
38 if (!fStream->
seek(fPosition)) {
45 const size_t fPosition;
56 void initSource(
const uint8_t*& nextInputByte,
size_t& bytesInBuffer)
override {
60 bool fillInputBuffer(
const uint8_t*& nextInputByte,
size_t& bytesInBuffer)
override {
67 const uint8_t*& nextInputByte,
68 size_t& bytesInBuffer)
override {
69 if (bytesToSkip > bytesInBuffer) {
70 SkCodecPrintf(
"Asked to read past end of a memory-mapped stream.\n");
73 nextInputByte += bytesToSkip;
74 bytesInBuffer -= bytesToSkip;
77#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
78 const std::vector<SkJpegSegment>& getAllSegments()
override {
80 return fScanner->getSegments();
84 return fScanner->getSegments();
130 void initSource(
const uint8_t*& nextInputByte,
size_t& bytesInBuffer)
override {
131 nextInputByte = fBuffer->
bytes();
136 if (bytesRead == 0) {
138 SkCodecPrintf(
"Hit end of file reading a buffered stream.\n");
141 nextInputByte = fBuffer->
bytes();
142 bytesInBuffer = bytesRead;
146 const uint8_t*& nextInputByte,
147 size_t& bytesInBuffer)
override {
149 if (bytesToSkip <= bytesInBuffer) {
150 nextInputByte += bytesToSkip;
151 bytesInBuffer -= bytesToSkip;
154 bytesToSkip -= bytesInBuffer;
163 nextInputByte = fBuffer->
bytes();
166#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
167 const std::vector<SkJpegSegment>& getAllSegments()
override {
169 return fScanner->getSegments();
173 while (!fScanner->isDone() && !fScanner->hadError()) {
177 if (bytesRead == 0) {
181 fScanner->onBytes(
buffer, bytesRead);
183 return fScanner->getSegments();
188 SkCodecPrintf(
"Failed to seek to subset stream position.\n");
251#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
264 ~SkJpegUnseekableSourceMgr()
override {}
266 void initSource(
const uint8_t*& nextInputByte,
size_t& bytesInBuffer)
override {
267 nextInputByte = fBuffer->bytes();
270 bool fillInputBuffer(
const uint8_t*& nextInputByte,
size_t& bytesInBuffer)
override {
271 if (!readToBufferAndScan(fBuffer->size())) {
275 nextInputByte = fBuffer->bytes();
276 bytesInBuffer = fLastReadSize;
280 const uint8_t*& nextInputByte,
281 size_t& bytesInBuffer)
override {
283 if (bytesToSkip <= bytesInBuffer) {
284 nextInputByte += bytesToSkip;
285 bytesInBuffer -= bytesToSkip;
288 bytesToSkip -= bytesInBuffer;
291 while (bytesToSkip > 0) {
292 if (!readToBufferAndScan(
std::min(bytesToSkip, fBuffer->size()))) {
296 bytesToSkip -= fLastReadSize;
301 nextInputByte = fBuffer->bytes();
304 const std::vector<SkJpegSegment>& getAllSegments()
override {
305 while (!fScanner->isDone() && !fScanner->hadError()) {
306 if (!readToBufferAndScan(fBuffer->size())) {
307 SkCodecPrintf(
"Failure finishing unseekable input buffer.\n");
311 return fScanner->getSegments();
316 if (!fScanner->isDone()) {
317 SkCodecPrintf(
"getSubsetData is prematurely terminating scan.\n");
321 if (
offset < fLastReadOffset) {
328 uint8_t* subsetDataCurrent =
reinterpret_cast<uint8_t*
>(subsetData->
writable_data());
331 size_t offsetIntoBuffer =
offset - fLastReadOffset;
332 if (offsetIntoBuffer >= fLastReadSize) {
334 fLastReadOffset += fLastReadSize;
338 size_t bytesToSkip =
offset - fLastReadOffset;
339 while (bytesToSkip > 0) {
340 size_t bytesSkipped = fStream->skip(bytesToSkip);
341 if (bytesSkipped == 0) {
345 bytesToSkip -= bytesSkipped;
346 fLastReadOffset += bytesSkipped;
350 SkASSERT(offsetIntoBuffer < fLastReadSize);
354 size_t bytesToReadFromBuffer =
std::min(fLastReadSize - offsetIntoBuffer,
size);
355 memcpy(subsetDataCurrent, fBuffer->bytes() + offsetIntoBuffer, bytesToReadFromBuffer);
356 size -= bytesToReadFromBuffer;
357 subsetDataCurrent += bytesToReadFromBuffer;
367 fLastReadOffset += fLastReadSize;
373 size_t bytesRead = fStream->read(subsetDataCurrent,
size);
374 if (bytesRead == 0) {
379 subsetDataCurrent += bytesRead;
380 fLastReadOffset += bytesRead;
397 bool readToBufferAndScan(
size_t bytesToRead) {
399 fLastReadOffset += fLastReadSize;
400 fLastReadSize = fStream->read(fBuffer->writable_data(), bytesToRead);
401 if (fLastReadSize == 0) {
402 SkCodecPrintf(
"Hit end of file reading an unseekable stream.\n");
405 fScanner->onBytes(fBuffer->bytes(), fLastReadSize);
413 size_t fLastReadSize = 0;
417 size_t fLastReadOffset = 0;
426#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
427 if (!
stream->hasPosition()) {
428 return std::make_unique<SkJpegUnseekableSourceMgr>(
stream, bufferSize);
432 return std::make_unique<SkJpegMemorySourceMgr>(
stream);
434 return std::make_unique<SkJpegBufferedSourceMgr>(
stream, bufferSize);
#define SkCodecPrintf(...)
static constexpr size_t kJpegSegmentParameterLengthSize
static constexpr uint8_t kJpegMarkerEndOfImage
static constexpr size_t kJpegMarkerCodeSize
static const size_t kBufferSize
~ScopedSkStreamRestorer()
ScopedSkStreamRestorer(SkStream *stream)
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
const uint8_t * bytes() const
static sk_sp< SkData > MakeUninitialized(size_t length)
~SkJpegBufferedSourceMgr() override
void initSource(const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
bool fillInputBuffer(const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
SkJpegBufferedSourceMgr(SkStream *stream, size_t bufferSize)
bool skipInputBytes(size_t bytesToSkip, const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
void initSource(const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
SkJpegMemorySourceMgr(SkStream *stream)
bool skipInputBytes(size_t bytesToSkip, const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
~SkJpegMemorySourceMgr() override
bool fillInputBuffer(const uint8_t *&nextInputByte, size_t &bytesInBuffer) override
virtual ~SkJpegSourceMgr()
virtual bool skipInputBytes(size_t bytes, const uint8_t *&nextInputByte, size_t &bytesInBuffer)=0
virtual bool fillInputBuffer(const uint8_t *&nextInputByte, size_t &bytesInBuffer)=0
virtual void initSource(const uint8_t *&nextInputByte, size_t &bytesInBuffer)=0
SkJpegSourceMgr(SkStream *stream)
static std::unique_ptr< SkJpegSourceMgr > Make(SkStream *stream, size_t bufferSize=1024)
virtual bool seek(size_t)
virtual size_t getLength() const
virtual const void * getMemoryBase()
virtual size_t read(void *buffer, size_t size)=0
static float min(float r, float g, float b)
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data