// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_ENGINE_H_ #define FLUTTER_SHELL_PLATFORM_FUCHSIA_ENGINE_H_ #include #include #include #include #include #include #include "flutter/fml/macros.h" #include "flutter/shell/common/shell.h" #include "isolate_configurator.h" #include "thread.h" namespace flutter_runner { // Represents an instance of running Flutter engine along with the threads // that host the same. class Engine final { public: class Delegate { public: virtual void OnEngineTerminate(const Engine* holder) = 0; }; Engine(Delegate& delegate, std::string thread_label, std::shared_ptr svc, flutter::Settings settings, fml::RefPtr isolate_snapshot, fml::RefPtr shared_snapshot, fuchsia::ui::views::ViewToken view_token, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request); ~Engine(); // Returns the Dart return code for the root isolate if one is present. This // call is thread safe and synchronous. This call must be made infrequently. std::pair GetEngineReturnCode() const; #if !defined(DART_PRODUCT) void WriteProfileToTrace() const; #endif // !defined(DART_PRODUCT) private: Delegate& delegate_; const std::string thread_label_; flutter::Settings settings_; std::array, 3> threads_; std::unique_ptr isolate_configurator_; std::unique_ptr shell_; zx::event vsync_event_; fml::WeakPtrFactory weak_factory_; void OnMainIsolateStart(); void OnMainIsolateShutdown(); void Terminate(); void OnSessionMetricsDidChange(const fuchsia::ui::gfx::Metrics& metrics); void OnSessionSizeChangeHint(float width_change_factor, float height_change_factor); FML_DISALLOW_COPY_AND_ASSIGN(Engine); }; } // namespace flutter_runner #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_ENGINE_H_