Flutter Engine
The Flutter Engine
SkJpegSourceMgr.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkJpegSourceMgr_codec_DEFINED
9#define SkJpegSourceMgr_codec_DEFINED
10
12
13#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
15#endif // SK_CODEC_DECODES_JPEG_GAINMAPS
16
17#include <cstddef>
18#include <cstdint>
19#include <memory>
20
21#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
22#include <vector>
23#endif // SK_CODEC_DECODES_JPEG_GAINMAPS
24
25class SkStream;
26
27#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
28class SkData;
30struct SkJpegSegment;
31#endif // SK_CODEC_DECODES_JPEG_GAINMAPS
32
33/*
34 * Interface to adapt an SkStream to the jpeg_source_mgr interface. This interface has different
35 * implementations for SkStreams with different capabilities.
36 */
38public:
39 // Create a source manager. If the source manager will buffer data, |bufferSize| specifies
40 // the size of that buffer.
41 static std::unique_ptr<SkJpegSourceMgr> Make(SkStream* stream, size_t bufferSize = 1024);
43
44 // Interface called by libjpeg via its jpeg_source_mgr interface.
45 virtual void initSource(const uint8_t*& nextInputByte, size_t& bytesInBuffer) = 0;
46 virtual bool fillInputBuffer(const uint8_t*& nextInputByte, size_t& bytesInBuffer) = 0;
47 virtual bool skipInputBytes(size_t bytes,
48 const uint8_t*& nextInputByte,
49 size_t& bytesInBuffer) = 0;
50
51#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
52 // Parse this stream all the way through its EndOfImage marker and return the list of segments.
53 // Return false if there is an error or if no EndOfImage marker is found.
54 virtual const std::vector<SkJpegSegment>& getAllSegments() = 0;
55
56 // Return an the data for a subset of this source's stream, with the specified offset and size.
57 // If the returned SkData is a copy (it does not refer directly to memory owned by |fStream|),
58 // then |wasCopied| is set to true.
59 virtual sk_sp<SkData> getSubsetData(size_t offset, size_t size, bool* wasCopied = nullptr) = 0;
60
61 // Segments start with a 2 byte marker, followed by a 2 byte parameter length (which includes
62 // those two bytes, followed by parameters. Return the parameters portion of the specified
63 // segment. If possible, the returned SkData will refer to memory owned by |fStream|.
64 virtual sk_sp<SkData> getSegmentParameters(const SkJpegSegment& segment) = 0;
65#endif // SK_CODEC_DECODES_JPEG_GAINMAPS
66
67protected:
69 SkStream* const fStream; // unowned
70
71#ifdef SK_CODEC_DECODES_JPEG_GAINMAPS
72 // The segment scanner is lazily creatd only when needed.
73 std::unique_ptr<SkJpegSegmentScanner> fScanner;
74#endif // SK_CODEC_DECODES_JPEG_GAINMAPS
75};
76
77#endif
Definition: SkData.h:25
virtual ~SkJpegSourceMgr()
virtual bool skipInputBytes(size_t bytes, const uint8_t *&nextInputByte, size_t &bytesInBuffer)=0
SkStream *const fStream
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)
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
Definition: switches.h:259
SeparatedVector2 offset