Flutter Engine
flutter_runner::PlatformView Class Referencefinal

#include <platform_view.h>

Inheritance diagram for flutter_runner::PlatformView:
flutter::PlatformView flutter_runner::AccessibilityBridge::Delegate

Public Member Functions

 PlatformView (flutter::PlatformView::Delegate &delegate, std::string debug_label, fuchsia::ui::views::ViewRef view_ref, flutter::TaskRunners task_runners, std::shared_ptr< sys::ServiceDirectory > runner_services, fidl::InterfaceHandle< fuchsia::sys::ServiceProvider > parent_environment_service_provider, fidl::InterfaceRequest< fuchsia::ui::scenic::SessionListener > session_listener_request, fidl::InterfaceHandle< fuchsia::ui::views::Focuser > focuser, fit::closure on_session_listener_error_callback, OnEnableWireframe wireframe_enabled_callback, OnCreateView on_create_view_callback, OnUpdateView on_update_view_callback, OnDestroyView on_destroy_view_callback, OnCreateSurface on_create_surface_callback, std::shared_ptr< flutter::ExternalViewEmbedder > view_embedder, fml::TimeDelta vsync_offset, zx_handle_t vsync_event_handle)
 
 ~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...
 
void SetSemanticsEnabled (bool enabled) override
 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...
 
void DispatchSemanticsAction (int32_t node_id, flutter::SemanticsAction action) override
 
flutter::PointerDataDispatcherMaker GetDispatcherMaker () override
 Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPacketDispatcher based on platforms. More...
 
- Public Member Functions inherited from flutter::PlatformView
 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...
 
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...
 
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 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...
 
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...
 
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...
 

Additional Inherited Members

- Protected Attributes inherited from flutter::PlatformView
PlatformView::Delegatedelegate_
 
const TaskRunners task_runners_
 
PointerDataPacketConverter pointer_data_packet_converter_
 
SkISize size_
 
fml::WeakPtrFactory< PlatformViewweak_factory_
 

Detailed Description

Definition at line 45 of file platform_view.h.

Constructor & Destructor Documentation

◆ PlatformView()

flutter_runner::PlatformView::PlatformView ( flutter::PlatformView::Delegate delegate,
std::string  debug_label,
fuchsia::ui::views::ViewRef  view_ref,
flutter::TaskRunners  task_runners,
std::shared_ptr< sys::ServiceDirectory >  runner_services,
fidl::InterfaceHandle< fuchsia::sys::ServiceProvider >  parent_environment_service_provider,
fidl::InterfaceRequest< fuchsia::ui::scenic::SessionListener >  session_listener_request,
fidl::InterfaceHandle< fuchsia::ui::views::Focuser >  focuser,
fit::closure  on_session_listener_error_callback,
OnEnableWireframe  wireframe_enabled_callback,
OnCreateView  on_create_view_callback,
OnUpdateView  on_update_view_callback,
OnDestroyView  on_destroy_view_callback,
OnCreateSurface  on_create_surface_callback,
std::shared_ptr< flutter::ExternalViewEmbedder view_embedder,
fml::TimeDelta  vsync_offset,
zx_handle_t  vsync_event_handle 
)

Definition at line 53 of file platform_view.cc.

References action, args, flutter::PlatformView::DispatchPlatformMessage(), error, event, FML_DCHECK, FML_DLOG, FML_LOG, flutter::TaskRunners::GetUITaskRunner(), flutter_runner::kAccessibilityChannel, flutter_runner::kFlutterPlatformChannel, flutter_runner::kFlutterPlatformViewsChannel, flutter_runner::kTextInputChannel, flutter::SceneHost::OnViewConnected(), flutter::SceneHost::OnViewDisconnected(), flutter::SceneHost::OnViewStateChanged(), fml::TaskRunner::PostTask(), flutter_runner::SetInterfaceErrorHandler(), flutter::PlatformView::SetViewportMetrics(), flutter::PlatformView::task_runners_, TRACE_EVENT0, and ~PlatformView().

73  : flutter::PlatformView(delegate, std::move(task_runners)),
74  debug_label_(std::move(debug_label)),
75  view_ref_(std::move(view_ref)),
76  focuser_(focuser.Bind()),
77  session_listener_binding_(this, std::move(session_listener_request)),
78  session_listener_error_callback_(
79  std::move(session_listener_error_callback)),
80  wireframe_enabled_callback_(std::move(wireframe_enabled_callback)),
81  on_create_view_callback_(std::move(on_create_view_callback)),
82  on_update_view_callback_(std::move(on_update_view_callback)),
83  on_destroy_view_callback_(std::move(on_destroy_view_callback)),
84  on_create_surface_callback_(std::move(on_create_surface_callback)),
85  external_view_embedder_(external_view_embedder),
86  ime_client_(this),
87  vsync_offset_(std::move(vsync_offset)),
88  vsync_event_handle_(vsync_event_handle) {
89  // Register all error handlers.
90  SetInterfaceErrorHandler(session_listener_binding_, "SessionListener");
91  SetInterfaceErrorHandler(ime_, "Input Method Editor");
92  SetInterfaceErrorHandler(text_sync_service_, "Text Sync Service");
93  SetInterfaceErrorHandler(parent_environment_service_provider_,
94  "Parent Environment Service Provider");
95  // Access the IME service.
96  parent_environment_service_provider_ =
97  parent_environment_service_provider_handle.Bind();
98 
99  parent_environment_service_provider_.get()->ConnectToService(
100  fuchsia::ui::input::ImeService::Name_,
101  text_sync_service_.NewRequest().TakeChannel());
102 
103  // Finally! Register the native platform message handlers.
104  RegisterPlatformMessageHandlers();
105 
106  fuchsia::ui::views::ViewRef accessibility_view_ref;
107  view_ref_.Clone(&accessibility_view_ref);
108  accessibility_bridge_ = std::make_unique<AccessibilityBridge>(
109  *this, runner_services, std::move(accessibility_view_ref));
110 }
void SetInterfaceErrorHandler(fidl::InterfacePtr< T > &interface, std::string name)
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:44

◆ ~PlatformView()

flutter_runner::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 from flutter::PlatformView.

Referenced by PlatformView().

Member Function Documentation

◆ DispatchSemanticsAction()

void flutter_runner::PlatformView::DispatchSemanticsAction ( int32_t  node_id,
flutter::SemanticsAction  action 
)
overridevirtual

◆ GetDispatcherMaker()

flutter::PointerDataDispatcherMaker flutter_runner::PlatformView::GetDispatcherMaker ( )
overridevirtual

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

Reimplemented from flutter::PlatformView.

Definition at line 919 of file platform_view.cc.

919  {
921  return std::make_unique<flutter::SmoothPointerDataDispatcher>(delegate);
922  };
923 }
The interface for Engine to implement.

◆ SetSemanticsEnabled()

void flutter_runner::PlatformView::SetSemanticsEnabled ( bool  enabled)
overridevirtual

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 from flutter::PlatformView.

Definition at line 615 of file platform_view.cc.

References flutter::kAccessibleNavigation, flutter::PlatformView::SetAccessibilityFeatures(), and flutter::PlatformView::SetSemanticsEnabled().

615  {
617  if (enabled) {
618  SetAccessibilityFeatures(static_cast<int32_t>(
620  } else {
622  }
623 }
virtual void SetAccessibilityFeatures(int32_t flags)
Used by the embedder to specify the features to enable in the accessibility tree generated by the iso...
virtual void SetSemanticsEnabled(bool enabled)
Used by embedder to notify the running isolate hosted by the engine on the UI thread that the accessi...

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