Flutter Engine
 
Loading...
Searching...
No Matches
flutter::UIDartState Class Reference

#include <ui_dart_state.h>

Inheritance diagram for flutter::UIDartState:
tonic::DartState flutter::DartIsolate

Classes

struct  Context
 The subset of state which is owned by the shell or engine and passed through the RuntimeController into DartIsolates. If a shell-owned resource needs to be exposed to the framework via UIDartState, a pointer to the resource can be added to this struct with appropriate default construction. More...
 

Public Member Functions

Dart_Port main_port () const
 
bool IsRootIsolate () const
 
void SetDebugName (const std::string &name)
 
const std::string & debug_name () const
 
const std::string & logger_prefix () const
 
PlatformConfigurationplatform_configuration () const
 
void SetPlatformMessageHandler (std::weak_ptr< PlatformMessageHandler > handler)
 
Dart_Handle HandlePlatformMessage (std::unique_ptr< PlatformMessage > message)
 
const TaskRunnersGetTaskRunners () const
 
void ScheduleMicrotask (Dart_Handle handle)
 
void FlushMicrotasksNow ()
 
bool HasPendingMicrotasks ()
 
fml::WeakPtr< IOManagerGetIOManager () const
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const
 
std::shared_ptr< fml::ConcurrentTaskRunnerGetConcurrentTaskRunner () const
 
fml::TaskRunnerAffineWeakPtr< SnapshotDelegateGetSnapshotDelegate () const
 
fml::TaskRunnerAffineWeakPtr< ImageDecoderGetImageDecoder () const
 
fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistryGetImageGeneratorRegistry () const
 
std::shared_ptr< IsolateNameServerGetIsolateNameServer () const
 
tonic::DartErrorHandleType GetLastError ()
 
void LogMessage (const std::string &tag, const std::string &message) const
 
UnhandledExceptionCallback unhandled_exception_callback () const
 
int64_t GetRootIsolateToken () const
 
bool IsDeterministicRenderingEnabled () const
 Whether deterministic rendering practices are enabled for this application.
 
bool IsImpellerEnabled () const
 Whether Impeller is enabled for this application.
 
bool IsFlutterGPUEnabled () const
 Whether Flutter GPU is enabled for this application.
 
impeller::RuntimeStageBackend GetRuntimeStageBackend () const
 The runtime stage to use for fragment shaders.
 
virtual Dart_Isolate CreatePlatformIsolate (Dart_Handle entry_point, char **error)
 
- Public Member Functions inherited from tonic::DartState
 DartState (int dirfd=-1, std::function< void(Dart_Handle)> message_epilogue=nullptr)
 
virtual ~DartState ()
 
std::weak_ptr< DartStateGetWeakPtr ()
 
Dart_Isolate isolate ()
 
void SetIsolate (Dart_Isolate isolate)
 
Dart_PersistentHandle private_constructor_name ()
 
DartClassLibraryclass_library ()
 
DartMessageHandlermessage_handler ()
 
FileLoaderfile_loader ()
 
void MessageEpilogue (Dart_Handle message_result)
 
void SetReturnCode (uint32_t return_code)
 
void SetReturnCodeCallback (std::function< void(uint32_t)> callback)
 
bool has_set_return_code () const
 
void SetIsShuttingDown ()
 
bool IsShuttingDown ()
 

Static Public Member Functions

static UIDartStateCurrent ()
 
static void ThrowIfUIOperationsProhibited ()
 
- Static Public Member Functions inherited from tonic::DartState
static DartStateFrom (Dart_Isolate isolate)
 
static DartStateCurrent ()
 
static Dart_Handle HandleLibraryTag (Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
 

Protected Member Functions

 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)
 
 ~UIDartState () override
 
void SetPlatformConfiguration (std::unique_ptr< PlatformConfiguration > platform_configuration)
 
const std::string & GetAdvisoryScriptURI () const
 
- Protected Member Functions inherited from tonic::DartState
Dart_Isolate isolate () const
 
 TONIC_DISALLOW_COPY_AND_ASSIGN (DartState)
 

Detailed Description

Definition at line 37 of file ui_dart_state.h.

Constructor & Destructor Documentation

◆ UIDartState()

flutter::UIDartState::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 
)
protected

Definition at line 51 of file ui_dart_state.cc.

60 : add_callback_(std::move(add_callback)),
61 remove_callback_(std::move(remove_callback)),
62 logger_prefix_(std::move(logger_prefix)),
63 is_root_isolate_(is_root_isolate),
64 unhandled_exception_callback_(std::move(unhandled_exception_callback)),
65 log_message_callback_(std::move(log_message_callback)),
66 isolate_name_server_(std::move(isolate_name_server)),
67 context_(context) {
68 AddOrRemoveTaskObserver(true /* add */);
69}
UnhandledExceptionCallback unhandled_exception_callback() const
const std::string & logger_prefix() const

◆ ~UIDartState()

flutter::UIDartState::~UIDartState ( )
overrideprotected

Definition at line 71 of file ui_dart_state.cc.

71 {
72 AddOrRemoveTaskObserver(false /* remove */);
73}

Member Function Documentation

◆ CreatePlatformIsolate()

Dart_Isolate flutter::UIDartState::CreatePlatformIsolate ( Dart_Handle  entry_point,
char **  error 
)
virtual

Reimplemented in flutter::DartIsolate.

Definition at line 246 of file ui_dart_state.cc.

247 {
249 return nullptr;
250}
#define FML_UNREACHABLE()
Definition logging.h:128

References FML_UNREACHABLE.

Referenced by flutter::PlatformIsolateNativeApi::Spawn().

◆ Current()

UIDartState * flutter::UIDartState::Current ( )
static

Definition at line 116 of file ui_dart_state.cc.

116 {
117 return static_cast<UIDartState*>(DartState::Current());
118}
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)

Referenced by flutter::PlatformConfiguration::BeginFrame(), flutter::PlatformConfigurationNativeApi::ComputePlatformResolvedLocale(), flutter::PlatformConfigurationNativeApi::DefaultRouteName(), flutter::Picture::DoRasterizeToImage(), flutter::EncodeImage(), flutter::PlatformConfigurationNativeApi::EndWarmUpFrame(), flutter::gpu::Context::GetDefaultContext(), flutter::MultiFrameCodec::getNextFrame(), flutter::SingleFrameCodec::getNextFrame(), flutter::PlatformConfigurationNativeApi::GetPersistentIsolateData(), flutter::PlatformConfigurationNativeApi::GetRootIsolateToken(), flutter::PlatformConfigurationNativeApi::GetScaledFontSize(), flutter::FragmentProgram::initFromAsset(), flutter::ImmutableBuffer::initFromAsset(), flutter::ImmutableBuffer::initFromFile(), InternalFlutterGpu_CommandBuffer_Submit(), flutter::PlatformIsolateNativeApi::IsRunningOnPlatformThread(), flutter::FontCollection::LoadFontFromList(), flutter::DartRuntimeHooks::Logger_PrintString(), flutter::IsolateNameServerNatives::LookupPortByName(), flutter::gpu::ShaderLibrary::MakeFromAsset(), flutter::gpu::Texture::Overwrite(), flutter::Picture::RasterizeToImageSync(), flutter::PlatformConfigurationNativeApi::RegisterBackgroundIsolate(), flutter::IsolateNameServerNatives::RegisterPortWithName(), flutter::IsolateNameServerNatives::RemovePortNameMapping(), flutter::PlatformConfigurationNativeApi::Render(), flutter::PlatformConfigurationNativeApi::RequestViewFocusChange(), flutter::PlatformConfigurationNativeApi::RespondToPlatformMessage(), flutter::PlatformConfigurationNativeApi::ScheduleFrame(), flutter::DartRuntimeHooks::ScheduleMicrotask(), flutter::PlatformConfigurationNativeApi::SendChannelUpdate(), flutter::PlatformConfigurationNativeApi::SendPlatformMessage(), flutter::PlatformConfigurationNativeApi::SendPortPlatformMessage(), flutter::PlatformConfigurationNativeApi::SetApplicationLocale(), flutter::PlatformConfigurationNativeApi::SetIsolateDebugName(), flutter::PlatformConfigurationNativeApi::SetNeedsReportTimings(), flutter::PlatformConfigurationNativeApi::SetSemanticsTreeEnabled(), flutter::PlatformIsolateNativeApi::Spawn(), flutter::gpu::CommandBuffer::Submit(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), ThrowIfUIOperationsProhibited(), and flutter::PlatformConfigurationNativeApi::UpdateSemantics().

◆ debug_name()

const std::string & flutter::UIDartState::debug_name ( ) const
inline

Definition at line 124 of file ui_dart_state.h.

124{ return debug_name_; }

Referenced by SetDebugName().

◆ FlushMicrotasksNow()

void flutter::UIDartState::FlushMicrotasksNow ( )

Definition at line 161 of file ui_dart_state.cc.

161 {
162 microtask_queue_.RunMicrotasks();
163}

References tonic::DartMicrotaskQueue::RunMicrotasks().

Referenced by flutter::PlatformConfiguration::BeginFrame().

◆ GetAdvisoryScriptURI()

const std::string & flutter::UIDartState::GetAdvisoryScriptURI ( ) const
protected

Definition at line 75 of file ui_dart_state.cc.

75 {
76 return context_.advisory_script_uri;
77}

References flutter::UIDartState::Context::advisory_script_uri.

◆ GetConcurrentTaskRunner()

std::shared_ptr< fml::ConcurrentTaskRunner > flutter::UIDartState::GetConcurrentTaskRunner ( ) const

Definition at line 149 of file ui_dart_state.cc.

149 {
150 return context_.concurrent_task_runner;
151}
std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner

References flutter::UIDartState::Context::concurrent_task_runner.

◆ GetImageDecoder()

fml::TaskRunnerAffineWeakPtr< ImageDecoder > flutter::UIDartState::GetImageDecoder ( ) const

Definition at line 194 of file ui_dart_state.cc.

195 {
196 return context_.image_decoder;
197}
fml::TaskRunnerAffineWeakPtr< ImageDecoder > image_decoder
The image decoder.

References flutter::UIDartState::Context::image_decoder.

◆ GetImageGeneratorRegistry()

fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistry > flutter::UIDartState::GetImageGeneratorRegistry ( ) const

Definition at line 200 of file ui_dart_state.cc.

200 {
201 return context_.image_generator_registry;
202}
fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistry > image_generator_registry

References flutter::UIDartState::Context::image_generator_registry.

◆ GetIOManager()

fml::WeakPtr< IOManager > flutter::UIDartState::GetIOManager ( ) const

Definition at line 140 of file ui_dart_state.cc.

140 {
141 return context_.io_manager;
142}
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.

References flutter::UIDartState::Context::io_manager.

Referenced by flutter::EncodeImage(), and flutter::testing::TEST_F().

◆ GetIsolateNameServer()

std::shared_ptr< IsolateNameServer > flutter::UIDartState::GetIsolateNameServer ( ) const

◆ GetLastError()

tonic::DartErrorHandleType flutter::UIDartState::GetLastError ( )

Definition at line 208 of file ui_dart_state.cc.

208 {
210 if (error == tonic::kNoError) {
211 error = microtask_queue_.GetLastError();
212 }
213 return error;
214}
DartErrorHandleType isolate_last_error() const
DartErrorHandleType GetLastError()
DartMessageHandler & message_handler()
Definition dart_state.h:61
const uint8_t uint32_t uint32_t GError ** error
DartErrorHandleType
Definition dart_error.h:67
@ kNoError
Definition dart_error.h:68

References error, tonic::DartMicrotaskQueue::GetLastError(), tonic::DartMessageHandler::isolate_last_error(), tonic::kNoError, and tonic::DartState::message_handler().

◆ GetRootIsolateToken()

int64_t flutter::UIDartState::GetRootIsolateToken ( ) const

Returns a enumeration that uniquely represents this root isolate. Returns 0 if called from a non-root isolate.

Definition at line 242 of file ui_dart_state.cc.

242 {
243 return IsRootIsolate() ? reinterpret_cast<int64_t>(this) : 0;
244}
bool IsRootIsolate() const

References IsRootIsolate().

Referenced by flutter::PlatformConfigurationNativeApi::GetRootIsolateToken().

◆ GetRuntimeStageBackend()

impeller::RuntimeStageBackend flutter::UIDartState::GetRuntimeStageBackend ( ) const

The runtime stage to use for fragment shaders.

Definition at line 253 of file ui_dart_state.cc.

253 {
254 return context_.runtime_stage_backend.get();
255}
std::shared_future< impeller::RuntimeStageBackend > runtime_stage_backend
The runtime stage backend for fragment shaders.

References flutter::UIDartState::Context::runtime_stage_backend.

Referenced by flutter::FragmentProgram::initFromAsset().

◆ GetSkiaUnrefQueue()

fml::RefPtr< flutter::SkiaUnrefQueue > flutter::UIDartState::GetSkiaUnrefQueue ( ) const

Definition at line 144 of file ui_dart_state.cc.

144 {
145 return context_.unref_queue;
146}
fml::RefPtr< SkiaUnrefQueue > unref_queue

References flutter::UIDartState::Context::unref_queue.

◆ GetSnapshotDelegate()

fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > flutter::UIDartState::GetSnapshotDelegate ( ) const

Definition at line 190 of file ui_dart_state.cc.

190 {
191 return context_.snapshot_delegate;
192}
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate

References flutter::UIDartState::Context::snapshot_delegate.

Referenced by flutter::EncodeImage(), and flutter::FragmentProgram::initFromAsset().

◆ GetTaskRunners()

◆ HandlePlatformMessage()

Dart_Handle flutter::UIDartState::HandlePlatformMessage ( std::unique_ptr< PlatformMessage message)

Definition at line 223 of file ui_dart_state.cc.

224 {
225 if (platform_configuration_) {
226 platform_configuration_->client()->HandlePlatformMessage(
227 std::move(message));
228 } else {
229 std::shared_ptr<PlatformMessageHandler> handler =
230 platform_message_handler_.lock();
231 if (handler) {
232 handler->HandlePlatformMessage(std::move(message));
233 } else {
234 return tonic::ToDart(
235 "No platform channel handler registered for background isolate.");
236 }
237 }
238
239 return Dart_Null();
240}
const gchar FlBinaryMessengerMessageHandler handler
G_BEGIN_DECLS GBytes * message
Dart_Handle ToDart(const T &object)

References handler, message, and tonic::ToDart().

◆ HasPendingMicrotasks()

bool flutter::UIDartState::HasPendingMicrotasks ( )

Definition at line 165 of file ui_dart_state.cc.

165 {
166 return microtask_queue_.HasMicrotasks();
167}

References tonic::DartMicrotaskQueue::HasMicrotasks().

◆ IsDeterministicRenderingEnabled()

bool flutter::UIDartState::IsDeterministicRenderingEnabled ( ) const

Whether deterministic rendering practices are enabled for this application.

Definition at line 79 of file ui_dart_state.cc.

79 {
80 return context_.deterministic_rendering_enabled;
81}
bool deterministic_rendering_enabled
Whether deterministic rendering practices should be used.

References flutter::UIDartState::Context::deterministic_rendering_enabled.

◆ IsFlutterGPUEnabled()

bool flutter::UIDartState::IsFlutterGPUEnabled ( ) const

Whether Flutter GPU is enabled for this application.

Definition at line 87 of file ui_dart_state.cc.

87 {
88 return context_.enable_impeller && context_.enable_flutter_gpu;
89}
bool enable_flutter_gpu
Whether flutter_gpu is enabled or not.
bool enable_impeller
Whether Impeller is enabled or not.

References flutter::UIDartState::Context::enable_flutter_gpu, and flutter::UIDartState::Context::enable_impeller.

◆ IsImpellerEnabled()

bool flutter::UIDartState::IsImpellerEnabled ( ) const

Whether Impeller is enabled for this application.

Definition at line 83 of file ui_dart_state.cc.

83 {
84 return context_.enable_impeller;
85}

References flutter::UIDartState::Context::enable_impeller.

Referenced by flutter::EncodeImage().

◆ IsRootIsolate()

◆ logger_prefix()

const std::string & flutter::UIDartState::logger_prefix ( ) const
inline

Definition at line 126 of file ui_dart_state.h.

126{ return logger_prefix_; }

Referenced by flutter::DartRuntimeHooks::Logger_PrintString().

◆ LogMessage()

void flutter::UIDartState::LogMessage ( const std::string &  tag,
const std::string &  message 
) const

Definition at line 216 of file ui_dart_state.cc.

217 {
218 if (log_message_callback_) {
219 log_message_callback_(tag, message);
220 }
221}

References message.

Referenced by flutter::DartRuntimeHooks::Logger_PrintString().

◆ main_port()

Dart_Port flutter::UIDartState::main_port ( ) const
inline

Definition at line 117 of file ui_dart_state.h.

117{ return main_port_; }

◆ platform_configuration()

PlatformConfiguration * flutter::UIDartState::platform_configuration ( ) const
inline

◆ ScheduleMicrotask()

void flutter::UIDartState::ScheduleMicrotask ( Dart_Handle  handle)

Definition at line 153 of file ui_dart_state.cc.

153 {
154 if (tonic::CheckAndHandleError(closure) || !Dart_IsClosure(closure)) {
155 return;
156 }
157
158 microtask_queue_.ScheduleMicrotask(closure);
159}
void ScheduleMicrotask(Dart_Handle callback)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

References tonic::CheckAndHandleError(), and tonic::DartMicrotaskQueue::ScheduleMicrotask().

Referenced by flutter::DartRuntimeHooks::ScheduleMicrotask().

◆ SetDebugName()

void flutter::UIDartState::SetDebugName ( const std::string &  name)

Definition at line 108 of file ui_dart_state.cc.

108 {
109 debug_name_ = debug_name;
110 if (platform_configuration_) {
111 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
112 main_port_);
113 }
114}
const std::string & debug_name() const

References debug_name().

Referenced by flutter::PlatformConfigurationNativeApi::SetIsolateDebugName().

◆ SetPlatformConfiguration()

void flutter::UIDartState::SetPlatformConfiguration ( std::unique_ptr< PlatformConfiguration platform_configuration)
protected

Definition at line 120 of file ui_dart_state.cc.

121 {
123 platform_configuration_ = std::move(platform_configuration);
124 if (platform_configuration_) {
125 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
126 main_port_);
127 }
128}
PlatformConfiguration * platform_configuration() const
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK, IsRootIsolate(), and platform_configuration().

◆ SetPlatformMessageHandler()

void flutter::UIDartState::SetPlatformMessageHandler ( std::weak_ptr< PlatformMessageHandler handler)

Definition at line 130 of file ui_dart_state.cc.

131 {
133 platform_message_handler_ = std::move(handler);
134}

References FML_DCHECK, handler, and IsRootIsolate().

Referenced by flutter::PlatformConfigurationNativeApi::RegisterBackgroundIsolate().

◆ ThrowIfUIOperationsProhibited()

void flutter::UIDartState::ThrowIfUIOperationsProhibited ( )
static

Definition at line 100 of file ui_dart_state.cc.

100 {
102 Dart_EnterScope();
103 Dart_ThrowException(
104 tonic::ToDart("UI actions are only available on root isolate."));
105 }
106}
static UIDartState * Current()

References Current(), IsRootIsolate(), and tonic::ToDart().

Referenced by flutter::PlatformConfigurationNativeApi::ComputePlatformResolvedLocale(), flutter::SceneBuilder::Create(), flutter::ColorFilter::Create(), flutter::CanvasGradient::Create(), flutter::ImageFilter::Create(), flutter::CanvasPath::Create(), flutter::PictureRecorder::Create(), flutter::SemanticsUpdateBuilder::Create(), flutter::CanvasPathMeasure::Create(), flutter::ParagraphBuilder::Create(), flutter::RSuperellipse::Create(), flutter::PlatformConfigurationNativeApi::DefaultRouteName(), flutter::PlatformConfigurationNativeApi::EndWarmUpFrame(), flutter::PlatformConfigurationNativeApi::GetPersistentIsolateData(), flutter::PlatformConfigurationNativeApi::GetScaledFontSize(), flutter::ImmutableBuffer::initFromAsset(), flutter::ImmutableBuffer::initFromFile(), flutter::NativeStringAttribute::initLocaleStringAttribute(), flutter::NativeSemanticsFlags::initSemanticsFlags(), flutter::NativeStringAttribute::initSpellOutStringAttribute(), flutter::FontCollection::LoadFontFromList(), flutter::PlatformConfigurationNativeApi::Render(), flutter::PlatformConfigurationNativeApi::RequestDartPerformanceMode(), flutter::PlatformConfigurationNativeApi::ScheduleFrame(), flutter::PlatformConfigurationNativeApi::SetApplicationLocale(), flutter::PlatformConfigurationNativeApi::SetIsolateDebugName(), flutter::PlatformConfigurationNativeApi::SetNeedsReportTimings(), flutter::PlatformConfigurationNativeApi::SetSemanticsTreeEnabled(), flutter::PlatformConfigurationNativeApi::UpdateSemantics(), and flutter::PlatformConfiguration::UpdateSemanticsEnabled().

◆ unhandled_exception_callback()

UnhandledExceptionCallback flutter::UIDartState::unhandled_exception_callback ( ) const
inline

Definition at line 169 of file ui_dart_state.h.

169 {
170 return unhandled_exception_callback_;
171 }

The documentation for this class was generated from the following files: