Flutter Engine
flutter::PlatformView Class Reference

Platform views are created by the shell on the platform task runner. Unless explicitly specified, all platform view methods are called on the platform task runner as well. Platform views are usually sub-classed on a per platform basis and the bulk of the window system integration happens using that subclass. Since most platform window toolkits are usually only safe to access on a single "main" thread, any interaction that requires access to the underlying platform's window toolkit is routed through the platform view associated with that shell. This involves operations like settings up and tearing down the render surface, platform messages, interacting with accessibility features on the platform, input events, etc. More...

#include <platform_view.h>

Inheritance diagram for flutter::PlatformView:
flutter::PlatformViewAndroid flutter::PlatformViewEmbedder flutter::PlatformViewIOS flutter::testing::ShellTestPlatformView flutter_runner::PlatformView flutter::testing::ShellTestPlatformViewGL flutter::testing::ShellTestPlatformViewVulkan

Classes

class  Delegate
 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...
 

Public Member Functions

 PlatformView (Delegate &delegate, TaskRunners task_runners)
 Creates a platform view with the specified delegate and task runner. The base class by itself does not do much but is suitable for use in test environments where full platform integration may not be necessary. The platform view may only be created, accessed and destroyed on the platform task runner. More...
 
virtual ~PlatformView ()
 Destroys the platform view. The platform view is owned by the shell and will be destroyed by the same on the platform tasks runner. More...
 
virtual std::unique_ptr< VsyncWaiterCreateVSyncWaiter ()
 Invoked by the shell to obtain a platform specific vsync waiter. It is optional for platforms to override this method and provide a custom vsync waiter because a timer based fall-back waiter is used by default. However, it is highly recommended that platform provide their own Vsync waiter as the timer based fall-back will not render frames aligned with vsync boundaries. More...
 
void DispatchPlatformMessage (fml::RefPtr< PlatformMessage > message)
 Used by embedders to dispatch a platform message to a running root isolate hosted by the engine. If an isolate is not running, the message is dropped. If there is no one on the other side listening on the channel, the message is dropped. When a platform message is dropped, any response handles associated with that message will be dropped as well. All users of platform messages must assume that message may not be delivered and/or their response handles may not be invoked. Platform messages are not buffered. More...
 
virtual void HandlePlatformMessage (fml::RefPtr< PlatformMessage > message)
 Overridden by embedders to perform actions in response to platform messages sent from the framework to the embedder. Default implementation of this method simply returns an empty response. More...
 
void DispatchSemanticsAction (int32_t id, SemanticsAction action, std::vector< uint8_t > args)
 Used by embedders to dispatch an accessibility action to a running isolate hosted by the engine. More...
 
virtual void SetSemanticsEnabled (bool enabled)
 Used by embedder to notify the running isolate hosted by the engine on the UI thread that the accessibility tree needs to be generated. More...
 
virtual void SetAccessibilityFeatures (int32_t flags)
 Used by the embedder to specify the features to enable in the accessibility tree generated by the isolate. This information is forwarded to the root isolate hosted by the engine on the UI thread. More...
 
virtual void UpdateSemantics (SemanticsNodeUpdates updates, CustomAccessibilityActionUpdates actions)
 Used by the framework to tell the embedder to apply the specified semantics node updates. The default implementation of this method does nothing. More...
 
void SetViewportMetrics (const ViewportMetrics &metrics)
 Used by embedders to specify the updated viewport metrics. In response to this call, on the raster thread, the rasterizer may need to be reconfigured to the updated viewport dimensions. On the UI thread, the framework may need to start generating a new frame for the updated viewport metrics as well. More...
 
void NotifyCreated ()
 Used by embedders to notify the shell that a platform view has been created. This notification is used to create a rendering surface and pick the client rendering API to use to render into this surface. No frames will be scheduled or rendered before this call. The surface must remain valid till the corresponding call to NotifyDestroyed. More...
 
virtual void NotifyDestroyed ()
 Used by embedders to notify the shell that the platform view has been destroyed. This notification used to collect the rendering surface and all associated resources. Frame scheduling is also suspended. More...
 
virtual sk_sp< GrDirectContext > CreateResourceContext () const
 Used by the shell to obtain a Skia GPU context that is capable of operating on the IO thread. The context must be in the same share-group as the Skia GPU context used on the render thread. This context will always be used on the IO thread. Because it is in the same share-group as the separate render thread context, any GPU resources uploaded in this context will be visible to the render thread context (synchronization of GPU resources is managed by Skia). More...
 
virtual void ReleaseResourceContext () const
 Used by the shell to notify the embedder that the resource context previously obtained via a call to CreateResourceContext() is being collected. The embedder is free to collect an platform specific resources associated with this context. More...
 
virtual PointerDataDispatcherMaker GetDispatcherMaker ()
 Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPacketDispatcher based on platforms. More...
 
fml::WeakPtr< PlatformViewGetWeakPtr () const
 Returns a weak pointer to the platform view. Since the platform view may only be created, accessed and destroyed on the platform thread, any access to the platform view from a non-platform task runner needs a weak pointer to the platform view along with a reference to the platform task runner. A task must be posted to the platform task runner with the weak pointer captured in the same. The platform view method may only be called in the posted task once the weak pointer validity has been checked. This method is used by callers to obtain that weak pointer. More...
 
virtual void OnPreEngineRestart () const
 Gives embedders a chance to react to a "cold restart" of the running isolate. The default implementation of this method does nothing. More...
 
void SetNextFrameCallback (const fml::closure &closure)
 Sets a callback that gets executed when the rasterizer renders the next frame. 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. The callback is executed on the render task runner and not the platform task runner. It is the embedder's responsibility to re-thread as necessary. More...
 
void DispatchPointerDataPacket (std::unique_ptr< PointerDataPacket > packet)
 Dispatches pointer events from the embedder to the framework. Each pointer data packet may contain multiple pointer input events. Each call to this method wakes up the UI thread. More...
 
void RegisterTexture (std::shared_ptr< flutter::Texture > texture)
 Used by the embedder to specify a texture that it wants 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...
 
void UnregisterTexture (int64_t texture_id)
 Used by the embedder to notify the rasterizer that it will no longer attempt to composite the specified texture within the layer tree. This allows the rasterizer to collect associated resources. More...
 
void MarkTextureFrameAvailable (int64_t texture_id)
 Used by the embedder to notify the rasterizer that the context of the previously registered texture have been updated. 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 re-composited with all updated external textures. Unlike the calls to register and unregister the texture, this call must be made each time a new texture frame is available. More...
 
virtual std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocales (const std::vector< std::string > &supported_locale_data)
 Directly invokes platform-specific APIs to compute the locale the platform would have natively resolved to. More...
 

Protected Member Functions

virtual std::unique_ptr< SurfaceCreateRenderingSurface ()
 

Protected Attributes

PlatformView::Delegatedelegate_
 
const TaskRunners task_runners_
 
PointerDataPacketConverter pointer_data_packet_converter_
 
SkISize size_
 
fml::WeakPtrFactory< PlatformViewweak_factory_
 

Detailed Description

Platform views are created by the shell on the platform task runner. Unless explicitly specified, all platform view methods are called on the platform task runner as well. Platform views are usually sub-classed on a per platform basis and the bulk of the window system integration happens using that subclass. Since most platform window toolkits are usually only safe to access on a single "main" thread, any interaction that requires access to the underlying platform's window toolkit is routed through the platform view associated with that shell. This involves operations like settings up and tearing down the render surface, platform messages, interacting with accessibility features on the platform, input events, etc.

Definition at line 44 of file platform_view.h.

Constructor & Destructor Documentation

◆ PlatformView()

flutter::PlatformView::PlatformView ( Delegate delegate,
TaskRunners  task_runners 
)
explicit

Creates a platform view with the specified delegate and task runner. The base class by itself does not do much but is suitable for use in test environments where full platform integration may not be necessary. The platform view may only be created, accessed and destroyed on the platform task runner.

Parameters
delegateThe delegate. This is typically the shell.
[in]task_runnersThe task runners used by this platform view.

Definition at line 19 of file platform_view.cc.

Referenced by flutter::PlatformViewEmbedder::PlatformViewEmbedder().

20  : delegate_(delegate),
21  task_runners_(std::move(task_runners)),
22  size_(SkISize::Make(0, 0)),
23  weak_factory_(this) {}
fml::WeakPtrFactory< PlatformView > weak_factory_
const TaskRunners task_runners_
PlatformView::Delegate & delegate_

◆ ~PlatformView()

flutter::PlatformView::~PlatformView ( )
virtualdefault

Destroys the platform view. The platform view is owned by the shell and will be destroyed by the same on the platform tasks runner.

Reimplemented in flutter_runner::PlatformView.

Member Function Documentation

◆ ComputePlatformResolvedLocales()

std::unique_ptr< std::vector< std::string > > flutter::PlatformView::ComputePlatformResolvedLocales ( const std::vector< std::string > &  supported_locale_data)
virtual

Directly invokes platform-specific APIs to compute the locale the platform would have natively resolved to.

Parameters
[in]supported_locale_dataThe vector of strings that represents the locales supported by the app. Each locale consists of three strings: languageCode, countryCode, and scriptCode in that order.
Returns
A vector of 3 strings languageCode, countryCode, and scriptCode that represents the locale selected by the platform. Empty strings mean the value was unassigned. Empty vector represents a null locale.

Definition at line 148 of file platform_view.cc.

149  {
150  std::unique_ptr<std::vector<std::string>> out =
151  std::make_unique<std::vector<std::string>>();
152  return out;
153 }

◆ CreateRenderingSurface()

std::unique_ptr< Surface > flutter::PlatformView::CreateRenderingSurface ( )
protectedvirtual

Definition at line 131 of file platform_view.cc.

References FML_DCHECK.

131  {
132  // We have a default implementation because tests create a platform view but
133  // never a rendering surface.
134  FML_DCHECK(false) << "This platform does not provide a rendering surface but "
135  "it was notified of surface rendering surface creation.";
136  return nullptr;
137 }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ CreateResourceContext()

sk_sp< GrDirectContext > flutter::PlatformView::CreateResourceContext ( ) const
virtual

Used by the shell to obtain a Skia GPU context that is capable of operating on the IO thread. The context must be in the same share-group as the Skia GPU context used on the render thread. This context will always be used on the IO thread. Because it is in the same share-group as the separate render thread context, any GPU resources uploaded in this context will be visible to the render thread context (synchronization of GPU resources is managed by Skia).

If such context cannot be created on the IO thread, callers may return nullptr. This will mean that all texture uploads will be queued onto the render thread which will cause performance issues. When this context is nullptr, an error is logged to the console. It is highly recommended that all platforms provide a resource context.

Attention
Unlike all other methods on the platform view, this will be called on IO task runner.
Returns
The Skia GPU context that is in the same share-group as the main render thread GPU context. May be nullptr in case such a context cannot be created.

Definition at line 91 of file platform_view.cc.

References FML_DLOG.

91  {
92  FML_DLOG(WARNING) << "This platform does not setup the resource "
93  "context on the IO thread for async texture uploads.";
94  return nullptr;
95 }
#define FML_DLOG(severity)
Definition: logging.h:85

◆ CreateVSyncWaiter()

std::unique_ptr< VsyncWaiter > flutter::PlatformView::CreateVSyncWaiter ( )
virtual

Invoked by the shell to obtain a platform specific vsync waiter. It is optional for platforms to override this method and provide a custom vsync waiter because a timer based fall-back waiter is used by default. However, it is highly recommended that platform provide their own Vsync waiter as the timer based fall-back will not render frames aligned with vsync boundaries.

Attention
If a timer based fall-back is used, a warning is logged to the console. In case this method is overridden in a subclass, it must return a valid vsync waiter. Returning null will lead to internal errors. If a valid vsync waiter cannot be returned, subclasses should just call the based class method instead.
Returns
A vsync waiter. If is an internal error to return a null waiter.

Definition at line 27 of file platform_view.cc.

References FML_DLOG, and task_runners_.

Referenced by flutter::PlatformViewEmbedder::HandlePlatformMessage().

27  {
28  FML_DLOG(WARNING)
29  << "This platform does not provide a Vsync waiter implementation. A "
30  "simple timer based fallback is being used.";
31  return std::make_unique<VsyncWaiterFallback>(task_runners_);
32 }
const TaskRunners task_runners_
#define FML_DLOG(severity)
Definition: logging.h:85

◆ DispatchPlatformMessage()

void flutter::PlatformView::DispatchPlatformMessage ( fml::RefPtr< PlatformMessage message)

Used by embedders to dispatch a platform message to a running root isolate hosted by the engine. If an isolate is not running, the message is dropped. If there is no one on the other side listening on the channel, the message is dropped. When a platform message is dropped, any response handles associated with that message will be dropped as well. All users of platform messages must assume that message may not be delivered and/or their response handles may not be invoked. Platform messages are not buffered.

For embedders that wish to respond to platform message directed from the framework to the embedder, the HandlePlatformMessage method may be overridden.

See also
HandlePlatformMessage()
Parameters
[in]messageThe platform message to deliver to the root isolate.

Definition at line 34 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewDispatchPlatformMessage().

Referenced by flutter::PlatformViewAndroid::DispatchEmptyPlatformMessage(), flutter::PlatformViewAndroid::DispatchPlatformMessage(), flutter_runner::PlatformView::PlatformView(), and flutter_runner::PointerTraceHACK().

35  {
37 }
virtual void OnPlatformViewDispatchPlatformMessage(fml::RefPtr< PlatformMessage > message)=0
Notifies the delegate that the platform has dispatched a platform message from the embedder to the Fl...
PlatformView::Delegate & delegate_

◆ DispatchPointerDataPacket()

void flutter::PlatformView::DispatchPointerDataPacket ( std::unique_ptr< PointerDataPacket packet)

Dispatches pointer events from the embedder to the framework. Each pointer data packet may contain multiple pointer input events. Each call to this method wakes up the UI thread.

Parameters
[in]packetThe pointer data packet to dispatch to the framework.

Definition at line 39 of file platform_view.cc.

References flutter::PointerDataPacketConverter::Convert(), delegate_, flutter::PlatformView::Delegate::OnPlatformViewDispatchPointerDataPacket(), and pointer_data_packet_converter_.

Referenced by flutter_runner::PointerTraceHACK().

40  {
42  pointer_data_packet_converter_.Convert(std::move(packet)));
43 }
std::unique_ptr< PointerDataPacket > Convert(std::unique_ptr< PointerDataPacket > packet)
Converts pointer data packet into a form that framework understands. The raw pointer data packet from...
PlatformView::Delegate & delegate_
PointerDataPacketConverter pointer_data_packet_converter_
virtual void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr< PointerDataPacket > packet)=0
Notifies the delegate that the platform view has encountered a pointer event. This pointer event need...

◆ DispatchSemanticsAction()

void flutter::PlatformView::DispatchSemanticsAction ( int32_t  id,
SemanticsAction  action,
std::vector< uint8_t >  args 
)

Used by embedders to dispatch an accessibility action to a running isolate hosted by the engine.

Parameters
[in]idThe identifier of the accessibility node on which to perform the action.
[in]actionThe action
[in]argsThe arguments

Definition at line 45 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewDispatchSemanticsAction().

Referenced by flutter::AccessibilityBridge::DispatchSemanticsAction(), flutter_runner::PlatformView::DispatchSemanticsAction(), and flutter::PlatformViewAndroid::DispatchSemanticsAction().

47  {
49 }
G_BEGIN_DECLS FlValue * args
virtual void OnPlatformViewDispatchSemanticsAction(int32_t id, SemanticsAction action, std::vector< uint8_t > args)=0
Notifies the delegate that the platform view has encountered an accessibility related action on the s...
PlatformView::Delegate & delegate_
SemanticsAction action

◆ GetDispatcherMaker()

PointerDataDispatcherMaker flutter::PlatformView::GetDispatcherMaker ( )
virtual

Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPacketDispatcher based on platforms.

Reimplemented in flutter::PlatformViewIOS, and flutter_runner::PlatformView.

Definition at line 99 of file platform_view.cc.

99  {
100  return [](DefaultPointerDataDispatcher::Delegate& delegate) {
101  return std::make_unique<DefaultPointerDataDispatcher>(delegate);
102  };
103 }

◆ GetWeakPtr()

fml::WeakPtr< PlatformView > flutter::PlatformView::GetWeakPtr ( ) const

Returns a weak pointer to the platform view. Since the platform view may only be created, accessed and destroyed on the platform thread, any access to the platform view from a non-platform task runner needs a weak pointer to the platform view along with a reference to the platform task runner. A task must be posted to the platform task runner with the weak pointer captured in the same. The platform view method may only be called in the posted task once the weak pointer validity has been checked. This method is used by callers to obtain that weak pointer.

Returns
The weak pointer to the platform view.

Definition at line 105 of file platform_view.cc.

References weak_factory_.

Referenced by flutter::PlatformViewAndroid::RegisterExternalTexture().

105  {
106  return weak_factory_.GetWeakPtr();
107 }
fml::WeakPtrFactory< PlatformView > weak_factory_

◆ HandlePlatformMessage()

void flutter::PlatformView::HandlePlatformMessage ( fml::RefPtr< PlatformMessage message)
virtual

Overridden by embedders to perform actions in response to platform messages sent from the framework to the embedder. Default implementation of this method simply returns an empty response.

Embedders that wish to send platform messages to the framework may use the DispatchPlatformMessage method. This method is for messages that go the other way.

See also
DisplatchPlatformMessage()
Parameters
[in]messageThe message

Reimplemented in flutter::PlatformViewEmbedder.

Definition at line 112 of file platform_view.cc.

Referenced by flutter_runner::PointerTraceHACK().

112  {
113  if (auto response = message->response())
114  response->CompleteEmpty();
115 }

◆ MarkTextureFrameAvailable()

void flutter::PlatformView::MarkTextureFrameAvailable ( int64_t  texture_id)

Used by the embedder to notify the rasterizer that the context of the previously registered texture have been updated. 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 re-composited with all updated external textures. Unlike the calls to register and unregister the texture, this call must be made each time a new texture frame is available.

See also
RegisterTexture, UnregisterTexture
Parameters
[in]texture_idThe identifier of the texture that has been updated.

Definition at line 127 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewMarkTextureFrameAvailable().

127  {
129 }
virtual void OnPlatformViewMarkTextureFrameAvailable(int64_t texture_id)=0
Notifies the delegate that the embedder has updated the contents of the texture with the specified id...
PlatformView::Delegate & delegate_

◆ NotifyCreated()

void flutter::PlatformView::NotifyCreated ( )

Used by embedders to notify the shell that a platform view has been created. This notification is used to create a rendering surface and pick the client rendering API to use to render into this surface. No frames will be scheduled or rendered before this call. The surface must remain valid till the corresponding call to NotifyDestroyed.

Definition at line 63 of file platform_view.cc.

References delegate_, FML_LOG, flutter::TaskRunners::GetRasterTaskRunner(), flutter::PlatformView::Delegate::OnPlatformViewCreated(), fml::TaskRunner::RunNowOrPostTask(), fml::ManualResetWaitableEvent::Signal(), task_runners_, and fml::ManualResetWaitableEvent::Wait().

Referenced by flutter::PlatformViewAndroid::NotifyCreated(), and flutter_runner::testing::TEST_F().

63  {
64  std::unique_ptr<Surface> surface;
65 
66  // Threading: We want to use the platform view on the non-platform thread.
67  // Using the weak pointer is illegal. But, we are going to introduce a latch
68  // so that the platform view is not collected till the surface is obtained.
69  auto* platform_view = this;
72  task_runners_.GetRasterTaskRunner(), [platform_view, &surface, &latch]() {
73  surface = platform_view->CreateRenderingSurface();
74  if (surface && !surface->IsValid()) {
75  surface.reset();
76  }
77  latch.Signal();
78  });
79  latch.Wait();
80  if (!surface) {
81  FML_LOG(ERROR) << "Failed to create platform view rendering surface";
82  return;
83  }
84  delegate_.OnPlatformViewCreated(std::move(surface));
85 }
const TaskRunners task_runners_
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55
#define FML_LOG(severity)
Definition: logging.h:65
fml::RefPtr< fml::TaskRunner > GetRasterTaskRunner() const
Definition: task_runners.cc:42
PlatformView::Delegate & delegate_
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 setup and begin rendering to that surface.

◆ NotifyDestroyed()

void flutter::PlatformView::NotifyDestroyed ( )
virtual

Used by embedders to notify the shell that the platform view has been destroyed. This notification used to collect the rendering surface and all associated resources. Frame scheduling is also suspended.

Attention
Subclasses may choose to override this method to perform platform specific functions. However, they must call the base class method at some point in their implementation.

Reimplemented in flutter::PlatformViewAndroid.

Definition at line 87 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewDestroyed().

Referenced by flutter::PlatformViewAndroid::NotifyDestroyed(), and flutter::PlatformViewIOS::SetOwnerViewController().

87  {
89 }
PlatformView::Delegate & delegate_
virtual void OnPlatformViewDestroyed()=0
Notifies the delegate that the platform view was destroyed. This is usually a sign to the rasterizer ...

◆ OnPreEngineRestart()

void flutter::PlatformView::OnPreEngineRestart ( ) const
virtual

Gives embedders a chance to react to a "cold restart" of the running isolate. The default implementation of this method does nothing.

While a "hot restart" patches a running isolate, a "cold restart" restarts the root isolate in a running shell.

Definition at line 117 of file platform_view.cc.

117 {}

◆ RegisterTexture()

void flutter::PlatformView::RegisterTexture ( std::shared_ptr< flutter::Texture texture)

Used by the embedder to specify a texture that it wants 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.

Attention
This method must only be called once per texture. When the texture is updated, calling MarkTextureFrameAvailable with the specified texture identifier is sufficient to make Flutter re-render the frame with the updated texture composited in-line.
See also
UnregisterTexture, MarkTextureFrameAvailable
Parameters
[in]textureThe texture that is being updated by the embedder but composited by Flutter in its own hierarchy.

Definition at line 119 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewRegisterTexture().

Referenced by flutter::PlatformViewIOS::RegisterExternalTexture(), and flutter::PlatformViewAndroid::RegisterExternalTexture().

119  {
120  delegate_.OnPlatformViewRegisterTexture(std::move(texture));
121 }
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 compos...
PlatformView::Delegate & delegate_

◆ ReleaseResourceContext()

void flutter::PlatformView::ReleaseResourceContext ( ) const
virtual

Used by the shell to notify the embedder that the resource context previously obtained via a call to CreateResourceContext() is being collected. The embedder is free to collect an platform specific resources associated with this context.

Attention
Unlike all other methods on the platform view, this will be called on IO task runner.

Definition at line 97 of file platform_view.cc.

97 {}

◆ SetAccessibilityFeatures()

void flutter::PlatformView::SetAccessibilityFeatures ( int32_t  flags)
virtual

Used by the embedder to specify the features to enable in the accessibility tree generated by the isolate. This information is forwarded to the root isolate hosted by the engine on the UI thread.

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.

Attention
Subclasses may choose to override this method to perform platform specific functions. However, they must call the base class method at some point in their implementation.
Parameters
[in]flagsThe features to enable in the accessibility tree.

Definition at line 55 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewSetAccessibilityFeatures().

Referenced by flutter_runner::PlatformView::SetSemanticsEnabled(), and flutter::PlatformViewIOS::SetSemanticsEnabled().

55  {
57 }
PlatformView::Delegate & delegate_
virtual void OnPlatformViewSetAccessibilityFeatures(int32_t flags)=0
Notifies the delegate that the embedder has expressed an opinion about the features to enable in the ...
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart flags
Definition: switches.h:66

◆ SetNextFrameCallback()

void flutter::PlatformView::SetNextFrameCallback ( const fml::closure closure)

Sets a callback that gets executed when the rasterizer renders the next frame. 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. The callback is executed on the render task runner and not the platform task runner. It is the embedder's responsibility to re-thread as necessary.

Attention
The callback is executed on the render task runner and not the platform task runner. Embedders must re-thread as necessary.
Parameters
[in]closureThe callback to execute on the render thread when the next frame gets rendered.

Definition at line 139 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewSetNextFrameCallback().

Referenced by FlutterViewController::pushRoute:, and flutter::PlatformViewAndroid::RegisterExternalTexture().

139  {
140  if (!closure) {
141  return;
142  }
143 
145 }
std::function< void()> closure
Definition: closure.h:14
PlatformView::Delegate & delegate_
virtual void OnPlatformViewSetNextFrameCallback(const fml::closure &closure)=0
Notifies the delegate that the specified callback needs to be invoked after the rasterizer is done re...

◆ SetSemanticsEnabled()

void flutter::PlatformView::SetSemanticsEnabled ( bool  enabled)
virtual

Used by embedder to notify the running isolate hosted by the engine on the UI thread that the accessibility tree needs to be generated.

Attention
Subclasses may choose to override this method to perform platform specific functions. However, they must call the base class method at some point in their implementation.
Parameters
[in]enabledWhether the accessibility tree needs to be generated.

Reimplemented in flutter::PlatformViewIOS, and flutter_runner::PlatformView.

Definition at line 51 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewSetSemanticsEnabled().

Referenced by flutter::PlatformViewIOS::PlatformViewIOS(), flutter_runner::PlatformView::SetSemanticsEnabled(), and flutter::PlatformViewIOS::SetSemanticsEnabled().

51  {
53 }
virtual void OnPlatformViewSetSemanticsEnabled(bool enabled)=0
Notifies the delegate that the embedder has expressed an opinion about whether the accessibility tree...
PlatformView::Delegate & delegate_

◆ SetViewportMetrics()

void flutter::PlatformView::SetViewportMetrics ( const ViewportMetrics metrics)

Used by embedders to specify the updated viewport metrics. In response to this call, on the raster thread, the rasterizer may need to be reconfigured to the updated viewport dimensions. On the UI thread, the framework may need to start generating a new frame for the updated viewport metrics as well.

Parameters
[in]metricsThe updated viewport metrics.

Definition at line 59 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewSetViewportMetrics().

Referenced by flutter_runner::PlatformView::PlatformView().

59  {
61 }
PlatformView::Delegate & delegate_
virtual void OnPlatformViewSetViewportMetrics(const ViewportMetrics &metrics)=0
Notifies the delegate the viewport metrics of the platform view have been updated. The rasterizer will need to be reconfigured to render the frame in the updated viewport metrics.

◆ UnregisterTexture()

void flutter::PlatformView::UnregisterTexture ( int64_t  texture_id)

Used by the embedder to notify the rasterizer that it will no longer attempt to composite the specified texture within the layer tree. This allows the rasterizer to collect associated resources.

Attention
This call must only be called once per texture identifier.
See also
RegisterTexture, MarkTextureFrameAvailable
Parameters
[in]texture_idThe identifier of the texture to unregister. If the texture has not been previously registered, this call does nothing.

Definition at line 123 of file platform_view.cc.

References delegate_, and flutter::PlatformView::Delegate::OnPlatformViewUnregisterTexture().

123  {
125 }
PlatformView::Delegate & delegate_
virtual void OnPlatformViewUnregisterTexture(int64_t texture_id)=0
Notifies the delegate that the embedder will no longer attempt to composite the specified texture wit...

◆ UpdateSemantics()

void flutter::PlatformView::UpdateSemantics ( SemanticsNodeUpdates  updates,
CustomAccessibilityActionUpdates  actions 
)
virtual

Used by the framework to tell the embedder to apply the specified semantics node updates. The default implementation of this method does nothing.

See also
SemanticsNode, SemticsNodeUpdates, CustomAccessibilityActionUpdates
Parameters
[in]updatesA map with the stable semantics node identifier as key and the node properties as the value.
[in]actionsA map with the stable semantics node identifier as key and the custom node action as the value.

Reimplemented in flutter::PlatformViewEmbedder.

Definition at line 109 of file platform_view.cc.

110  {}

Member Data Documentation

◆ delegate_

◆ pointer_data_packet_converter_

PointerDataPacketConverter flutter::PlatformView::pointer_data_packet_converter_
protected

Definition at line 588 of file platform_view.h.

Referenced by DispatchPointerDataPacket().

◆ size_

SkISize flutter::PlatformView::size_
protected

Definition at line 589 of file platform_view.h.

◆ task_runners_

◆ weak_factory_

fml::WeakPtrFactory<PlatformView> flutter::PlatformView::weak_factory_
protected

Definition at line 590 of file platform_view.h.

Referenced by GetWeakPtr().


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