Flutter Engine
The Flutter Engine
|
Used to forward events from the platform view to interested subsystems. This forwarding is done by the shell which sets itself up as the delegate of the platform view. More...
#include <platform_view.h>
Public Types | |
using | AddViewCallback = PlatformView::AddViewCallback |
using | RemoveViewCallback = PlatformView::RemoveViewCallback |
using | KeyDataResponse = std::function< void(bool)> |
Public Member Functions | |
virtual void | OnPlatformViewCreated (std::unique_ptr< Surface > surface)=0 |
Notifies the delegate that the platform view was created with the given render surface. This surface is platform (iOS, Android) and client-rendering API (OpenGL, Software, Metal, Vulkan) specific. This is usually a sign to the rasterizer to set up and begin rendering to that surface. More... | |
virtual void | OnPlatformViewDestroyed ()=0 |
Notifies the delegate that the platform view was destroyed. This is usually a sign to the rasterizer to suspend rendering a previously configured surface and collect any intermediate resources. More... | |
virtual void | OnPlatformViewScheduleFrame ()=0 |
Notifies the delegate that the platform needs to schedule a frame to regenerate the layer tree and redraw the surface. More... | |
virtual void | OnPlatformViewAddView (int64_t view_id, const ViewportMetrics &viewport_metrics, AddViewCallback callback)=0 |
Allocate resources for a new non-implicit view and inform Dart about the view, and on success, schedules a new frame. More... | |
virtual void | OnPlatformViewRemoveView (int64_t view_id, RemoveViewCallback callback)=0 |
Deallocate resources for a removed view and inform Dart about the removal. More... | |
virtual void | OnPlatformViewSetNextFrameCallback (const fml::closure &closure)=0 |
Notifies the delegate that the specified callback needs to be invoked after the rasterizer is done rendering the next frame. This callback will be called on the render thread and it is caller responsibility to perform any re-threading as necessary. Due to the asynchronous nature of rendering in Flutter, embedders usually add a placeholder over the contents in which Flutter is going to render when Flutter is first initialized. This callback may be used as a signal to remove that placeholder. More... | |
virtual void | OnPlatformViewSetViewportMetrics (int64_t view_id, const ViewportMetrics &metrics)=0 |
Notifies the delegate the viewport metrics of a view have been updated. The rasterizer will need to be reconfigured to render the frame in the updated viewport metrics. More... | |
virtual void | OnPlatformViewDispatchPlatformMessage (std::unique_ptr< PlatformMessage > message)=0 |
Notifies the delegate that the platform has dispatched a platform message from the embedder to the Flutter application. This message must be forwarded to the running isolate hosted by the engine on the UI thread. More... | |
virtual void | OnPlatformViewDispatchPointerDataPacket (std::unique_ptr< PointerDataPacket > packet)=0 |
Notifies the delegate that the platform view has encountered a pointer event. This pointer event needs to be forwarded to the running root isolate hosted by the engine on the UI thread. More... | |
virtual void | OnPlatformViewDispatchSemanticsAction (int32_t node_id, SemanticsAction action, fml::MallocMapping args)=0 |
Notifies the delegate that the platform view has encountered an accessibility related action on the specified node. This event must be forwarded to the running root isolate hosted by the engine on the UI thread. More... | |
virtual void | OnPlatformViewSetSemanticsEnabled (bool enabled)=0 |
Notifies the delegate that the embedder has expressed an opinion about whether the accessibility tree needs to be enabled or disabled. This information needs to be forwarded to the root isolate running on the UI thread. More... | |
virtual void | OnPlatformViewSetAccessibilityFeatures (int32_t flags)=0 |
Notifies the delegate that the embedder has expressed an opinion about the features to enable in the accessibility tree. More... | |
virtual void | OnPlatformViewRegisterTexture (std::shared_ptr< Texture > texture)=0 |
Notifies the delegate that the embedder has specified a texture that it want the rasterizer to composite within the Flutter layer tree. All textures must have a unique identifier. When the rasterizer encounters an external texture within its hierarchy, it gives the embedder a chance to update that texture on the raster thread before it composites the same on-screen. More... | |
virtual void | OnPlatformViewUnregisterTexture (int64_t texture_id)=0 |
Notifies the delegate that the embedder will no longer attempt to composite the specified texture within the layer tree. This allows the rasterizer to collect associated resources. More... | |
virtual void | OnPlatformViewMarkTextureFrameAvailable (int64_t texture_id)=0 |
Notifies the delegate that the embedder has updated the contents of the texture with the specified identifier. Typically, Flutter will only render a frame if there is an updated layer tree. However, in cases where the layer tree is static but one of the externally composited textures has been updated by the embedder, the embedder needs to notify the rasterizer to render a new frame. In such cases, the existing layer tree may be reused with the frame composited with all updated external textures. More... | |
virtual void | LoadDartDeferredLibrary (intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions)=0 |
Loads the dart shared library into the dart VM. When the dart library is loaded successfully, the dart future returned by the originating loadLibrary() call completes. More... | |
virtual void | LoadDartDeferredLibraryError (intptr_t loading_unit_id, const std::string error_message, bool transient)=0 |
Indicates to the dart VM that the request to load a deferred library with the specified loading unit id has failed. More... | |
virtual void | UpdateAssetResolverByType (std::unique_ptr< AssetResolver > updated_asset_resolver, AssetResolver::AssetResolverType type)=0 |
Replaces the asset resolver handled by the engine's AssetManager of the specified type with updated_asset_resolver . The matching AssetResolver is removed and replaced with updated_asset_resolvers . More... | |
virtual const Settings & | OnPlatformViewGetSettings () const =0 |
Called by the platform view on the platform thread to get the settings object associated with the platform view instance. More... | |
Used to forward events from the platform view to interested subsystems. This forwarding is done by the shell which sets itself up as the delegate of the platform view.
Definition at line 60 of file platform_view.h.
Definition at line 62 of file platform_view.h.
using flutter::PlatformView::Delegate::KeyDataResponse = std::function<void(bool)> |
Definition at line 64 of file platform_view.h.
Definition at line 63 of file platform_view.h.
|
pure virtual |
Loads the dart shared library into the dart VM. When the dart library is loaded successfully, the dart future returned by the originating loadLibrary() call completes.
The Dart compiler may generate separate shared libraries files called 'loading units' when libraries are imported as deferred. Each of these shared libraries are identified by a unique loading unit id. Callers should open and resolve a SymbolMapping from the shared library. The Mappings should be moved into this method, as ownership will be assumed by the dart root isolate after successful loading and released after shutdown of the root isolate. The loading unit may not be used after isolate shutdown. If loading fails, the mappings will be released.
This method is paired with a RequestDartDeferredLibrary invocation that provides the embedder with the loading unit id of the deferred library to load.
[in] | loading_unit_id | The unique id of the deferred library's loading unit. |
[in] | snapshot_data | Dart snapshot data of the loading unit's shared library. |
[in] | snapshot_data | Dart snapshot instructions of the loading unit's shared library. |
|
pure virtual |
Indicates to the dart VM that the request to load a deferred library with the specified loading unit id has failed.
The dart future returned by the initiating loadLibrary() call will complete with an error.
[in] | loading_unit_id | The unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary. |
[in] | error_message | The error message that will appear in the dart Future. |
[in] | transient | A transient error is a failure due to temporary conditions such as no network. Transient errors allow the dart VM to re-request the same deferred library and loading_unit_id again. Non-transient errors are permanent and attempts to re-request the library will instantly complete with an error. |
|
pure virtual |
Allocate resources for a new non-implicit view and inform Dart about the view, and on success, schedules a new frame.
After the operation, |callback| should be invoked with whether the operation is successful.
Adding |kFlutterImplicitViewId| or an existing view ID should result in failure.
[in] | view_id | The view ID of the new view. |
[in] | viewport_metrics | The initial viewport metrics for the view. |
[in] | callback | The callback that's invoked once the shell has attempted to add the view. |
|
pure virtual |
Notifies the delegate that the platform view was created with the given render surface. This surface is platform (iOS, Android) and client-rendering API (OpenGL, Software, Metal, Vulkan) specific. This is usually a sign to the rasterizer to set up and begin rendering to that surface.
[in] | surface | The surface |
|
pure virtual |
Notifies the delegate that the platform view was destroyed. This is usually a sign to the rasterizer to suspend rendering a previously configured surface and collect any intermediate resources.
|
pure virtual |
Notifies the delegate that the platform has dispatched a platform message from the embedder to the Flutter application. This message must be forwarded to the running isolate hosted by the engine on the UI thread.
[in] | message | The platform message to dispatch to the running root isolate. |
|
pure virtual |
Notifies the delegate that the platform view has encountered a pointer event. This pointer event needs to be forwarded to the running root isolate hosted by the engine on the UI thread.
[in] | packet | The pointer data packet containing multiple pointer events. |
|
pure virtual |
Notifies the delegate that the platform view has encountered an accessibility related action on the specified node. This event must be forwarded to the running root isolate hosted by the engine on the UI thread.
[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 | An optional list of argument that apply to the specified action. |
|
pure virtual |
Called by the platform view on the platform thread to get the settings object associated with the platform view instance.
|
pure virtual |
Notifies the delegate that the embedder has updated the contents of the texture with the specified identifier. Typically, Flutter will only render a frame if there is an updated layer tree. However, in cases where the layer tree is static but one of the externally composited textures has been updated by the embedder, the embedder needs to notify the rasterizer to render a new frame. In such cases, the existing layer tree may be reused with the frame composited with all updated external textures.
[in] | texture_id | The identifier of the texture that has been updated. |
|
pure virtual |
Notifies the delegate that the embedder has specified a texture that it want the rasterizer to composite within the Flutter layer tree. All textures must have a unique identifier. When the rasterizer encounters an external texture within its hierarchy, it gives the embedder a chance to update that texture on the raster thread before it composites the same on-screen.
[in] | texture | The texture that is being updated by the embedder but composited by Flutter in its own hierarchy. |
|
pure virtual |
Deallocate resources for a removed view and inform Dart about the removal.
After the operation, |callback| should be invoked with whether the operation is successful.
Removing |kFlutterImplicitViewId| or an non-existent view ID should result in failure.
[in] | view_id | The view ID of the view to be removed. |
[in] | callback | The callback that's invoked once the shell has attempted to remove the view. |
|
pure virtual |
Notifies the delegate that the platform needs to schedule a frame to regenerate the layer tree and redraw the surface.
|
pure virtual |
Notifies the delegate that the embedder has expressed an opinion about the features to enable in the accessibility tree.
The engine does not care about the accessibility feature flags as all it does is forward this information from the embedder to the framework. However, curious readers may refer to AccessibilityFeatures
in window.dart
for currently supported accessibility feature flags.
[in] | flags | The features to enable in the accessibility tree. |
|
pure virtual |
Notifies the delegate that the specified callback needs to be invoked after the rasterizer is done rendering the next frame. This callback will be called on the render thread and it is caller responsibility to perform any re-threading as necessary. Due to the asynchronous nature of rendering in Flutter, embedders usually add a placeholder over the contents in which Flutter is going to render when Flutter is first initialized. This callback may be used as a signal to remove that placeholder.
[in] | closure | The callback to execute on the next frame. |
|
pure virtual |
Notifies the delegate that the embedder has expressed an opinion about whether the accessibility tree needs to be enabled or disabled. This information needs to be forwarded to the root isolate running on the UI thread.
[in] | enabled | Whether the accessibility tree is enabled or disabled. |
|
pure virtual |
Notifies the delegate the viewport metrics of a view have been updated. The rasterizer will need to be reconfigured to render the frame in the updated viewport metrics.
[in] | view_id | The ID for the view that metrics describes. |
[in] | metrics | The updated viewport metrics. |
|
pure virtual |
Notifies the delegate that the embedder will no longer attempt to composite the specified texture within the layer tree. This allows the rasterizer to collect associated resources.
[in] | texture_id | The identifier of the texture to unregister. If the texture has not been previously registered, this call does nothing. |
|
pure virtual |
Replaces the asset resolver handled by the engine's AssetManager of the specified type
with updated_asset_resolver
. The matching AssetResolver is removed and replaced with updated_asset_resolvers
.
AssetResolvers should be updated when the existing resolver becomes obsolete and a newer one becomes available that provides updated access to the same type of assets as the existing one. This update process is meant to be performed at runtime.
If a null resolver is provided, nothing will be done. If no matching resolver is found, the provided resolver will be added to the end of the AssetManager resolvers queue. The replacement only occurs with the first matching resolver. Any additional matching resolvers are untouched.
[in] | updated_asset_resolver | The asset resolver to replace the resolver of matching type with. |
[in] | type | The type of AssetResolver to update. Only resolvers of the specified type will be replaced by the updated resolver. |