Flutter Engine
flutter_runner_product_configuration.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 
7 #include <zircon/assert.h>
8 
9 #include "flutter/fml/logging.h"
10 #include "rapidjson/document.h"
11 
12 namespace flutter_runner {
13 
15  std::string json_string) {
16  rapidjson::Document document;
17  document.Parse(json_string);
18 
19  if (!document.IsObject()) {
20  FML_LOG(ERROR) << "Failed to parse configuration; using defaults: "
21  << json_string;
22  return;
23  }
24 
25  // Parse out all values we're expecting.
26  if (document.HasMember("vsync_offset_in_us")) {
27  auto& val = document["vsync_offset_in_us"];
28  if (val.IsInt())
29  vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
30  }
31  if (document.HasMember("max_frames_in_flight")) {
32  auto& val = document["max_frames_in_flight"];
33  if (val.IsInt())
34  max_frames_in_flight_ = val.GetInt();
35  }
36  if (document.HasMember("intercept_all_input")) {
37  auto& val = document["intercept_all_input"];
38  if (val.IsBool())
39  intercept_all_input_ = val.GetBool();
40  }
41  if (document.HasMember("enable_shader_warmup")) {
42  auto& val = document["enable_shader_warmup"];
43  if (val.IsBool())
44  enable_shader_warmup_ = val.GetBool();
45  }
46  if (document.HasMember("enable_shader_warmup_dart_hooks")) {
47  auto& val = document["enable_shader_warmup_dart_hooks"];
48  if (val.IsBool())
49  enable_shader_warmup_dart_hooks_ = val.GetBool();
50  }
51 }
52 
53 } // namespace flutter_runner
#define FML_LOG(severity)
Definition: logging.h:65
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43