25 std::unique_ptr<EmbedderThreadHost> thread_host,
31 std::unique_ptr<EmbedderExternalTextureResolver> external_texture_resolver)
34 run_configuration_(
std::move(run_configuration)),
36 on_create_platform_view,
37 on_create_rasterizer)),
38 external_texture_resolver_(
std::move(external_texture_resolver)) {}
44 FML_DLOG(ERROR) <<
"Invalid shell arguments.";
49 FML_DLOG(ERROR) <<
"Shell already initialized";
54 shell_args_->on_create_platform_view, shell_args_->on_create_rasterizer);
80 if (thread_host_->GetTaskRunners().GetUITaskRunner() &&
81 !thread_host_->GetTaskRunners()
83 ->RunsTasksOnCurrentThread()) {
88 thread_host_->GetTaskRunners().GetUITaskRunner()->PostTask([&] {
89 ui_thread_running.
Signal();
90 ui_thread_block.
Wait();
91 ui_thread_finished.
Signal();
95 ui_thread_running.
Wait();
96 thread_host_->InvalidateActiveRunners();
101 ui_thread_finished.
Wait();
103 thread_host_->InvalidateActiveRunners();
105 thread_host_.reset();
112 shell_->RunEngine(std::move(run_configuration_));
117 return static_cast<bool>(shell_);
121 return task_runners_;
129 shell_->GetPlatformView()->NotifyCreated();
138 shell_->GetPlatformView()->NotifyDestroyed();
159 std::unique_ptr<flutter::PointerDataPacket> packet) {
174 std::unique_ptr<PlatformMessage>
message) {
192 shell_->GetPlatformView()->RegisterTexture(
193 external_texture_resolver_->ResolveExternalTexture(
texture));
201 shell_->GetPlatformView()->UnregisterTexture(
texture);
209 shell_->GetPlatformView()->MarkTextureFrameAvailable(
texture);
262 task_runners_, baton, frame_start_time, frame_target_time);
270 return shell_->ReloadSystemFonts();
278 shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(task);
286 if (task ==
nullptr) {
289 auto result = thread_host_->PostTask(
reinterpret_cast<intptr_t
>(task->
runner),
299 shell_->FlushMicrotaskQueue();
307 if (!
IsValid() || closure ==
nullptr) {
311 const auto trampoline = [closure](
314 runner->PostTask([closure,
type] { closure(
type); });
318 const auto& task_runners = shell_->GetTaskRunners();
320 task_runners.GetRasterTaskRunner());
324 task_runners.GetPlatformTaskRunner());
327 auto vm = shell_->GetDartVM();
328 vm->GetConcurrentMessageLoop()->PostTaskToAllWorkers(
349 return *shell_.get();
bool MarkTextureFrameAvailable(int64_t texture)
bool PostTaskOnEngineManagedNativeThreads(const std::function< void(FlutterNativeThreadType)> &closure) const
EmbedderEngine(std::unique_ptr< EmbedderThreadHost > thread_host, const TaskRunners &task_runners, const Settings &settings, RunConfiguration run_configuration, const Shell::CreateCallback< PlatformView > &on_create_platform_view, const Shell::CreateCallback< Rasterizer > &on_create_rasterizer, std::unique_ptr< EmbedderExternalTextureResolver > external_texture_resolver)
bool RegisterTexture(int64_t texture)
bool PostRenderThreadTask(const fml::closure &task)
bool SetAccessibilityFeatures(int32_t flags)
bool SetViewportMetrics(int64_t view_id, const flutter::ViewportMetrics &metrics)
bool DispatchSemanticsAction(int64_t view_id, int node_id, flutter::SemanticsAction action, fml::MallocMapping args)
bool RunTask(const FlutterTask *task)
bool DispatchPointerDataPacket(std::unique_ptr< flutter::PointerDataPacket > packet)
const TaskRunners & GetTaskRunners() const
bool UnregisterTexture(int64_t texture)
bool SendPlatformMessage(std::unique_ptr< PlatformMessage > message)
bool SetSemanticsEnabled(bool enabled)
bool OnVsyncEvent(intptr_t baton, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
Specifies all the configuration required by the runtime library to launch the root isolate....
bool IsValid() const
A valid run configuration only guarantees that the engine should be able to find the assets and the i...
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
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
static bool OnEmbedderVsync(const flutter::TaskRunners &task_runners, intptr_t baton, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
A Mapping like NonOwnedMapping, but uses Free as its release proc.
virtual bool RunsTasksOnCurrentThread()
virtual TaskQueueId GetTaskQueueId()
@ kFlutterNativeThreadTypeWorker
@ kFlutterNativeThreadTypeUI
@ kFlutterNativeThreadTypePlatform
@ kFlutterNativeThreadTypeRender
TaskRunners task_runners_
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS GBytes * message
G_BEGIN_DECLS FlutterViewId view_id
#define FML_DLOG(severity)
#define FML_DCHECK(condition)
std::function< void()> closure
Shell::CreateCallback< PlatformView > on_create_platform_view
ShellArgs(const Settings &p_settings, Shell::CreateCallback< PlatformView > p_on_create_platform_view, Shell::CreateCallback< Rasterizer > p_on_create_rasterizer)
Shell::CreateCallback< Rasterizer > on_create_rasterizer