Flutter Engine
 
Loading...
Searching...
No Matches
test_codec_extensions.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7namespace flutter {
8
11
12// static
14 static PointExtensionSerializer sInstance;
15 return sInstance;
16}
17
19 uint8_t type,
20 ByteStreamReader* stream) const {
21 if (type == kPointType) {
22 int32_t x = stream->ReadInt32();
23 int32_t y = stream->ReadInt32();
24 return CustomEncodableValue(Point(x, y));
25 }
27}
28
30 ByteStreamWriter* stream) const {
31 auto custom_value = std::get_if<CustomEncodableValue>(&value);
32 if (!custom_value) {
34 return;
35 }
36 stream->WriteByte(kPointType);
37 const Point& point = std::any_cast<Point>(*custom_value);
38 stream->WriteInt32(point.x());
39 stream->WriteInt32(point.y());
40}
41
44
45// static
50
52 uint8_t type,
53 ByteStreamReader* stream) const {
54 if (type == kSomeDataType) {
55 size_t size = ReadSize(stream);
56 std::vector<uint8_t> data;
57 data.resize(size);
58 stream->ReadBytes(data.data(), size);
59 EncodableValue label = ReadValue(stream);
60 return CustomEncodableValue(SomeData(std::get<std::string>(label), data));
61 }
63}
64
66 ByteStreamWriter* stream) const {
67 auto custom_value = std::get_if<CustomEncodableValue>(&value);
68 if (!custom_value) {
70 return;
71 }
72 stream->WriteByte(kSomeDataType);
73 const SomeData& some_data = std::any_cast<SomeData>(*custom_value);
74 size_t data_size = some_data.data().size();
75 WriteSize(data_size, stream);
76 stream->WriteBytes(some_data.data().data(), data_size);
77 WriteValue(EncodableValue(some_data.label()), stream);
78}
79
80} // namespace flutter
GLenum type
virtual void ReadBytes(uint8_t *buffer, size_t length)=0
virtual void WriteByte(uint8_t byte)=0
virtual void WriteBytes(const uint8_t *bytes, size_t length)=0
void WriteInt32(int32_t value)
static const PointExtensionSerializer & GetInstance()
EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const override
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
double x() const
Definition geometry.h:22
double y() const
Definition geometry.h:23
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
static const SomeDataExtensionSerializer & GetInstance()
EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const override
const std::string & label() const
const std::vector< uint8_t > & data() const
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
void WriteSize(size_t size, ByteStreamWriter *stream) const
EncodableValue ReadValue(ByteStreamReader *stream) const
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const
size_t ReadSize(ByteStreamReader *stream) const
int32_t value
int32_t x
double y
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36