Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
flutter::PlatformView::Delegate Class Referenceabstract

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>

Inheritance diagram for flutter::PlatformView::Delegate:
flutter::Shell

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.
 
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.
 
virtual void OnPlatformViewScheduleFrame ()=0
 Notifies the delegate that the platform needs to schedule a frame to regenerate the layer tree and redraw the surface.
 
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.
 
virtual void OnPlatformViewRemoveView (int64_t view_id, RemoveViewCallback callback)=0
 Deallocate resources for a removed view and inform Dart about the removal.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
virtual const SettingsOnPlatformViewGetSettings () const =0
 Called by the platform view on the platform thread to get the settings object associated with the platform view instance.
 

Detailed Description

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 61 of file platform_view.h.

Member Typedef Documentation

◆ AddViewCallback

Definition at line 63 of file platform_view.h.

◆ KeyDataResponse

using flutter::PlatformView::Delegate::KeyDataResponse = std::function<void(bool)>

Definition at line 65 of file platform_view.h.

◆ RemoveViewCallback

Definition at line 64 of file platform_view.h.

Member Function Documentation

◆ LoadDartDeferredLibrary()

virtual void flutter::PlatformView::Delegate::LoadDartDeferredLibrary ( intptr_t  loading_unit_id,
std::unique_ptr< const fml::Mapping snapshot_data,
std::unique_ptr< const fml::Mapping snapshot_instructions 
)
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.

Parameters
[in]loading_unit_idThe unique id of the deferred library's loading unit.
[in]snapshot_dataDart snapshot data of the loading unit's shared library.
[in]snapshot_dataDart snapshot instructions of the loading unit's shared library.

Implemented in flutter::Shell.

◆ LoadDartDeferredLibraryError()

virtual void flutter::PlatformView::Delegate::LoadDartDeferredLibraryError ( intptr_t  loading_unit_id,
const std::string  error_message,
bool  transient 
)
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.

Parameters
[in]loading_unit_idThe unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary.
[in]error_messageThe error message that will appear in the dart Future.
[in]transientA 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.

Implemented in flutter::Shell.

◆ OnPlatformViewAddView()

virtual void flutter::PlatformView::Delegate::OnPlatformViewAddView ( int64_t  view_id,
const ViewportMetrics viewport_metrics,
AddViewCallback  callback 
)
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.

Parameters
[in]view_idThe view ID of the new view.
[in]viewport_metricsThe initial viewport metrics for the view.
[in]callbackThe callback that's invoked once the shell has attempted to add the view.

Implemented in flutter::Shell.

◆ OnPlatformViewCreated()

virtual void flutter::PlatformView::Delegate::OnPlatformViewCreated ( std::unique_ptr< Surface surface)
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.

Parameters
[in]surfaceThe surface

Implemented in flutter::Shell.

◆ OnPlatformViewDestroyed()

virtual void flutter::PlatformView::Delegate::OnPlatformViewDestroyed ( )
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.

Implemented in flutter::Shell.

◆ OnPlatformViewDispatchPlatformMessage()

virtual void flutter::PlatformView::Delegate::OnPlatformViewDispatchPlatformMessage ( std::unique_ptr< PlatformMessage message)
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.

Parameters
[in]messageThe platform message to dispatch to the running root isolate.

Implemented in flutter::Shell.

◆ OnPlatformViewDispatchPointerDataPacket()

virtual void flutter::PlatformView::Delegate::OnPlatformViewDispatchPointerDataPacket ( std::unique_ptr< PointerDataPacket packet)
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.

Parameters
[in]packetThe pointer data packet containing multiple pointer events.

Implemented in flutter::Shell.

◆ OnPlatformViewDispatchSemanticsAction()

virtual void flutter::PlatformView::Delegate::OnPlatformViewDispatchSemanticsAction ( int32_t  node_id,
SemanticsAction  action,
fml::MallocMapping  args 
)
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.

Parameters
[in]node_idThe identifier of the accessibility node.
[in]actionThe accessibility related action performed on the node of the specified ID.
[in]argsAn optional list of argument that apply to the specified action.

Implemented in flutter::Shell.

◆ OnPlatformViewGetSettings()

virtual const Settings & flutter::PlatformView::Delegate::OnPlatformViewGetSettings ( ) const
pure virtual

Called by the platform view on the platform thread to get the settings object associated with the platform view instance.

Returns
The settings.

Implemented in flutter::Shell.

◆ OnPlatformViewMarkTextureFrameAvailable()

virtual void flutter::PlatformView::Delegate::OnPlatformViewMarkTextureFrameAvailable ( int64_t  texture_id)
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.

Parameters
[in]texture_idThe identifier of the texture that has been updated.

Implemented in flutter::Shell.

◆ OnPlatformViewRegisterTexture()

virtual void flutter::PlatformView::Delegate::OnPlatformViewRegisterTexture ( std::shared_ptr< Texture texture)
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.

Parameters
[in]textureThe texture that is being updated by the embedder but composited by Flutter in its own hierarchy.

◆ OnPlatformViewRemoveView()

virtual void flutter::PlatformView::Delegate::OnPlatformViewRemoveView ( int64_t  view_id,
RemoveViewCallback  callback 
)
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.

Parameters
[in]view_idThe view ID of the view to be removed.
[in]callbackThe callback that's invoked once the shell has attempted to remove the view.

Implemented in flutter::Shell.

◆ OnPlatformViewScheduleFrame()

virtual void flutter::PlatformView::Delegate::OnPlatformViewScheduleFrame ( )
pure virtual

Notifies the delegate that the platform needs to schedule a frame to regenerate the layer tree and redraw the surface.

Implemented in flutter::Shell.

◆ OnPlatformViewSetAccessibilityFeatures()

virtual void flutter::PlatformView::Delegate::OnPlatformViewSetAccessibilityFeatures ( int32_t  flags)
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.

Parameters
[in]flagsThe features to enable in the accessibility tree.

Implemented in flutter::Shell.

◆ OnPlatformViewSetNextFrameCallback()

virtual void flutter::PlatformView::Delegate::OnPlatformViewSetNextFrameCallback ( const fml::closure closure)
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.

Attention
The callback will be invoked on the render thread and not the calling thread.
Parameters
[in]closureThe callback to execute on the next frame.

Implemented in flutter::Shell.

◆ OnPlatformViewSetSemanticsEnabled()

virtual void flutter::PlatformView::Delegate::OnPlatformViewSetSemanticsEnabled ( bool  enabled)
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.

Parameters
[in]enabledWhether the accessibility tree is enabled or disabled.

Implemented in flutter::Shell.

◆ OnPlatformViewSetViewportMetrics()

virtual void flutter::PlatformView::Delegate::OnPlatformViewSetViewportMetrics ( int64_t  view_id,
const ViewportMetrics metrics 
)
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.

Parameters
[in]view_idThe ID for the view that metrics describes.
[in]metricsThe updated viewport metrics.

Implemented in flutter::Shell.

◆ OnPlatformViewUnregisterTexture()

virtual void flutter::PlatformView::Delegate::OnPlatformViewUnregisterTexture ( int64_t  texture_id)
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.

Parameters
[in]texture_idThe identifier of the texture to unregister. If the texture has not been previously registered, this call does nothing.

Implemented in flutter::Shell.

◆ UpdateAssetResolverByType()

virtual void flutter::PlatformView::Delegate::UpdateAssetResolverByType ( std::unique_ptr< AssetResolver updated_asset_resolver,
AssetResolver::AssetResolverType  type 
)
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.

Parameters
[in]updated_asset_resolverThe asset resolver to replace the resolver of matching type with.
[in]typeThe type of AssetResolver to update. Only resolvers of the specified type will be replaced by the updated resolver.

Implemented in flutter::Shell.


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