Flutter Engine
The Flutter Engine
FakeStreams.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 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
10
11#ifndef FakeStreams_DEFINED
12#define FakeStreams_DEFINED
13
14// Stream that is not an asset stream (!hasPosition() or !hasLength())
16public:
18
19 bool hasPosition() const override {
20 return false;
21 }
22
23 bool hasLength() const override {
24 return false;
25 }
26
27 size_t peek(void* buf, size_t bytes) const override {
28 return fStream.peek(buf, bytes);
29 }
30 size_t read(void* buf, size_t bytes) override {
31 return fStream.read(buf, bytes);
32 }
33 bool rewind() override {
34 return fStream.rewind();
35 }
36 bool isAtEnd() const override {
37 return fStream.isAtEnd();
38 }
39private:
40 SkMemoryStream fStream;
41};
42
44public:
46
47 bool rewind() override {
48 return false;
49 }
50
51 bool seek(size_t /* position */) override {
52 return false;
53 }
54private:
55 using INHERITED = NotAssetMemStream;
56};
57
58/*
59 * Represents a stream without all of its data.
60 */
61class HaltingStream : public SkStream {
62public:
63 HaltingStream(sk_sp<SkData> data, size_t initialLimit)
64 : fTotalSize(data->size())
65 , fLimit(initialLimit)
66 , fStream(std::move(data))
67 {}
68
69 void addNewData(size_t extra) {
70 fLimit = std::min(fTotalSize, fLimit + extra);
71 }
72
73 size_t read(void* buffer, size_t size) override {
74 if (fStream.getPosition() + size > fLimit) {
75 size = fLimit - fStream.getPosition();
76 }
77
78 return fStream.read(buffer, size);
79 }
80
81 bool isAtEnd() const override {
82 return fStream.isAtEnd();
83 }
84
85 bool hasLength() const override { return true; }
86 size_t getLength() const override { return fLimit; }
87
88 bool hasPosition() const override { return true; }
89 size_t getPosition() const override { return fStream.getPosition(); }
90 bool rewind() override { return fStream.rewind(); }
91 bool move(long offset) override { return fStream.move(offset); }
92 bool seek(size_t position) override { return fStream.seek(position); }
93
94 bool isAllDataReceived() const { return fLimit == fTotalSize; }
95
96private:
97 const size_t fTotalSize;
98 size_t fLimit;
99 SkMemoryStream fStream;
100};
101#endif // FakeStreams_DEFINED
bool isAtEnd() const override
Definition: FakeStreams.h:81
bool seek(size_t position) override
Definition: FakeStreams.h:92
bool hasLength() const override
Definition: FakeStreams.h:85
void addNewData(size_t extra)
Definition: FakeStreams.h:69
size_t getPosition() const override
Definition: FakeStreams.h:89
bool hasPosition() const override
Definition: FakeStreams.h:88
size_t read(void *buffer, size_t size) override
Definition: FakeStreams.h:73
bool isAllDataReceived() const
Definition: FakeStreams.h:94
HaltingStream(sk_sp< SkData > data, size_t initialLimit)
Definition: FakeStreams.h:63
bool move(long offset) override
Definition: FakeStreams.h:91
bool rewind() override
Definition: FakeStreams.h:90
size_t getLength() const override
Definition: FakeStreams.h:86
NonseekableStream(sk_sp< SkData > data)
Definition: FakeStreams.h:45
bool rewind() override
Definition: FakeStreams.h:47
bool seek(size_t) override
Definition: FakeStreams.h:51
size_t peek(void *buf, size_t bytes) const override
Definition: FakeStreams.h:27
bool isAtEnd() const override
Definition: FakeStreams.h:36
bool rewind() override
Definition: FakeStreams.h:33
bool hasLength() const override
Definition: FakeStreams.h:23
NotAssetMemStream(sk_sp< SkData > data)
Definition: FakeStreams.h:17
bool hasPosition() const override
Definition: FakeStreams.h:19
size_t read(void *buf, size_t bytes) override
Definition: FakeStreams.h:30
bool isAtEnd() const override
Definition: SkStream.cpp:361
bool move(long offset) override
Definition: SkStream.cpp:385
bool seek(size_t position) override
Definition: SkStream.cpp:378
size_t read(void *buffer, size_t size) override
Definition: SkStream.cpp:337
size_t peek(void *buffer, size_t size) const override
Definition: SkStream.cpp:351
bool rewind() override
Definition: SkStream.cpp:365
size_t getPosition() const override
Definition: SkStream.cpp:374
virtual bool move(long)
Definition: SkStream.h:131
static float min(float r, float g, float b)
Definition: hsl.cpp:48
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
Definition: switches.h:126
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
Definition: ref_ptr.h:256
SeparatedVector2 offset
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63