Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | List of all members
DM::JsonWriter Class Reference

#include <DMJsonWriter.h>

Classes

struct  BitmapResult
 

Static Public Member Functions

static void AddBitmapResult (const BitmapResult &)
 
static void DumpJson (const char *dir, CommandLineFlags::StringArray key, CommandLineFlags::StringArray properties)
 
static bool ReadJson (const char *path, void(*callback)(BitmapResult))
 

Detailed Description

Class for collecting results from DM and writing to a json file. All methods are thread-safe.

Definition at line 20 of file DMJsonWriter.h.

Member Function Documentation

◆ AddBitmapResult()

void DM::JsonWriter::AddBitmapResult ( const BitmapResult result)
static

Add a result to the end of the list of results.

Definition at line 31 of file DMJsonWriter.cpp.

31 {
33 gBitmapResults.push_back(result);
34}
GAsyncResult * result
TArray< JsonWriter::BitmapResult > gBitmapResults
static SkMutex & bitmap_result_mutex()

◆ DumpJson()

void DM::JsonWriter::DumpJson ( const char *  dir,
CommandLineFlags::StringArray  key,
CommandLineFlags::StringArray  properties 
)
static

Write all collected results to the file dir/dm.json.

Definition at line 36 of file DMJsonWriter.cpp.

38 {
39 if (0 == strcmp(dir, "")) {
40 return;
41 }
42
43 SkString path = SkOSPath::Join(dir, "dm.json");
45 SkFILEWStream stream(path.c_str());
47
48 writer.beginObject(); // root
49
50 for (int i = 1; i < properties.size(); i += 2) {
51 writer.appendCString(properties[i-1], properties[i]);
52 }
53
54 writer.beginObject("key");
55 for (int i = 1; i < key.size(); i += 2) {
56 writer.appendCString(key[i-1], key[i]);
57 }
58 writer.endObject();
59
60 int maxResidentSetSizeMB = sk_tools::getMaxResidentSetSizeMB();
61 if (maxResidentSetSizeMB != -1) {
62 writer.appendS32("max_rss_MB", maxResidentSetSizeMB);
63 }
64
65 {
67 writer.beginArray("results");
68 for (int i = 0; i < gBitmapResults.size(); i++) {
69 writer.beginObject();
70
71 writer.beginObject("key");
72 writer.appendString("name" , gBitmapResults[i].name);
73 writer.appendString("config" , gBitmapResults[i].config);
74 writer.appendString("source_type", gBitmapResults[i].sourceType);
75
76 // Source options only need to be part of the key if they exist.
77 // Source type by source type, we either always set options or never set options.
78 if (!gBitmapResults[i].sourceOptions.isEmpty()) {
79 writer.appendString("source_options", gBitmapResults[i].sourceOptions);
80 }
81 writer.endObject(); // key
82
83 writer.beginObject("options");
84 writer.appendString("ext" , gBitmapResults[i].ext);
85 writer.appendString("gamut", gBitmapResults[i].gamut);
86 writer.appendString("transfer_fn", gBitmapResults[i].transferFn);
87 writer.appendString("color_type", gBitmapResults[i].colorType);
88 writer.appendString("alpha_type", gBitmapResults[i].alphaType);
89 writer.appendString("color_depth", gBitmapResults[i].colorDepth);
90 writer.endObject(); // options
91
92 writer.appendString("md5", gBitmapResults[i].md5);
93
94 writer.endObject(); // 1 result
95 }
96 writer.endArray(); // results
97 }
98
99 writer.endObject(); // root
100 writer.flush();
101 stream.flush();
102}
static SkMD5::Digest md5(const SkBitmap &bm)
Definition: CodecTest.cpp:77
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
bool sk_mkdir(const char *path)
static SkString Join(const char *rootPath, const char *relativePath)
Definition: SkOSPath.cpp:14
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
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145
int getMaxResidentSetSizeMB()
Definition: ProcStats.cpp:87

◆ ReadJson()

bool DM::JsonWriter::ReadJson ( const char *  path,
void(*)(BitmapResult callback 
)
static

Read JSON file at path written by DumpJson, calling callback for each BitmapResult recorded in the file. Return success.

Definition at line 106 of file DMJsonWriter.cpp.

106 {
108 if (!json) {
109 return false;
110 }
111
112 DOM dom((const char*)json->data(), json->size());
113 const ObjectValue* root = dom.root();
114 if (!root) {
115 return false;
116 }
117
118 const ArrayValue* results = (*root)["results"];
119 if (!results) {
120 return false;
121 }
122
123 BitmapResult br;
124 for (const ObjectValue* r : *results) {
125 const ObjectValue& key = (*r)["key"].as<ObjectValue>();
126 const ObjectValue& options = (*r)["options"].as<ObjectValue>();
127
128 br.name = key["name"].as<StringValue>().begin();
129 br.config = key["config"].as<StringValue>().begin();
130 br.sourceType = key["source_type"].as<StringValue>().begin();
131 br.ext = options["ext"].as<StringValue>().begin();
132 br.gamut = options["gamut"].as<StringValue>().begin();
133 br.transferFn = options["transfer_fn"].as<StringValue>().begin();
134 br.colorType = options["color_type"].as<StringValue>().begin();
135 br.alphaType = options["alpha_type"].as<StringValue>().begin();
136 br.colorDepth = options["color_depth"].as<StringValue>().begin();
137 br.md5 = (*r)["md5"].as<StringValue>().begin();
138
139 if (const StringValue* so = key["source_options"]) {
140 br.sourceOptions = so->begin();
141 }
142 callback(br);
143 }
144 return true;
145}
const char * options
static sk_sp< SkData > MakeFromFileName(const char path[])
Definition: SkData.cpp:148
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: dom.py:1
string root
Definition: scale_cpu.py:20

The documentation for this class was generated from the following files: