// 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 #include #include #include #include "flutter/flow/embedded_views.h" #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/shell/common/shell.h" #include "flutter_runner_product_configuration.h" #include "fuchsia_external_view_embedder.h" #include "isolate_configurator.h" #include "session_connection.h" #include "thread.h" #include "vulkan_surface_producer.h" #if defined(LEGACY_FUCHSIA_EMBEDDER) #include "flutter/flow/scene_update_context.h" // nogncheck #endif namespace flutter_runner { namespace testing { class EngineTest; } // 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, std::shared_ptr runner_services, flutter::Settings settings, fuchsia::ui::views::ViewToken view_token, scenic::ViewRefPair view_ref_pair, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config); ~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::optional GetEngineReturnCode() const; #if !defined(DART_PRODUCT) void WriteProfileToTrace() const; #endif // !defined(DART_PRODUCT) private: Delegate& delegate_; const std::string thread_label_; std::array threads_; std::optional session_connection_; std::optional surface_producer_; std::shared_ptr external_view_embedder_; #if defined(LEGACY_FUCHSIA_EMBEDDER) std::shared_ptr legacy_external_view_embedder_; #endif std::unique_ptr isolate_configurator_; std::unique_ptr shell_; fuchsia::intl::PropertyProviderPtr intl_property_provider_; zx::event vsync_event_; #if defined(LEGACY_FUCHSIA_EMBEDDER) bool use_legacy_renderer_ = true; #endif bool intercept_all_input_ = false; fml::WeakPtrFactory weak_factory_; static void WarmupSkps(fml::BasicTaskRunner* concurrent_task_runner, fml::BasicTaskRunner* raster_task_runner, VulkanSurfaceProducer& surface_producer); void OnMainIsolateStart(); void OnMainIsolateShutdown(); void Terminate(); void DebugWireframeSettingsChanged(bool enabled); void CreateView(int64_t view_id, ViewIdCallback on_view_bound, bool hit_testable, bool focusable); void UpdateView(int64_t view_id, bool hit_testable, bool focusable); void DestroyView(int64_t view_id, ViewIdCallback on_view_unbound); std::shared_ptr GetExternalViewEmbedder(); std::unique_ptr CreateSurface(); friend class testing::EngineTest; fidl::InterfacePtr keyboard_svc_; FML_DISALLOW_COPY_AND_ASSIGN(Engine); }; } // namespace flutter_runner #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_ENGINE_H_