Flutter Engine
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
 
const TaskRunnersGetTaskRunners () const
 
void ScheduleMicrotask (Dart_Handle handle)
 
void FlushMicrotasksNow ()
 
fml::WeakPtr< IOManagerGetIOManager () const
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const
 
std::shared_ptr< VolatilePathTrackerGetVolatilePathTracker () const
 
fml::WeakPtr< SnapshotDelegateGetSnapshotDelegate () const
 
fml::WeakPtr< GrDirectContext > GetResourceContext () const
 
fml::WeakPtr< ImageDecoderGetImageDecoder () const
 
fml::WeakPtr< ImageGeneratorRegistryGetImageGeneratorRegistry () const
 
std::shared_ptr< IsolateNameServerGetIsolateNameServer () const
 
tonic::DartErrorHandleType GetLastError ()
 
void ReportUnhandledException (const std::string &error, const std::string &stack_trace)
 
void LogMessage (const std::string &tag, const std::string &message) const
 
bool enable_skparagraph () const
 
bool enable_display_list () const
 
- 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 ()
 
template<class T >
static flutter::SkiaGPUObject< T > CreateGPUObject (sk_sp< T > object)
 
- 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_, bool enable_skparagraph, bool enable_display_list, const UIDartState::Context &context)
 
 ~UIDartState () override
 
void SetPlatformConfiguration (std::unique_ptr< PlatformConfiguration > platform_configuration)
 
const std::string & GetAdvisoryScriptURI () const
 
const std::string & GetAdvisoryScriptEntrypoint () const
 
- Protected Member Functions inherited from tonic::DartState
Dart_Isolate isolate () const
 
 TONIC_DISALLOW_COPY_AND_ASSIGN (DartState)
 

Detailed Description

Definition at line 34 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_,
bool  enable_skparagraph,
bool  enable_display_list,
const UIDartState::Context context 
)
protected

Definition at line 50 of file ui_dart_state.cc.

Referenced by CreateGPUObject(), and flutter::DartIsolate::CreateRunningRootIsolate().

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

◆ ~UIDartState()

flutter::UIDartState::~UIDartState ( )
overrideprotected

Definition at line 74 of file ui_dart_state.cc.

Referenced by CreateGPUObject().

74  {
75  AddOrRemoveTaskObserver(false /* remove */);
76 }

Member Function Documentation

◆ CreateGPUObject()

template<class T >
static flutter::SkiaGPUObject<T> flutter::UIDartState::CreateGPUObject ( sk_sp< T >  object)
inlinestatic

◆ Current()

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

◆ debug_name()

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

Definition at line 101 of file ui_dart_state.h.

Referenced by GetAdvisoryScriptEntrypoint(), and SetDebugName().

101 { return debug_name_; }

◆ enable_display_list()

bool flutter::UIDartState::enable_display_list ( ) const

Definition at line 243 of file ui_dart_state.cc.

Referenced by flutter::PictureRecorder::BeginRecording(), and platform_configuration().

243  {
244  return enable_display_list_;
245 }

◆ enable_skparagraph()

bool flutter::UIDartState::enable_skparagraph ( ) const

Definition at line 239 of file ui_dart_state.cc.

Referenced by flutter::decodeStrut(), and platform_configuration().

239  {
240  return enable_skparagraph_;
241 }

◆ FlushMicrotasksNow()

void flutter::UIDartState::FlushMicrotasksNow ( )

◆ GetAdvisoryScriptEntrypoint()

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

◆ GetAdvisoryScriptURI()

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

Definition at line 78 of file ui_dart_state.cc.

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

Referenced by CreateGPUObject(), and flutter::DartIsolate::LoadLoadingUnitError().

78  {
79  return context_.advisory_script_uri;
80 }

◆ GetImageDecoder()

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

Definition at line 179 of file ui_dart_state.cc.

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

Referenced by platform_configuration(), and flutter::DartIsolate::SpawnIsolate().

179  {
180  return context_.image_decoder;
181 }
fml::WeakPtr< ImageDecoder > image_decoder
The image decoder.
Definition: ui_dart_state.h:74

◆ GetImageGeneratorRegistry()

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

Definition at line 183 of file ui_dart_state.cc.

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

Referenced by platform_configuration(), and flutter::DartIsolate::SpawnIsolate().

184  {
185  return context_.image_generator_registry;
186 }
fml::WeakPtr< ImageGeneratorRegistry > image_generator_registry
Definition: ui_dart_state.h:79

◆ GetIOManager()

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

Definition at line 127 of file ui_dart_state.cc.

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

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

127  {
128  return context_.io_manager;
129 }
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.
Definition: ui_dart_state.h:67

◆ GetIsolateNameServer()

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

◆ GetLastError()

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

Definition at line 192 of file ui_dart_state.cc.

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

Referenced by platform_configuration().

192  {
194  if (error == tonic::kNoError) {
195  error = microtask_queue_.GetLastError();
196  }
197  return error;
198 }
const uint8_t uint32_t uint32_t GError ** error
DartErrorHandleType isolate_last_error() const
DartErrorHandleType
Definition: dart_error.h:18
DartMessageHandler & message_handler()
Definition: dart_state.h:60
DartErrorHandleType GetLastError()

◆ GetResourceContext()

fml::WeakPtr< GrDirectContext > flutter::UIDartState::GetResourceContext ( ) const

Definition at line 172 of file ui_dart_state.cc.

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

Referenced by platform_configuration().

172  {
173  if (!context_.io_manager) {
174  return {};
175  }
176  return context_.io_manager->GetResourceContext();
177 }
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.
Definition: ui_dart_state.h:67

◆ GetSkiaUnrefQueue()

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

Definition at line 131 of file ui_dart_state.cc.

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

Referenced by platform_configuration(), and flutter::DartIsolate::SpawnIsolate().

131  {
132  return context_.unref_queue;
133 }
fml::RefPtr< SkiaUnrefQueue > unref_queue
Definition: ui_dart_state.h:71

◆ GetSnapshotDelegate()

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

Definition at line 168 of file ui_dart_state.cc.

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

Referenced by flutter::EncodeImage(), and platform_configuration().

168  {
169  return context_.snapshot_delegate;
170 }
fml::WeakPtr< SnapshotDelegate > snapshot_delegate
Definition: ui_dart_state.h:64

◆ GetTaskRunners()

◆ GetVolatilePathTracker()

std::shared_ptr< VolatilePathTracker > flutter::UIDartState::GetVolatilePathTracker ( ) const

Definition at line 135 of file ui_dart_state.cc.

References flutter::UIDartState::Context::volatile_path_tracker.

Referenced by platform_configuration(), flutter::DartIsolate::SpawnIsolate(), and flutter::testing::TEST_F().

136  {
137  return context_.volatile_path_tracker;
138 }
std::shared_ptr< VolatilePathTracker > volatile_path_tracker
Cache for tracking path volatility.
Definition: ui_dart_state.h:91

◆ IsRootIsolate()

bool flutter::UIDartState::IsRootIsolate ( ) const
inline

◆ logger_prefix()

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

Definition at line 103 of file ui_dart_state.h.

Referenced by CreateGPUObject(), and flutter::Logger_PrintString().

103 { return logger_prefix_; }

◆ LogMessage()

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

Definition at line 213 of file ui_dart_state.cc.

Referenced by flutter::Logger_PrintString(), and platform_configuration().

214  {
215  if (log_message_callback_) {
216  log_message_callback_(tag, message);
217  } else {
218  // Fall back to previous behavior if unspecified.
219 #if defined(OS_ANDROID)
220  __android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%.*s",
221  (int)message.size(), message.c_str());
222 #elif defined(OS_IOS)
223  std::stringstream stream;
224  if (tag.size() > 0) {
225  stream << tag << ": ";
226  }
227  stream << message;
228  std::string log = stream.str();
229  syslog(1 /* LOG_ALERT */, "%.*s", (int)log.size(), log.c_str());
230 #else
231  if (tag.size() > 0) {
232  std::cout << tag << ": ";
233  }
234  std::cout << message << std::endl;
235 #endif
236  }
237 }

◆ main_port()

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

Definition at line 94 of file ui_dart_state.h.

94 { return main_port_; }

◆ platform_configuration()

◆ ReportUnhandledException()

void flutter::UIDartState::ReportUnhandledException ( const std::string &  error,
const std::string &  stack_trace 
)

Definition at line 200 of file ui_dart_state.cc.

References FML_LOG.

Referenced by platform_configuration().

201  {
202  if (unhandled_exception_callback_ &&
203  unhandled_exception_callback_(error, stack_trace)) {
204  return;
205  }
206 
207  // Either the exception handler was not set or it could not handle the error,
208  // just log the exception.
209  FML_LOG(ERROR) << "Unhandled Exception: " << error << std::endl
210  << stack_trace;
211 }
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
Definition: logging.h:65

◆ ScheduleMicrotask()

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

Definition at line 140 of file ui_dart_state.cc.

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

Referenced by platform_configuration(), and flutter::ScheduleMicrotask().

140  {
141  if (tonic::LogIfError(closure) || !Dart_IsClosure(closure)) {
142  return;
143  }
144 
145  microtask_queue_.ScheduleMicrotask(closure);
146 }
void ScheduleMicrotask(Dart_Handle callback)
std::function< void()> closure
Definition: closure.h:14
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ SetDebugName()

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

Definition at line 102 of file ui_dart_state.cc.

References debug_name().

Referenced by GetAdvisoryScriptEntrypoint(), and IsRootIsolate().

102  {
103  debug_name_ = debug_name;
104  if (platform_configuration_) {
105  platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
106  main_port_);
107  }
108 }
const std::string & debug_name() const

◆ SetPlatformConfiguration()

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

Definition at line 114 of file ui_dart_state.cc.

Referenced by CreateGPUObject().

115  {
116  platform_configuration_ = std::move(platform_configuration);
117  if (platform_configuration_) {
118  platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
119  main_port_);
120  }
121 }
PlatformConfiguration * platform_configuration() const

◆ ThrowIfUIOperationsProhibited()


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