A class for holding and distributing platform-level information to and from the Dart code in Flutter's framework. More...
#include <platform_configuration.h>
Public Member Functions | |
| PlatformConfiguration (PlatformConfigurationClient *client) | |
| Creates a new PlatformConfiguration, typically created by the RuntimeController. | |
| PlatformConfiguration (const PlatformConfiguration &)=delete | |
| PlatformConfiguration & | operator= (const PlatformConfiguration &)=delete |
| ~PlatformConfiguration () | |
| PlatformConfigurationClient * | client () const |
| Access to the platform configuration client (which typically is implemented by the RuntimeController). | |
| void | DidCreateIsolate () |
| Called by the RuntimeController once it has created the root isolate, so that the PlatformController can get a handle to the 'dart:ui' library. | |
| bool | AddView (int64_t view_id, const ViewportMetrics &view_metrics) |
| Notify the framework that a new view is available. | |
| bool | RemoveView (int64_t view_id) |
| Notify the framework that a view is no longer available. | |
| bool | SendFocusEvent (const ViewFocusEvent &event) |
| Notify the isolate that the focus state of a native view has changed. | |
| bool | SetEngineId (int64_t engine_id) |
| Sets the opaque identifier of the engine. | |
| bool | UpdateViewMetrics (int64_t view_id, const ViewportMetrics &metrics) |
| Update the view metrics for the specified view. | |
| void | UpdateDisplays (const std::vector< DisplayData > &displays) |
| Update the specified display data in the framework. | |
| void | UpdateLocales (const std::vector< std::string > &locales) |
| Update the specified locale data in the framework. | |
| void | UpdateUserSettingsData (const std::string &data) |
| Update the user settings data in the framework. | |
| void | UpdateInitialLifecycleState (const std::string &data) |
| Updates the lifecycle state data in the framework. | |
| void | UpdateSemanticsEnabled (bool enabled) |
| Notifies the PlatformConfiguration that the embedder has expressed an opinion about whether the accessibility tree should be generated or not. This call originates in the platform view and is forwarded to the PlatformConfiguration here by the engine. | |
| void | UpdateAccessibilityFeatures (int32_t flags) |
| Forward the preference of accessibility features that must be enabled in the semantics tree to the framwork. | |
| void | DispatchPlatformMessage (std::unique_ptr< PlatformMessage > message) |
| Notifies the PlatformConfiguration that the client has sent it a message. This call originates in the platform view and has been forwarded through the engine to here. | |
| void | DispatchPointerDataPacket (const PointerDataPacket &packet) |
| Notifies the PlatformConfiguration that the client has sent it pointer events. This call originates in the platform view and has been forwarded through the engine to here. | |
| void | DispatchSemanticsAction (int64_t view_id, int32_t node_id, SemanticsAction action, fml::MallocMapping args) |
| Notifies the framework that the embedder encountered an accessibility related action on the specified node. This call originates on the platform view and has been forwarded to the platform configuration here by the engine. | |
| void | BeginFrame (fml::TimePoint frame_time, uint64_t frame_number) |
Notifies the framework that it is time to begin working on a new frame previously scheduled via a call to PlatformConfigurationClient::ScheduleFrame. This call originates in the animator. | |
| void | ReportTimings (std::vector< int64_t > timings) |
| Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to the framework by invoking this method at predefined intervals. | |
| const ViewportMetrics * | GetMetrics (int view_id) |
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration. | |
| void | CompletePlatformMessageResponse (int response_id, std::vector< uint8_t > data) |
| Responds to a previous platform message to the engine from the framework. | |
| void | CompletePlatformMessageEmptyResponse (int response_id) |
| Responds to a previous platform message to the engine from the framework with an empty response. | |
| Dart_Handle | on_error () |
A class for holding and distributing platform-level information to and from the Dart code in Flutter's framework.
It handles communication between the engine and the framework.
It communicates with the RuntimeController through the use of a PlatformConfigurationClient interface, which the RuntimeController defines.
Definition at line 302 of file platform_configuration.h.
|
explicit |
Creates a new PlatformConfiguration, typically created by the RuntimeController.
| [in] | client | The PlatformConfigurationClient to be injected into the PlatformConfiguration. This client is used to forward requests to the RuntimeController. |
Definition at line 34 of file platform_configuration.cc.
|
delete |
| flutter::PlatformConfiguration::~PlatformConfiguration | ( | ) |
Definition at line 38 of file platform_configuration.cc.
| bool flutter::PlatformConfiguration::AddView | ( | int64_t | view_id, |
| const ViewportMetrics & | view_metrics | ||
| ) |
Notify the framework that a new view is available.
A view must be added before other methods can refer to it,
including the implicit view. Adding a view that already exists
triggers an assertion.
| [in] | view_id | The ID of the new view. |
| [in] | viewport_metrics | The initial viewport metrics for the view. |
Definition at line 91 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), FML_LOG, tonic::DartPersistentValue::Get(), and view_id.
| void flutter::PlatformConfiguration::BeginFrame | ( | fml::TimePoint | frame_time, |
| uint64_t | frame_number | ||
| ) |
Notifies the framework that it is time to begin working on a new frame previously scheduled via a call to PlatformConfigurationClient::ScheduleFrame. This call originates in the animator.
The frame time given as the argument indicates the point at which the current frame interval began. It is very slightly (because of scheduling overhead) in the past. If a new layer tree is not produced and given to the raster task runner within one frame interval from this point, the Flutter application will jank.
This method calls the ::_beginFrame method in hooks.dart.
| [in] | frame_time | The point at which the current frame interval began. May be used by animation interpolators, physics simulations, etc.. |
| [in] | frame_number | The frame number recorded by the animator. Used by the framework to associate frame specific debug information with frame timings and timeline events. |
Definition at line 415 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), flutter::UIDartState::Current(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartInvokeVoid(), flutter::UIDartState::FlushMicrotasksNow(), FML_LOG, tonic::DartPersistentValue::Get(), fml::TimePoint::ToEpochDelta(), and fml::TimeDelta::ToMicroseconds().
|
inline |
Access to the platform configuration client (which typically is implemented by the RuntimeController).
Definition at line 327 of file platform_configuration.h.
Referenced by flutter::PlatformConfigurationNativeApi::ComputePlatformResolvedLocale(), flutter::DartIsolate::CreatePlatformIsolate(), flutter::PlatformConfigurationNativeApi::DefaultRouteName(), flutter::PlatformConfigurationNativeApi::EndWarmUpFrame(), flutter::PlatformConfigurationNativeApi::GetPersistentIsolateData(), flutter::PlatformConfigurationNativeApi::GetScaledFontSize(), flutter::FragmentProgram::initFromAsset(), flutter::ImmutableBuffer::initFromAsset(), flutter::FontCollection::LoadFontFromList(), flutter::PlatformConfigurationNativeApi::Render(), flutter::PlatformConfigurationNativeApi::RequestViewFocusChange(), flutter::PlatformConfigurationNativeApi::ScheduleFrame(), flutter::PlatformConfigurationNativeApi::SendChannelUpdate(), flutter::PlatformConfigurationNativeApi::SetApplicationLocale(), flutter::PlatformConfigurationNativeApi::SetNeedsReportTimings(), flutter::PlatformConfigurationNativeApi::SetSemanticsTreeEnabled(), and flutter::PlatformConfigurationNativeApi::UpdateSemantics().
| void flutter::PlatformConfiguration::CompletePlatformMessageEmptyResponse | ( | int | response_id | ) |
Responds to a previous platform message to the engine from the framework with an empty response.
| [in] | response_id | The unique id that identifies the original platform message to respond to. |
Definition at line 491 of file platform_configuration.cc.
Referenced by flutter::PlatformConfigurationNativeApi::RespondToPlatformMessage().
| void flutter::PlatformConfiguration::CompletePlatformMessageResponse | ( | int | response_id, |
| std::vector< uint8_t > | data | ||
| ) |
Responds to a previous platform message to the engine from the framework.
| [in] | response_id | The unique id that identifies the original platform message to respond to. |
| [in] | data | The data to send back in the response. |
Definition at line 505 of file platform_configuration.cc.
References flutter::data.
Referenced by flutter::PlatformConfigurationNativeApi::RespondToPlatformMessage().
| void flutter::PlatformConfiguration::DidCreateIsolate | ( | ) |
Called by the RuntimeController once it has created the root isolate, so that the PlatformController can get a handle to the 'dart:ui' library.
It uses the handle to call the hooks in hooks.dart.
Definition at line 40 of file platform_configuration.cc.
References tonic::DartState::Current(), tonic::DartPersistentValue::Set(), and tonic::ToDart().
| void flutter::PlatformConfiguration::DispatchPlatformMessage | ( | std::unique_ptr< PlatformMessage > | message | ) |
Notifies the PlatformConfiguration that the client has sent it a message. This call originates in the platform view and has been forwarded through the engine to here.
| [in] | message | The message sent from the embedder to the Dart application. |
Definition at line 339 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), FML_DLOG, tonic::DartPersistentValue::Get(), and message.
| void flutter::PlatformConfiguration::DispatchPointerDataPacket | ( | const PointerDataPacket & | packet | ) |
Notifies the PlatformConfiguration that the client has sent it pointer events. This call originates in the platform view and has been forwarded through the engine to here.
| [in] | packet | The pointer event(s) serialized into a packet. |
Definition at line 371 of file platform_configuration.cc.
References flutter::buffer, tonic::CheckAndHandleError(), tonic::DartByteData::Create(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), flutter::PointerDataPacket::data(), and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::DispatchSemanticsAction | ( | int64_t | view_id, |
| int32_t | node_id, | ||
| SemanticsAction | action, | ||
| fml::MallocMapping | args | ||
| ) |
Notifies the framework that the embedder encountered an accessibility related action on the specified node. This call originates on the platform view and has been forwarded to the platform configuration here by the engine.
| [in] | view_id | The identifier of the view. |
| [in] | node_id | The identifier of the accessibility node. |
| [in] | action | The accessibility related action performed on the node of the specified ID. |
| [in] | args | Optional data that applies to the specified action. |
Definition at line 391 of file platform_configuration.cc.
References args, tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| const ViewportMetrics * flutter::PlatformConfiguration::GetMetrics | ( | int | view_id | ) |
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration.
| [in] | view_id | The id of the view's viewport metrics to return. |
Definition at line 482 of file platform_configuration.cc.
References view_id.
Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().
|
inline |
Definition at line 567 of file platform_configuration.h.
References tonic::DartPersistentValue::Get().
|
delete |
| bool flutter::PlatformConfiguration::RemoveView | ( | int64_t | view_id | ) |
Notify the framework that a view is no longer available.
Removing a view that does not exist triggers an assertion.
The implicit view (kFlutterImplicitViewId) should never be
removed. Doing so triggers an assertion.
| [in] | view_id | The ID of the view. |
Definition at line 137 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), FML_LOG, tonic::DartPersistentValue::Get(), flutter::kFlutterImplicitViewId, and view_id.
| void flutter::PlatformConfiguration::ReportTimings | ( | std::vector< int64_t > | timings | ) |
Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to the framework by invoking this method at predefined intervals.
FrameTiming| [in] | timings | Collection of FrameTiming::kStatisticsCount * 'n' values for n frames whose timings have not been reported yet. Many of the values are timestamps, but a collection of integers is reported here for easier conversions to Dart objects. The timestamps are measured against the system monotonic clock measured in microseconds. |
Definition at line 455 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), flutter::data, FML_CHECK, FML_DCHECK, tonic::DartPersistentValue::Get(), and type.
| bool flutter::PlatformConfiguration::SendFocusEvent | ( | const ViewFocusEvent & | event | ) |
Notify the isolate that the focus state of a native view has changed.
| [in] | event | The focus event describing the change. |
Definition at line 161 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| bool flutter::PlatformConfiguration::SetEngineId | ( | int64_t | engine_id | ) |
Sets the opaque identifier of the engine.
The identifier can be passed from Dart to native code to
retrieve the engine instance.
Definition at line 177 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::UpdateAccessibilityFeatures | ( | int32_t | flags | ) |
Forward the preference of accessibility features that must be enabled in the semantics tree to the framwork.
| [in] | flags | The accessibility features that must be generated in the semantics tree. |
Definition at line 327 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::UpdateDisplays | ( | const std::vector< DisplayData > & | displays | ) |
Update the specified display data in the framework.
| [in] | displays | The display data to send to Dart. |
Definition at line 239 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), displays, and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::UpdateInitialLifecycleState | ( | const std::string & | data | ) |
Updates the lifecycle state data in the framework.
| [in] | data | The lifecycle state data. |
Definition at line 300 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::UpdateLocales | ( | const std::vector< std::string > & | locales | ) |
Update the specified locale data in the framework.
| [in] | locale_data | The locale data. This should consist of groups of 4 strings, each group representing a single locale. |
Definition at line 270 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| void flutter::PlatformConfiguration::UpdateSemanticsEnabled | ( | bool | enabled | ) |
Notifies the PlatformConfiguration that the embedder has expressed an opinion about whether the accessibility tree should be generated or not. This call originates in the platform view and is forwarded to the PlatformConfiguration here by the engine.
| [in] | enabled | Whether the accessibility tree is enabled or disabled. |
Definition at line 314 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), and flutter::UIDartState::ThrowIfUIOperationsProhibited().
| void flutter::PlatformConfiguration::UpdateUserSettingsData | ( | const std::string & | data | ) |
Update the user settings data in the framework.
| [in] | data | The user settings data. |
Definition at line 286 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), and tonic::DartPersistentValue::Get().
| bool flutter::PlatformConfiguration::UpdateViewMetrics | ( | int64_t | view_id, |
| const ViewportMetrics & | metrics | ||
| ) |
Update the view metrics for the specified view.
If the view is not found, silently return false.
| [in] | view_id | The ID of the view. |
| [in] | metrics | The new metrics of the view. |
Definition at line 191 of file platform_configuration.cc.
References tonic::CheckAndHandleError(), tonic::DartPersistentValue::dart_state(), tonic::DartInvoke(), tonic::DartPersistentValue::Get(), and view_id.
Referenced by flutter::testing::TEST_F().