7#include <fuchsia/accessibility/semantics/cpp/fidl.h>
8#include <fuchsia/media/cpp/fidl.h>
9#include <lib/async/cpp/task.h>
10#include <lib/zx/eventpair.h>
11#include <lib/zx/thread.h>
12#include <zircon/rights.h>
13#include <zircon/status.h>
14#include <zircon/types.h>
17#include "flutter/common/graphics/persistent_cache.h"
18#include "flutter/common/task_runners.h"
19#include "flutter/fml/make_copyable.h"
20#include "flutter/fml/message_loop.h"
21#include "flutter/fml/synchronization/waitable_event.h"
22#include "flutter/fml/task_runner.h"
23#include "flutter/runtime/dart_vm_lifecycle.h"
24#include "flutter/shell/common/rasterizer.h"
25#include "flutter/shell/common/run_configuration.h"
26#include "flutter/shell/common/serialization_callbacks.h"
27#include "flutter/shell/common/thread_host.h"
33#include "../runtime/dart/utils/files.h"
34#include "../runtime/dart/utils/root_inspect_node.h"
46zx_koid_t GetKoid(
const fuchsia::ui::views::ViewRef& view_ref) {
47 zx_handle_t handle = view_ref.reference.get();
48 zx_info_handle_basic_t
info;
49 zx_status_t status = zx_object_get_info(handle, ZX_INFO_HANDLE_BASIC, &
info,
50 sizeof(
info),
nullptr,
nullptr);
51 return status == ZX_OK ?
info.koid : ZX_KOID_INVALID;
54std::unique_ptr<flutter::PlatformMessage> MakeLocalizationPlatformMessage(
55 const fuchsia::intl::Profile& intl_profile) {
56 return std::make_unique<flutter::PlatformMessage>(
72 const fuchsia::media::ProfileProviderSyncPtr& profile_provider,
73 const std::string& role) {
74 ZX_ASSERT(profile_provider);
77 const zx_status_t dup_status =
78 zx::thread::self()->duplicate(ZX_RIGHT_SAME_RIGHTS, &dup);
79 if (dup_status != ZX_OK) {
81 <<
"Failed to duplicate thread handle when setting thread config: "
82 << zx_status_get_string(dup_status)
83 <<
". Thread will run at default priority.";
87 int64_t unused_period;
88 int64_t unused_capacity;
89 const zx_status_t status = profile_provider->RegisterHandlerWithCapacity(
90 std::move(dup), role, 0, 0.f, &unused_period, &unused_capacity);
91 if (status != ZX_OK) {
92 FML_LOG(WARNING) <<
"Failed to set thread role to \"" << role
93 <<
"\": " << zx_status_get_string(status)
94 <<
". Thread will run at default priority.";
100 const std::string& name_prefix,
101 const fuchsia::media::ProfileProviderSyncPtr& profile_provider,
103 ZX_ASSERT(profile_provider);
112 role = name_prefix +
".thread.background";
115 role = name_prefix +
".thread.display";
118 role = name_prefix +
".thread.raster";
121 role = name_prefix +
".thread.normal";
124 FML_LOG(WARNING) <<
"Unknown thread priority "
125 <<
static_cast<int>(config.
priority)
126 <<
". Thread will run at default priority.";
129 ZX_ASSERT(!role.empty());
131 SetThreadRole(profile_provider, role);
137 const std::string& name_prefix,
138 const std::shared_ptr<sys::ServiceDirectory>& services) {
157 std::shared_ptr<fuchsia::media::ProfileProviderSyncPtr>
158 media_profile_provider =
159 std::make_shared<fuchsia::media::ProfileProviderSyncPtr>();
161 const zx_status_t connect_status =
162 services->Connect(media_profile_provider->NewRequest());
163 if (connect_status != ZX_OK) {
165 <<
"Failed to connect to " << fuchsia::media::ProfileProvider::Name_
166 <<
": " << zx_status_get_string(connect_status)
167 <<
" This is not a fatal error, but threads created by the engine "
168 "will run at default priority, regardless of the requested "
173 SetThreadRole(*media_profile_provider, name_prefix +
".type.platform");
177 config_setter = [name_prefix, media_profile_provider](
179 SetThreadConfig(name_prefix, *media_profile_provider, config);
190 thread_host_config.SetUIConfig(
194 thread_host_config.SetIOConfig(
203 std::string thread_label,
204 std::shared_ptr<sys::ServiceDirectory> svc,
205 std::shared_ptr<sys::ServiceDirectory> runner_services,
207 fuchsia::ui::views::ViewCreationToken view_creation_token,
208 std::pair<fuchsia::ui::views::ViewRefControl,
209 fuchsia::ui::views::ViewRef> view_ref_pair,
211 fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
213 const std::vector<std::string>& dart_entrypoint_args)
215 thread_label_(
std::move(thread_label)),
216 thread_host_(CreateThreadHost(thread_label_, runner_services)),
217 view_creation_token_(
std::move(view_creation_token)),
218 memory_pressure_watcher_binding_(this),
219 latest_memory_pressure_level_(
fuchsia::memorypressure::Level::NORMAL),
220 intercept_all_input_(product_config.get_intercept_all_input()),
221 weak_factory_(this) {
222 Initialize(std::move(view_ref_pair), std::move(svc),
223 std::move(runner_services), std::move(settings),
224 std::move(fdio_ns), std::move(directory_request),
225 std::move(product_config), dart_entrypoint_args);
228void Engine::Initialize(
229 std::pair<fuchsia::ui::views::ViewRefControl, fuchsia::ui::views::ViewRef>
231 std::shared_ptr<sys::ServiceDirectory> svc,
232 std::shared_ptr<sys::ServiceDirectory> runner_services,
235 fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
237 const std::vector<std::string>& dart_entrypoint_args) {
239 FML_CHECK(view_creation_token_.value.is_valid());
248 platform_task_runner,
254 fuchsia::ui::views::FocuserHandle focuser;
255 fuchsia::ui::views::ViewRefFocusedHandle view_ref_focused;
256 fuchsia::ui::pointer::TouchSourceHandle touch_source;
257 fuchsia::ui::pointer::MouseSourceHandle mouse_source;
259 fuchsia::ui::composition::ViewBoundProtocols view_protocols;
260 view_protocols.set_view_focuser(focuser.NewRequest());
261 view_protocols.set_view_ref_focused(view_ref_focused.NewRequest());
262 view_protocols.set_touch_source(touch_source.NewRequest());
263 view_protocols.set_mouse_source(mouse_source.NewRequest());
266 fuchsia::ui::composition::FlatlandHandle flatland;
267 zx_status_t flatland_status =
268 runner_services->Connect<fuchsia::ui::composition::Flatland>(
269 flatland.NewRequest());
270 if (flatland_status != ZX_OK) {
271 FML_LOG(WARNING) <<
"fuchsia::ui::composition::Flatland connection failed: "
272 << zx_status_get_string(flatland_status);
276 fuchsia::accessibility::semantics::SemanticsManagerHandle semantics_manager;
277 zx_status_t semantics_status =
279 ->Connect<fuchsia::accessibility::semantics::SemanticsManager>(
280 semantics_manager.NewRequest());
281 if (semantics_status != ZX_OK) {
283 <<
"fuchsia::accessibility::semantics::SemanticsManager connection "
285 << zx_status_get_string(semantics_status);
289 fuchsia::ui::input::ImeServiceHandle ime_service;
290 zx_status_t ime_status =
291 runner_services->Connect<fuchsia::ui::input::ImeService>(
292 ime_service.NewRequest());
293 if (ime_status != ZX_OK) {
294 FML_LOG(WARNING) <<
"fuchsia::ui::input::ImeService connection failed: "
295 << zx_status_get_string(ime_status);
299 fuchsia::ui::input3::KeyboardHandle keyboard;
300 zx_status_t keyboard_status =
301 runner_services->Connect<fuchsia::ui::input3::Keyboard>(
302 keyboard.NewRequest());
304 <<
"fuchsia::ui::input3::Keyboard connection failed: "
305 << zx_status_get_string(keyboard_status);
308 fuchsia::ui::pointerinjector::RegistryHandle pointerinjector_registry;
309 zx_status_t pointerinjector_registry_status =
310 runner_services->Connect<fuchsia::ui::pointerinjector::Registry>(
311 pointerinjector_registry.NewRequest());
312 if (pointerinjector_registry_status != ZX_OK) {
314 <<
"fuchsia::ui::pointerinjector::Registry connection failed: "
315 << zx_status_get_string(pointerinjector_registry_status);
319 fuchsia::ui::views::ViewRef platform_view_ref;
320 view_ref_pair.second.Clone(&platform_view_ref);
321 fuchsia::ui::views::ViewRef accessibility_view_ref;
322 view_ref_pair.second.Clone(&accessibility_view_ref);
323 fuchsia::ui::views::ViewRef isolate_view_ref;
324 view_ref_pair.second.Clone(&isolate_view_ref);
332 fml::closure session_error_callback = [task_runner = platform_task_runner,
333 weak = weak_factory_.GetWeakPtr()]() {
334 task_runner->PostTask([weak]() {
336 FML_LOG(
ERROR) <<
"Terminating from session_error_callback";
345 fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
347 auto session_inspect_node =
350 [
this, &view_embedder_latch,
351 session_inspect_node = std::move(session_inspect_node),
352 flatland = std::move(flatland),
353 session_error_callback = std::move(session_error_callback),
354 view_creation_token = std::move(view_creation_token_),
355 view_protocols = std::move(view_protocols),
356 request = parent_viewport_watcher.NewRequest(),
357 view_ref_pair = std::move(view_ref_pair),
359 if (software_rendering) {
360 surface_producer_ = std::make_shared<SoftwareSurfaceProducer>();
362 surface_producer_ = std::make_shared<VulkanSurfaceProducer>();
365 flatland_connection_ = std::make_shared<FlatlandConnection>(
366 thread_label_, std::move(flatland),
367 std::move(session_error_callback), [](
auto) {});
369 fuchsia::ui::views::ViewIdentityOnCreation view_identity = {
370 .view_ref = std::move(view_ref_pair.second),
371 .view_ref_control = std::move(view_ref_pair.first)};
372 view_embedder_ = std::make_shared<ExternalViewEmbedder>(
373 std::move(view_creation_token), std::move(view_identity),
374 std::move(view_protocols), std::move(request), flatland_connection_,
375 surface_producer_, intercept_all_input_);
377 view_embedder_latch.
Signal();
379 view_embedder_latch.
Wait();
382 set_semantics_enabled_callback = [
this](
bool enabled) {
391 dispatch_semantics_action_callback =
400 const std::string accessibility_inspect_name =
401 std::to_string(GetKoid(accessibility_view_ref));
402 accessibility_bridge_ = std::make_unique<AccessibilityBridge>(
403 std::move(set_semantics_enabled_callback),
404 std::move(dispatch_semantics_action_callback),
405 std::move(semantics_manager), std::move(accessibility_view_ref),
407 std::move(accessibility_inspect_name)));
410 &Engine::DebugWireframeSettingsChanged,
this, std::placeholders::_1);
413 &Engine::CreateView,
this, std::placeholders::_1, std::placeholders::_2,
414 std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
417 &Engine::UpdateView,
this, std::placeholders::_1, std::placeholders::_2,
418 std::placeholders::_3, std::placeholders::_4);
421 &Engine::DestroyView,
this, std::placeholders::_1, std::placeholders::_2);
424 std::bind(&Engine::CreateSurface,
this);
429 fit::closure on_session_listener_error_callback =
430 [task_runner = platform_task_runner,
431 weak = weak_factory_.GetWeakPtr()]() {
432 task_runner->PostTask([weak]() {
435 "on_session_listener_error_callback";
445 settings, task_runners.GetIOTaskRunner());
446 run_configuration.SetEntrypointArgs(std::move(dart_entrypoint_args));
450 accessibility_bridge_->AddSemanticsNodeUpdate(updates, pixel_ratio);
454 [
this](
const std::string&
message) {
455 accessibility_bridge_->RequestAnnounce(
message);
461 [
this, view_ref = std::move(platform_view_ref),
462 parent_viewport_watcher = std::move(parent_viewport_watcher),
463 ime_service = std::move(ime_service), keyboard = std::move(keyboard),
464 focuser = std::move(focuser),
465 view_ref_focused = std::move(view_ref_focused),
466 touch_source = std::move(touch_source),
467 mouse_source = std::move(mouse_source),
468 pointerinjector_registry = std::move(pointerinjector_registry),
469 on_session_listener_error_callback =
470 std::move(on_session_listener_error_callback),
471 on_enable_wireframe_callback =
472 std::move(on_enable_wireframe_callback),
473 on_create_view_callback = std::move(on_create_view_callback),
474 on_update_view_callback = std::move(on_update_view_callback),
475 on_destroy_view_callback = std::move(on_destroy_view_callback),
476 on_create_surface_callback = std::move(on_create_surface_callback),
477 on_semantics_node_update_callback =
478 std::move(on_semantics_node_update_callback),
479 on_request_announce_callback =
480 std::move(on_request_announce_callback),
481 external_view_embedder = GetExternalViewEmbedder(),
482 await_vsync_callback =
484 flatland_connection_->AwaitVsync(cb);
486 await_vsync_for_secondary_callback_callback =
488 flatland_connection_->AwaitVsyncForSecondaryCallback(cb);
495 on_shader_warmup_callback =
497 const std::vector<std::string>& skp_names,
498 std::function<void(uint32_t)> completion_callback,
502 ->GetConcurrentMessageLoop()
505 shell.GetTaskRunners().GetRasterTaskRunner().get(),
509 skp_names, completion_callback);
512 WarmupSkps(
shell.GetDartVM()
513 ->GetConcurrentMessageLoop()
516 shell.GetTaskRunners().GetRasterTaskRunner().get(),
520 std::nullopt, std::nullopt);
524 return std::make_unique<flutter_runner::PlatformView>(
525 shell,
shell.GetTaskRunners(), std::move(view_ref),
526 std::move(external_view_embedder), std::move(ime_service),
527 std::move(keyboard), std::move(touch_source),
528 std::move(mouse_source), std::move(focuser),
529 std::move(view_ref_focused), std::move(parent_viewport_watcher),
530 std::move(pointerinjector_registry),
531 std::move(on_enable_wireframe_callback),
532 std::move(on_create_view_callback),
533 std::move(on_update_view_callback),
534 std::move(on_destroy_view_callback),
535 std::move(on_create_surface_callback),
536 std::move(on_semantics_node_update_callback),
537 std::move(on_request_announce_callback),
538 std::move(on_shader_warmup_callback),
539 std::move(await_vsync_callback),
540 std::move(await_vsync_for_secondary_callback_callback),
547 return std::make_unique<flutter::Rasterizer>(shell);
550 settings.root_isolate_create_callback =
551 std::bind(&Engine::OnMainIsolateStart,
this);
552 settings.root_isolate_shutdown_callback =
553 std::bind([weak = weak_factory_.GetWeakPtr(),
554 runner = task_runners.GetPlatformTaskRunner()]() {
555 runner->PostTask([weak = std::move(weak)] {
557 weak->OnMainIsolateShutdown();
563 fuchsia::fonts::ProviderSyncPtr sync_font_provider;
564 runner_services->Connect(sync_font_provider.NewRequest());
566 sync_font_provider.Unbind().TakeChannel().release();
572 std::move(task_runners),
574 std::move(on_create_platform_view),
575 std::move(on_create_rasterizer)
586 isolate_configurator_ = std::make_unique<IsolateConfigurator>(
587 std::move(fdio_ns), directory_request.TakeChannel(),
588 std::move(isolate_view_ref.reference));
592 shell_->GetPlatformView()->NotifyCreated();
599 memory_pressure_provider_.set_error_handler([](zx_status_t status) {
601 <<
"Failed to connect to " << fuchsia::memorypressure::Provider::Name_
602 <<
": " << zx_status_get_string(status)
603 <<
" This is not a fatal error, but the heap will not be "
604 <<
" compacted when memory is low.";
611 ZX_ASSERT(runner_services->Connect(
612 memory_pressure_provider_.NewRequest()) == ZX_OK);
614 FML_VLOG(1) <<
"Registering memorypressure watcher";
618 memory_pressure_provider_->RegisterWatcher(
619 memory_pressure_watcher_binding_.NewBinding());
627 intl_property_provider_.set_error_handler([](zx_status_t status) {
628 FML_LOG(WARNING) <<
"Failed to connect to "
629 << fuchsia::intl::PropertyProvider::Name_ <<
": "
630 << zx_status_get_string(status)
631 <<
" This is not a fatal error, but the user locale "
632 <<
" preferences will not be forwarded to flutter apps";
638 ZX_ASSERT(runner_services->Connect(intl_property_provider_.NewRequest()) ==
641 auto get_profile_callback = [weak = weak_factory_.GetWeakPtr()](
642 const fuchsia::intl::Profile&
profile) {
647 FML_LOG(WARNING) <<
"Got intl Profile without locales";
649 auto message = MakeLocalizationPlatformMessage(profile);
650 FML_VLOG(1) <<
"Sending LocalizationPlatformMessage";
651 weak->shell_->GetPlatformView()->DispatchPlatformMessage(
655 FML_VLOG(1) <<
"Requesting intl Profile";
658 intl_property_provider_->GetProfile(get_profile_callback);
661 intl_property_provider_.events().OnChange = [
this, runner_services,
662 get_profile_callback]() {
663 FML_VLOG(1) << fuchsia::intl::PropertyProvider::Name_ <<
": OnChange";
664 runner_services->Connect(intl_property_provider_.NewRequest());
665 intl_property_provider_->GetProfile(get_profile_callback);
669 auto on_run_failure = [weak = weak_factory_.GetWeakPtr()]() {
678 shell_->GetTaskRunners().GetUITaskRunner()->PostTask(
680 run_configuration = std::move(run_configuration),
687 if (
engine->Run(std::move(run_configuration)) ==
701 view_embedder_.reset();
702 flatland_connection_.reset();
703 surface_producer_.reset();
704 view_embedder_latch.
Signal();
706 view_embedder_latch.
Wait();
709std::optional<uint32_t> Engine::GetEngineReturnCode()
const {
713 std::optional<uint32_t> code;
716 shell_->GetTaskRunners().GetUITaskRunner(),
717 [&latch, &code,
engine = shell_->GetEngine()]() {
719 code = engine->GetUIIsolateReturnCode();
727void Engine::OnMainIsolateStart() {
728 if (!isolate_configurator_ ||
729 !isolate_configurator_->ConfigureCurrentIsolate()) {
730 FML_LOG(
ERROR) <<
"Could not configure some native embedder bindings for a "
735void Engine::OnMainIsolateShutdown() {
739void Engine::Terminate() {
745void Engine::DebugWireframeSettingsChanged(
bool enabled) {
748 shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask([]() {
754void Engine::CreateView(int64_t view_id,
755 ViewCallback on_view_created,
756 ViewCreatedCallback on_view_bound,
760 shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
761 [
this, view_id, hit_testable, focusable,
762 on_view_created = std::move(on_view_created),
763 on_view_bound = std::move(on_view_bound)]() {
765 view_embedder_->CreateView(view_id, std::move(on_view_created),
766 std::move(on_view_bound));
768 hit_testable, focusable);
772void Engine::UpdateView(int64_t view_id,
777 shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
778 [
this, view_id, occlusion_hint, hit_testable, focusable]() {
780 view_embedder_->SetViewProperties(view_id, occlusion_hint, hit_testable,
785void Engine::DestroyView(int64_t view_id, ViewIdCallback on_view_unbound) {
788 shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
789 [
this, view_id, on_view_unbound = std::move(on_view_unbound)]() {
791 view_embedder_->DestroyView(view_id, std::move(on_view_unbound));
795std::unique_ptr<flutter::Surface> Engine::CreateSurface() {
796 return std::make_unique<Surface>(thread_label_, GetExternalViewEmbedder(),
797 surface_producer_->gr_context());
800std::shared_ptr<flutter::ExternalViewEmbedder>
801Engine::GetExternalViewEmbedder() {
803 return view_embedder_;
806#if !defined(DART_PRODUCT)
807void Engine::WriteProfileToTrace()
const {
808 Dart_Port main_port = shell_->GetEngine()->GetUIIsolateMainPort();
818void Engine::WarmupSkps(
821 std::shared_ptr<SurfaceProducer> surface_producer,
823 std::shared_ptr<flutter::AssetManager> asset_manager,
824 std::optional<
const std::vector<std::string>> skp_names,
825 std::optional<std::function<
void(uint32_t)>> maybe_completion_callback,
829 auto completion_callback = [maybe_completion_callback](uint32_t skp_count) {
830 if (maybe_completion_callback.has_value() &&
831 maybe_completion_callback.value()) {
832 maybe_completion_callback.value()(skp_count);
846 std::unique_ptr<SurfaceProducerSurface>* skp_warmup_surface =
847 new std::unique_ptr<SurfaceProducerSurface>(
nullptr);
851 concurrent_task_runner->
PostTask([raster_task_runner, size,
852 skp_warmup_surface, surface_producer,
853 asset_manager, skp_names,
854 completion_callback, synchronous]() {
855 TRACE_DURATION(
"flutter",
"DeserializeSkps");
856 std::vector<std::unique_ptr<fml::Mapping>> skp_mappings;
858 for (
auto& skp_name : skp_names.
value()) {
859 auto skp_mapping = asset_manager->GetAsMapping(skp_name);
861 skp_mappings.push_back(std::move(skp_mapping));
863 FML_LOG(
ERROR) <<
"Failed to get mapping for " << skp_name;
867 skp_mappings = asset_manager->GetAsMappings(
".*\\.skp$",
"shaders");
870 if (skp_mappings.empty()) {
872 <<
"Engine::WarmupSkps got zero SKP mappings, returning early";
873 completion_callback(0);
878 for (
auto& mapping : skp_mappings) {
882 FML_LOG(INFO) <<
"Shader warmup got " << skp_mappings.size()
883 <<
" skp's with a total size of " <<
total_size <<
" bytes";
885 std::vector<sk_sp<SkPicture>> pictures;
887 for (
auto& mapping : skp_mappings) {
888 std::unique_ptr<SkMemoryStream>
stream =
896 FML_LOG(
ERROR) <<
"Failed to deserialize picture " << i;
902 raster_task_runner->
PostTask([picture, skp_warmup_surface, size,
903 surface_producer, completion_callback, i,
904 count = skp_mappings.size(), synchronous] {
905 TRACE_DURATION(
"flutter",
"WarmupSkp");
906 if (*skp_warmup_surface == nullptr) {
907 skp_warmup_surface->reset(
908 surface_producer->ProduceOffscreenSurface(size).release());
910 if (*skp_warmup_surface == nullptr) {
911 FML_LOG(ERROR) <<
"Failed to create offscreen warmup surface";
914 completion_callback(0);
920 (*skp_warmup_surface)
923 ->drawPicture(picture);
925 if (i ==
count - 1) {
930 completion_callback(
count);
933 if (surface_producer->gr_context()) {
936 surface_producer->gr_context()->flushAndSubmit();
942 flush_info.fFinishedProc = [](
void* skp_warmup_surface) {
943 delete static_cast<std::unique_ptr<SurfaceProducerSurface>*
>(
947 surface_producer->gr_context()->flush(flush_info);
948 surface_producer->gr_context()->submit(
952 if (i ==
count - 1) {
953 delete skp_warmup_surface;
962void Engine::OnLevelChanged(
963 fuchsia::memorypressure::Level level,
964 fuchsia::memorypressure::Watcher::OnLevelChangedCallback
callback) {
970 FML_LOG(WARNING) <<
"memorypressure watcher: OnLevelChanged from "
971 <<
static_cast<int>(latest_memory_pressure_level_) <<
" to "
972 <<
static_cast<int>(level);
974 if (latest_memory_pressure_level_ == fuchsia::memorypressure::Level::NORMAL &&
975 (level == fuchsia::memorypressure::Level::WARNING ||
976 level == fuchsia::memorypressure::Level::CRITICAL)) {
978 <<
"memorypressure watcher: notifying Flutter that memory is low";
979 shell_->NotifyLowMemoryWarning();
981 latest_memory_pressure_level_ = level;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static size_t total_size(SkSBlockAllocator< N > &pool)
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
static std::unique_ptr< SkMemoryStream > MakeDirect(const void *data, size_t length)
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
static inspect::Node CreateRootChild(const std::string &name)
static std::shared_ptr< AssetManager > asset_manager()
static PersistentCache * GetCacheForProcess()
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
static std::unique_ptr< Shell > Create(const PlatformData &platform_data, const TaskRunners &task_runners, Settings settings, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer, bool is_gpu_disabled=false)
Creates a shell instance using the provided settings. The callbacks to create the various shell subco...
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
std::function< void(bool)> SetSemanticsEnabledCallback
std::function< void(int32_t, flutter::SemanticsAction)> DispatchSemanticsActionCallback
static flutter::ThreadHost CreateThreadHost(const std::string &name_prefix, const std::shared_ptr< sys::ServiceDirectory > &runner_services=nullptr)
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)
bool enable_shader_warmup_dart_hooks()
bool software_rendering()
bool enable_shader_warmup()
An interface over the ability to schedule tasks on a TaskRunner.
virtual void PostTask(const fml::closure &task)=0
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
@ kDisplay
Suitable for threads which generate data for the display.
static void SetCurrentThreadName(const ThreadConfig &config)
DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port, char **error)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
#define FML_VLOG(verbose_level)
#define FML_LOG(severity)
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
sk_sp< const SkPicture > picture
std::function< void(const std::vector< std::string > &, std::function< void(uint32_t)>, uint64_t, uint64_t)> OnShaderWarmupCallback
fit::function< void(int64_t, ViewCallback, ViewCreatedCallback, bool, bool)> OnCreateViewCallback
fit::function< void(int64_t, ViewIdCallback)> OnDestroyViewCallback
std::function< void(fml::TimePoint, fml::TimePoint)> FireCallbackCallback
fit::function< void(int64_t, SkRect, bool, bool)> OnUpdateViewCallback
fit::function< std::unique_ptr< flutter::Surface >()> OnCreateSurfaceCallback
fit::function< void(flutter::SemanticsNodeUpdates, float)> OnSemanticsNodeUpdateCallback
fml::MallocMapping MakeLocalizationPlatformMessageData(const Profile &intl_profile)
fit::function< void(std::string)> OnRequestAnnounceCallback
fit::function< void(bool)> OnEnableWireframeCallback
sk_sp< SkImage > DeserializeImageWithoutData(const void *data, size_t length, void *ctx)
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
sk_sp< SkTypeface > DeserializeTypefaceWithoutData(const void *data, size_t length, void *ctx)
fml::Thread::ThreadConfigSetter ThreadConfigSetter
internal::CopyableLambda< T > MakeCopyable(T lambda)
std::function< void()> closure
GrGpuFinishedContext fFinishedContext
SkDeserialTypefaceProc fTypefaceProc
SkDeserialImageProc fImageProc
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeEmpty()
static std::string MakeThreadName(Type type, const std::string &prefix)
Use the prefix and thread type to generator a thread name.
void SetRasterConfig(const ThreadConfig &)
Specified the IO Thread Config, meanwhile set the mask.
The collection of all the threads used by the engine.
std::unique_ptr< fml::Thread > io_thread
std::unique_ptr< fml::Thread > raster_thread
std::unique_ptr< fml::Thread > ui_thread
The ThreadConfig is the thread info include thread name, thread priority.
#define TRACE_EVENT0(category_group, name)