Flutter Engine
The Flutter Engine
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
5#include "flutter/shell/platform/common/client_wrapper/testing/test_codec_extensions.h"
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
47 static SomeDataExtensionSerializer sInstance;
48 return sInstance;
49}
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);
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);
78}
79
80} // namespace flutter
GLenum type
static const PointExtensionSerializer & GetInstance()
EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const override
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
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
uint8_t value
double y
double x
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: switches.h:41
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
TPoint< Scalar > Point
Definition: point.h:322