Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter_runner_product_configuration.h"
#include <zircon/assert.h>

#include "rapidjson/document.h"

Expand All @@ -17,15 +18,26 @@ FlutterRunnerProductConfiguration::FlutterRunnerProductConfiguration(
return;

// Parse out all values we're expecting.
if (auto& val = document["vsync_offset_in_us"]; val.IsInt()) {
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
if (document.HasMember("vsync_offset_in_us")) {
auto& val = document["vsync_offset_in_us"];
if (val.IsInt())
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
}
if (auto& val = document["max_frames_in_flight"]; val.IsInt()) {
max_frames_in_flight_ = val.GetInt();
if (document.HasMember("max_frames_in_flight")) {
auto& val = document["max_frames_in_flight"];
if (val.IsInt())
max_frames_in_flight_ = val.GetInt();
}
if (document.HasMember("intercept_all_input")) {
auto& val = document["intercept_all_input"];
if (val.IsBool())
intercept_all_input_ = val.GetBool();
}
#if defined(LEGACY_FUCHSIA_EMBEDDER)
if (auto& val = document["use_legacy_renderer"]; val.IsBool()) {
use_legacy_renderer_ = val.GetBool();
if (document.HasMember("use_legacy_renderer")) {
auto& val = document["use_legacy_renderer"];
if (val.IsBool())
use_legacy_renderer_ = val.GetBool();
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ class FlutterRunnerProductConfiguration {

fml::TimeDelta get_vsync_offset() { return vsync_offset_; }
uint64_t get_max_frames_in_flight() { return max_frames_in_flight_; }
bool get_intercept_all_input() { return intercept_all_input_; }
#if defined(LEGACY_FUCHSIA_EMBEDDER)
bool use_legacy_renderer() { return use_legacy_renderer_; }
#endif

private:
fml::TimeDelta vsync_offset_ = fml::TimeDelta::Zero();
uint64_t max_frames_in_flight_ = 3;
bool intercept_all_input_ = false;
#if defined(LEGACY_FUCHSIA_EMBEDDER)
bool use_legacy_renderer_ = true;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,26 @@ TEST_F(FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight) {
minimum_reasonable_max_frames_in_flight);
}

TEST_F(FlutterRunnerProductConfigurationTest, ValidInterceptAllInput) {
const std::string json_string = "{ \"intercept_all_input\" : true } ";
const uint64_t expected_intercept_all_input = true;

FlutterRunnerProductConfiguration product_config =
FlutterRunnerProductConfiguration(json_string);

EXPECT_EQ(expected_intercept_all_input,
product_config.get_intercept_all_input());
}

TEST_F(FlutterRunnerProductConfigurationTest, MissingInterceptAllInput) {
const std::string json_string = "{ \"intercept_all_input\" : } ";
const uint64_t expected_intercept_all_input = false;

FlutterRunnerProductConfiguration product_config =
FlutterRunnerProductConfiguration(json_string);

EXPECT_EQ(expected_intercept_all_input,
product_config.get_intercept_all_input());
}

} // namespace flutter_runner_test