From fc4efe0ac215c3b6658cf3d9fb6985820d2e5dd2 Mon Sep 17 00:00:00 2001 From: Hidenori Matsubayashi Date: Fri, 4 Mar 2022 09:13:44 +0900 Subject: [PATCH] flutter stable 2.10.3 (#84) Fixed https://github.com/sony/flutter-elinux/issues/81 Updated to the flutter 2.10.3. See also: - https://github.com/sony/flutter-embedded-linux/releases/tag/bd539267b4 - https://github.com/flutter/flutter/tree/2.10.3 --- bin/internal/engine.version | 2 +- bin/internal/flutter.version | 2 +- lib/elinux_artifacts.dart | 4 +- templates/app/runner/command_options.h | 62 +++++++++++++------ .../app/runner/flutter_embedder_options.h | 40 ++++++++++-- templates/app/runner/main.cc | 1 + 6 files changed, 81 insertions(+), 30 deletions(-) diff --git a/bin/internal/engine.version b/bin/internal/engine.version index 62c80a8..8bde045 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version @@ -1 +1 @@ -a83ed0e5e3b9cd2b5e2f07ef31c72f43c55e93b7 +bd539267b42051b0da3d16ffa8f48949dce8aa8f diff --git a/bin/internal/flutter.version b/bin/internal/flutter.version index c6a0fae..5a7e768 100644 --- a/bin/internal/flutter.version +++ b/bin/internal/flutter.version @@ -1 +1 @@ -097d3313d8e2c7f901932d63e537c1acefb87800 +7e9793dee1b85a243edd0e06cb1658e98b077561 diff --git a/lib/elinux_artifacts.dart b/lib/elinux_artifacts.dart index f52abdc..936141a 100644 --- a/lib/elinux_artifacts.dart +++ b/lib/elinux_artifacts.dart @@ -52,9 +52,7 @@ class ELinuxArtifacts extends CachedArtifacts { assert(hostPlatform != HostPlatform.linux_arm64, 'Artifact $artifact not available on Linux arm64.'); return _getEngineArtifactsDirectory(arch, mode!) - // TODO(hidenori): Remove this comment out. - // See: https://github.com/sony/flutter-elinux/issues/81 - //.childDirectory(getNameForHostPlatform(hostPlatform)) + .childDirectory(getNameForHostPlatform(hostPlatform)) .childFile('gen_snapshot') .path; } diff --git a/templates/app/runner/command_options.h b/templates/app/runner/command_options.h index 977cdc8..107a152 100644 --- a/templates/app/runner/command_options.h +++ b/templates/app/runner/command_options.h @@ -39,30 +39,40 @@ class CommandOptions { CommandOptions() = default; ~CommandOptions() = default; - void AddWithoutValue(const std::string& name, const std::string& short_name, - const std::string& description, bool required) { + void AddWithoutValue(const std::string& name, + const std::string& short_name, + const std::string& description, + bool required) { Add(name, short_name, description, "", ReaderString(), required, false); } - void AddInt(const std::string& name, const std::string& short_name, - const std::string& description, const int& default_value, + void AddInt(const std::string& name, + const std::string& short_name, + const std::string& description, + const int& default_value, bool required) { Add(name, short_name, description, default_value, ReaderInt(), required, true); } - void AddString(const std::string& name, const std::string& short_name, + void AddString(const std::string& name, + const std::string& short_name, const std::string& description, - const std::string& default_value, bool required) { + const std::string& default_value, + bool required) { Add(name, short_name, description, default_value, ReaderString(), required, true); } template - void Add(const std::string& name, const std::string& short_name, - const std::string& description, const T default_value, - F reader = F(), bool required = true, bool required_value = true) { + void Add(const std::string& name, + const std::string& short_name, + const std::string& description, + const T default_value, + F reader = F(), + bool required = true, + bool required_value = true) { if (options_.find(name) != options_.end()) { std::cerr << "Already registered option: " << name << std::endl; return; @@ -213,7 +223,7 @@ class CommandOptions { } size_t index_adjust = 0; - constexpr int kSpacerNum = 5; + constexpr int kSpacerNum = 10; auto need_value = registration_order_options_[i]->IsRequiredValue(); ostream << kOptionStyleNormal << registration_order_options_[i]->GetName(); @@ -242,8 +252,11 @@ class CommandOptions { class Option { public: - Option(const std::string& name, const std::string& short_name, - const std::string& description, bool required, bool required_value) + Option(const std::string& name, + const std::string& short_name, + const std::string& description, + bool required, + bool required_value) : name_(name), short_name_(short_name), description_(description), @@ -288,9 +301,12 @@ class CommandOptions { template class OptionValue : public Option { public: - OptionValue(const std::string& name, const std::string& short_name, - const std::string& description, const T& default_value, - bool required, bool required_value) + OptionValue(const std::string& name, + const std::string& short_name, + const std::string& description, + const T& default_value, + bool required, + bool required_value) : Option(name, short_name, description, required, required_value), default_value_(default_value), value_(default_value){}; @@ -316,10 +332,18 @@ class CommandOptions { template class OptionValueReader : public OptionValue { public: - OptionValueReader(const std::string& name, const std::string& short_name, - const std::string& description, const T default_value, - F reader, bool required, bool required_value) - : OptionValue(name, short_name, description, default_value, required, + OptionValueReader(const std::string& name, + const std::string& short_name, + const std::string& description, + const T default_value, + F reader, + bool required, + bool required_value) + : OptionValue(name, + short_name, + description, + default_value, + required, required_value), reader_(reader) {} ~OptionValueReader() = default; diff --git a/templates/app/runner/flutter_embedder_options.h b/templates/app/runner/flutter_embedder_options.h index 636fdda..4c22913 100644 --- a/templates/app/runner/flutter_embedder_options.h +++ b/templates/app/runner/flutter_embedder_options.h @@ -14,18 +14,21 @@ class FlutterEmbedderOptions { public: FlutterEmbedderOptions() { - options_.AddString("bundle", "b", "Path to Flutter app bundle", "./", - false); + options_.AddString("bundle", "b", "Path to Flutter project bundle", + "./bundle", true); options_.AddWithoutValue("no-cursor", "n", "No mouse cursor/pointer", false); + options_.AddInt("rotation", "r", + "Window rotation(degree) [0(default)|90|180|270]", 0, + false); #if defined(FLUTTER_TARGET_BACKEND_GBM) || \ defined(FLUTTER_TARGET_BACKEND_EGLSTREAM) // no more options. #elif defined(FLUTTER_TARGET_BACKEND_X11) options_.AddWithoutValue("fullscreen", "f", "Always full-screen display", false); - options_.AddInt("width", "w", "Flutter app window width", 1280, false); - options_.AddInt("height", "h", "Flutter app window height", 720, false); + options_.AddInt("width", "w", "Window width", 1280, false); + options_.AddInt("height", "h", "Window height", 720, false); #else // FLUTTER_TARGET_BACKEND_WAYLAND options_.AddWithoutValue("onscreen-keyboard", "k", "Enable on-screen keyboard", false); @@ -33,8 +36,8 @@ class FlutterEmbedderOptions { "Enable window decorations", false); options_.AddWithoutValue("fullscreen", "f", "Always full-screen display", false); - options_.AddInt("width", "w", "Flutter app window width", 1280, false); - options_.AddInt("height", "h", "Flutter app window height", 720, false); + options_.AddInt("width", "w", "Window width", 1280, false); + options_.AddInt("height", "h", "Window height", 720, false); #endif } ~FlutterEmbedderOptions() = default; @@ -48,6 +51,26 @@ class FlutterEmbedderOptions { bundle_path_ = options_.GetValue("bundle"); use_mouse_cursor_ = !options_.Exist("no-cursor"); + if (options_.Exist("rotation")) { + switch (options_.GetValue("rotation")) { + case 90: + window_view_rotation_ = + flutter::FlutterViewController::ViewRotation::kRotation_90; + break; + case 180: + window_view_rotation_ = + flutter::FlutterViewController::ViewRotation::kRotation_180; + break; + case 270: + window_view_rotation_ = + flutter::FlutterViewController::ViewRotation::kRotation_270; + break; + default: + window_view_rotation_ = + flutter::FlutterViewController::ViewRotation::kRotation_0; + break; + } + } #if defined(FLUTTER_TARGET_BACKEND_GBM) || \ defined(FLUTTER_TARGET_BACKEND_EGLSTREAM) @@ -86,6 +109,9 @@ class FlutterEmbedderOptions { } int WindowWidth() const { return window_width_; } int WindowHeight() const { return window_height_; } + flutter::FlutterViewController::ViewRotation WindowRotation() const { + return window_view_rotation_; + } private: commandline::CommandOptions options_; @@ -98,6 +124,8 @@ class FlutterEmbedderOptions { flutter::FlutterViewController::ViewMode::kNormal; int window_width_ = 1280; int window_height_ = 720; + flutter::FlutterViewController::ViewRotation window_view_rotation_ = + flutter::FlutterViewController::ViewRotation::kRotation_0; }; #endif // FLUTTER_EMBEDDER_OPTIONS_ diff --git a/templates/app/runner/main.cc b/templates/app/runner/main.cc index 92a6513..fa4e11b 100644 --- a/templates/app/runner/main.cc +++ b/templates/app/runner/main.cc @@ -29,6 +29,7 @@ int main(int argc, char** argv) { view_properties.width = options.WindowWidth(); view_properties.height = options.WindowHeight(); view_properties.view_mode = options.WindowViewMode(); + view_properties.view_rotation = options.WindowRotation(); view_properties.use_mouse_cursor = options.IsUseMouseCursor(); view_properties.use_onscreen_keyboard = options.IsUseOnscreenKeyboard(); view_properties.use_window_decoration = options.IsUseWindowDecoraation();