5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_ENGINE_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_ENGINE_H_
10#include <fuchsia/intl/cpp/fidl.h>
11#include <fuchsia/io/cpp/fidl.h>
12#include <fuchsia/memorypressure/cpp/fidl.h>
13#include <fuchsia/ui/composition/cpp/fidl.h>
14#include <fuchsia/ui/views/cpp/fidl.h>
15#include <lib/async-loop/cpp/loop.h>
16#include <lib/sys/cpp/service_directory.h>
18#include "flutter/flow/embedded_views.h"
19#include "flutter/flow/surface.h"
20#include "flutter/fml/macros.h"
21#include "flutter/shell/common/shell.h"
22#include "flutter/shell/common/thread_host.h"
23#include "flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h"
39class Engine final :
public fuchsia::memorypressure::Watcher {
47 const std::string& name_prefix,
48 const std::shared_ptr<sys::ServiceDirectory>& runner_services =
nullptr);
51 std::string thread_label,
52 std::shared_ptr<sys::ServiceDirectory> svc,
53 std::shared_ptr<sys::ServiceDirectory> runner_services,
55 fuchsia::ui::views::ViewCreationToken view_creation_token,
56 std::pair<fuchsia::ui::views::ViewRefControl,
57 fuchsia::ui::views::ViewRef> view_ref_pair,
59 fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
61 const std::vector<std::string>& dart_entrypoint_args);
69#if !defined(DART_PRODUCT)
75 std::pair<fuchsia::ui::views::ViewRefControl, fuchsia::ui::views::ViewRef>
77 std::shared_ptr<sys::ServiceDirectory> svc,
78 std::shared_ptr<sys::ServiceDirectory> runner_services,
81 fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
83 const std::vector<std::string>& dart_entrypoint_args);
85 static void WarmupSkps(
88 std::shared_ptr<SurfaceProducer> surface_producer,
90 std::shared_ptr<flutter::AssetManager> asset_manager,
91 std::optional<
const std::vector<std::string>> skp_names,
92 std::optional<
std::function<
void(uint32_t)>> completion_callback,
93 bool synchronous =
false);
95 void OnMainIsolateStart();
97 void OnMainIsolateShutdown();
101 void DebugWireframeSettingsChanged(
bool enabled);
102 void CreateView(int64_t view_id,
107 void UpdateView(int64_t view_id,
111 void DestroyView(int64_t view_id,
ViewIdCallback on_view_unbound);
114 void OnLevelChanged(fuchsia::memorypressure::Level
level,
115 fuchsia::memorypressure::Watcher::OnLevelChangedCallback
118 std::shared_ptr<flutter::ExternalViewEmbedder> GetExternalViewEmbedder();
120 std::unique_ptr<flutter::Surface> CreateSurface();
124 const std::string thread_label_;
127 fuchsia::ui::views::ViewCreationToken view_creation_token_;
128 std::shared_ptr<FlatlandConnection>
129 flatland_connection_;
130 std::shared_ptr<SurfaceProducer> surface_producer_;
131 std::shared_ptr<ExternalViewEmbedder> view_embedder_;
133 std::unique_ptr<IsolateConfigurator> isolate_configurator_;
134 std::unique_ptr<flutter::Shell> shell_;
135 std::unique_ptr<AccessibilityBridge> accessibility_bridge_;
137 fuchsia::intl::PropertyProviderPtr intl_property_provider_;
139 fuchsia::memorypressure::ProviderPtr memory_pressure_provider_;
140 fidl::Binding<fuchsia::memorypressure::Watcher>
141 memory_pressure_watcher_binding_;
144 fuchsia::memorypressure::Level latest_memory_pressure_level_;
146 bool intercept_all_input_ =
false;
virtual void OnEngineTerminate(const Engine *holder)=0
static flutter::ThreadHost CreateThreadHost(const std::string &name_prefix, const std::shared_ptr< sys::ServiceDirectory > &runner_services=nullptr)
void WriteProfileToTrace() const
friend class testing::EngineTest
Engine(Delegate &delegate, std::string thread_label, std::shared_ptr< sys::ServiceDirectory > svc, std::shared_ptr< sys::ServiceDirectory > runner_services, flutter::Settings settings, fuchsia::ui::views::ViewCreationToken view_creation_token, std::pair< fuchsia::ui::views::ViewRefControl, fuchsia::ui::views::ViewRef > view_ref_pair, UniqueFDIONS fdio_ns, fidl::InterfaceRequest< fuchsia::io::Directory > directory_request, FlutterRunnerProductConfiguration product_config, const std::vector< std::string > &dart_entrypoint_args)
std::optional< uint32_t > GetEngineReturnCode() const
An interface over the ability to schedule tasks on a TaskRunner.
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Dart_NativeFunction function
std::function< void()> ViewCallback
std::function< void(fuchsia::ui::composition::ContentId)> ViewIdCallback
std::function< void(fuchsia::ui::composition::ContentId, fuchsia::ui::composition::ChildViewWatcherHandle child_view_watcher)> ViewCreatedCallback
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
The collection of all the threads used by the engine.