20 : task_runners(task_runners) {}
29 image_generator_registry,
30 std::string advisory_script_uri,
31 std::string advisory_script_entrypoint,
32 bool deterministic_rendering_enabled,
33 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
34 std::shared_future<impeller::RuntimeStageBackend> runtime_stage_backend,
36 bool enable_flutter_gpu)
37 : task_runners(task_runners),
38 snapshot_delegate(
std::move(snapshot_delegate)),
39 io_manager(
std::move(io_manager)),
40 unref_queue(
std::move(unref_queue)),
41 image_decoder(
std::move(image_decoder)),
42 image_generator_registry(
std::move(image_generator_registry)),
43 advisory_script_uri(
std::move(advisory_script_uri)),
44 advisory_script_entrypoint(
std::move(advisory_script_entrypoint)),
45 deterministic_rendering_enabled(deterministic_rendering_enabled),
46 concurrent_task_runner(
std::move(concurrent_task_runner)),
47 runtime_stage_backend(
std::move(runtime_stage_backend)),
48 enable_impeller(enable_impeller),
49 enable_flutter_gpu(enable_flutter_gpu) {}
57 std::shared_ptr<IsolateNameServer> isolate_name_server,
60 : add_callback_(
std::move(add_callback)),
61 remove_callback_(
std::move(remove_callback)),
63 is_root_isolate_(is_root_isolate),
65 log_message_callback_(
std::move(log_message_callback)),
66 isolate_name_server_(
std::move(isolate_name_server)),
68 AddOrRemoveTaskObserver(
true );
72 AddOrRemoveTaskObserver(
false );
91void UIDartState::DidSetIsolate() {
92 main_port_ = Dart_GetMainPortId();
104 tonic::ToDart(
"UI actions are only available on root isolate."));
110 if (platform_configuration_) {
111 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
117 return static_cast<UIDartState*
>(DartState::Current());
121 std::unique_ptr<PlatformConfiguration> platform_configuration) {
124 if (platform_configuration_) {
125 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
131 std::weak_ptr<PlatformMessageHandler>
handler) {
133 platform_message_handler_ = std::move(
handler);
148std::shared_ptr<fml::ConcurrentTaskRunner>
169void UIDartState::AddOrRemoveTaskObserver(
bool add) {
176 FML_DCHECK(add_callback_ && remove_callback_);
180 add_callback_(
reinterpret_cast<intptr_t
>(
this),
182 }
else if (callback_queue_id_.has_value()) {
183 remove_callback_(callback_queue_id_.value(),
184 reinterpret_cast<intptr_t
>(
this));
185 callback_queue_id_.reset();
205 return isolate_name_server_;
217 const std::string&
message)
const {
218 if (log_message_callback_) {
219 log_message_callback_(tag,
message);
224 std::unique_ptr<PlatformMessage>
message) {
225 if (platform_configuration_) {
226 platform_configuration_->client()->HandlePlatformMessage(
229 std::shared_ptr<PlatformMessageHandler>
handler =
230 platform_message_handler_.lock();
235 "No platform channel handler registered for background isolate.");
243 return IsRootIsolate() ?
reinterpret_cast<int64_t
>(
this) : 0;
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
fml::RefPtr< flutter::SkiaUnrefQueue > GetSkiaUnrefQueue() const
bool HasPendingMicrotasks()
std::shared_ptr< fml::ConcurrentTaskRunner > GetConcurrentTaskRunner() const
fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistry > GetImageGeneratorRegistry() const
PlatformConfiguration * platform_configuration() const
fml::TaskRunnerAffineWeakPtr< ImageDecoder > GetImageDecoder() const
UnhandledExceptionCallback unhandled_exception_callback() const
bool IsRootIsolate() const
bool IsFlutterGPUEnabled() const
Whether Flutter GPU is enabled for this application.
void FlushMicrotasksNow()
void SetPlatformConfiguration(std::unique_ptr< PlatformConfiguration > platform_configuration)
const std::string & logger_prefix() const
tonic::DartErrorHandleType GetLastError()
fml::WeakPtr< IOManager > GetIOManager() const
const TaskRunners & GetTaskRunners() const
bool IsDeterministicRenderingEnabled() const
Whether deterministic rendering practices are enabled for this application.
virtual Dart_Isolate CreatePlatformIsolate(Dart_Handle entry_point, char **error)
bool IsImpellerEnabled() const
Whether Impeller is enabled for this application.
std::shared_ptr< IsolateNameServer > GetIsolateNameServer() const
void SetDebugName(const std::string &name)
int64_t GetRootIsolateToken() const
void ScheduleMicrotask(Dart_Handle handle)
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > GetSnapshotDelegate() const
const std::string & GetAdvisoryScriptURI() const
impeller::RuntimeStageBackend GetRuntimeStageBackend() const
The runtime stage to use for fragment shaders.
void LogMessage(const std::string &tag, const std::string &message) const
void SetPlatformMessageHandler(std::weak_ptr< PlatformMessageHandler > handler)
static UIDartState * Current()
static void ThrowIfUIOperationsProhibited()
Dart_Handle HandlePlatformMessage(std::unique_ptr< PlatformMessage > message)
UIDartState(TaskObserverAdd add_callback, TaskObserverRemove remove_callback, std::string logger_prefix, UnhandledExceptionCallback unhandled_exception_callback, LogMessageCallback log_message_callback, std::shared_ptr< IsolateNameServer > isolate_name_server, bool is_root_isolate_, const UIDartState::Context &context)
const std::string & debug_name() const
DartErrorHandleType isolate_last_error() const
void ScheduleMicrotask(Dart_Handle callback)
bool HasMicrotasks() const
DartErrorHandleType GetLastError()
DartMessageHandler & message_handler()
const gchar FlBinaryMessengerMessageHandler handler
G_BEGIN_DECLS GBytes * message
const uint8_t uint32_t uint32_t GError ** error
#define FML_UNREACHABLE()
#define FML_DCHECK(condition)
std::function< void(fml::TaskQueueId, intptr_t)> TaskObserverRemove
std::function< fml::TaskQueueId(intptr_t, fml::closure)> TaskObserverAdd
std::function< bool(const std::string &, const std::string &)> UnhandledExceptionCallback
std::function< void(const std::string &, const std::string &)> LogMessageCallback
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
fml::RefPtr< SkiaUnrefQueue > unref_queue
bool enable_flutter_gpu
Whether flutter_gpu is enabled or not.
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.
std::string advisory_script_uri
std::shared_future< impeller::RuntimeStageBackend > runtime_stage_backend
The runtime stage backend for fragment shaders.
Context(const TaskRunners &task_runners)
const TaskRunners task_runners
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate
bool enable_impeller
Whether Impeller is enabled or not.
fml::TaskRunnerAffineWeakPtr< ImageDecoder > image_decoder
The image decoder.
std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner
bool deterministic_rendering_enabled
Whether deterministic rendering practices should be used.
fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistry > image_generator_registry
std::string advisory_script_entrypoint