Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::TesterPlatformView Class Reference
Inheritance diagram for flutter::TesterPlatformView:
flutter::PlatformView flutter::GPUSurfaceSoftwareDelegate

Public Member Functions

 TesterPlatformView (Delegate &delegate, const TaskRunners &task_runners, ImpellerVulkanContextHolder &&impeller_context_holder)
 
 ~TesterPlatformView ()
 
std::shared_ptr< impeller::ContextGetImpellerContext () const override
 
std::unique_ptr< SurfaceCreateRenderingSurface () override
 
sk_sp< SkSurfaceAcquireBackingStore (const SkISize &size) override
 Called when the GPU surface needs a new buffer to render a new frame into.
 
bool PresentBackingStore (sk_sp< SkSurface > backing_store) override
 Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen.
 
std::shared_ptr< ExternalViewEmbedderCreateExternalViewEmbedder () override
 
- Public Member Functions inherited from flutter::PlatformView
 PlatformView (Delegate &delegate, const 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.
 
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.
 
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.
 
void DispatchPlatformMessage (std::unique_ptr< 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.
 
virtual void HandlePlatformMessage (std::unique_ptr< 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.
 
void DispatchSemanticsAction (int32_t node_id, SemanticsAction action, fml::MallocMapping args)
 Used by embedders to dispatch an accessibility action to a running isolate hosted by the engine.
 
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.
 
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.
 
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.
 
virtual void SendChannelUpdate (const std::string &name, bool listening)
 Used by the framework to tell the embedder that it has registered a listener on a given channel.
 
void SetViewportMetrics (int64_t view_id, const ViewportMetrics &metrics)
 Used by embedders to specify the updated viewport metrics for a view. 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.
 
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.
 
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.
 
void ScheduleFrame ()
 Used by embedders to schedule a frame. In response to this call, the framework may need to start generating a new frame.
 
void AddView (int64_t view_id, const ViewportMetrics &viewport_metrics, AddViewCallback callback)
 Used by embedders to notify the shell of a new non-implicit view.
 
void RemoveView (int64_t view_id, RemoveViewCallback callback)
 Used by embedders to notify the shell of a removed non-implicit view.
 
virtual sk_sp< GrDirectContextCreateResourceContext () 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).
 
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.
 
virtual PointerDataDispatcherMaker GetDispatcherMaker ()
 Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPacketDispatcher based on platforms.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
virtual void RequestDartDeferredLibrary (intptr_t loading_unit_id)
 Invoked when the dart VM requests that a deferred library be loaded. Notifies the engine that the deferred library identified by the specified loading unit id should be downloaded and loaded into the Dart VM via LoadDartDeferredLibrary
 
virtual void LoadDartDeferredLibrary (intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions)
 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)
 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)
 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 std::unique_ptr< SnapshotSurfaceProducerCreateSnapshotSurfaceProducer ()
 Creates an object that produces surfaces suitable for raster snapshotting. The rasterizer will request this surface if no on screen surface is currently available when an application requests a snapshot, e.g. if Scene.toImage or Picture.toImage are called while the application is in the background.
 
virtual std::shared_ptr< PlatformMessageHandlerGetPlatformMessageHandler () const
 Specifies a delegate that will receive PlatformMessages from Flutter to the host platform.
 
const SettingsGetSettings () const
 Get the settings for this platform view instance.
 
virtual double GetScaledFontSize (double unscaled_font_size, int configuration_id) const
 Synchronously invokes platform-specific APIs to apply the system text scaling on the given unscaled font size.
 
- Public Member Functions inherited from flutter::GPUSurfaceSoftwareDelegate
 ~GPUSurfaceSoftwareDelegate ()
 

Additional Inherited Members

- Public Types inherited from flutter::PlatformView
using AddViewCallback = std::function< void(bool added)>
 
using RemoveViewCallback = std::function< void(bool removed)>
 
- Protected Attributes inherited from flutter::PlatformView
PlatformView::Delegatedelegate_
 
const TaskRunners task_runners_
 
PointerDataPacketConverter pointer_data_packet_converter_
 
fml::WeakPtrFactory< PlatformViewweak_factory_
 

Detailed Description

Definition at line 188 of file tester_main.cc.

Constructor & Destructor Documentation

◆ TesterPlatformView()

flutter::TesterPlatformView::TesterPlatformView ( Delegate delegate,
const TaskRunners task_runners,
ImpellerVulkanContextHolder &&  impeller_context_holder 
)
inline

Definition at line 191 of file tester_main.cc.

194 : PlatformView(delegate, task_runners),
195 impeller_context_holder_(std::move(impeller_context_holder)) {}
PlatformView(Delegate &delegate, const TaskRunners &task_runners)
Creates a platform view with the specified delegate and task runner. The base class by itself does no...

◆ ~TesterPlatformView()

flutter::TesterPlatformView::~TesterPlatformView ( )
inline

Definition at line 197 of file tester_main.cc.

197 {
198#if ALLOW_IMPELLER
199 if (impeller_context_holder_.context) {
200 impeller_context_holder_.context->Shutdown();
201 }
202#endif
203 }

Member Function Documentation

◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::TesterPlatformView::AcquireBackingStore ( const SkISize size)
inlineoverridevirtual

Called when the GPU surface needs a new buffer to render a new frame into.

Parameters
[in]sizeThe size of the frame.
Returns
A raster surface returned by the platform.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 233 of file tester_main.cc.

233 {
234 if (sk_surface_ != nullptr &&
235 SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
236 // The old and new surface sizes are the same. Nothing to do here.
237 return sk_surface_;
238 }
239
243 sk_surface_ = SkSurfaces::Raster(info, nullptr);
244
245 if (sk_surface_ == nullptr) {
247 << "Could not create backing store for software rendering.";
248 return nullptr;
249 }
250
251 return sk_surface_;
252 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
static sk_sp< SkColorSpace > MakeSRGB()
int width() const
Definition SkSurface.h:178
int height() const
Definition SkSurface.h:184
#define FML_LOG(severity)
Definition logging.h:82
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
#define ERROR(message)

◆ CreateExternalViewEmbedder()

std::shared_ptr< ExternalViewEmbedder > flutter::TesterPlatformView::CreateExternalViewEmbedder ( )
inlineoverridevirtual

Reimplemented from flutter::PlatformView.

Definition at line 260 of file tester_main.cc.

260 {
261 return external_view_embedder_;
262 }

◆ CreateRenderingSurface()

std::unique_ptr< Surface > flutter::TesterPlatformView::CreateRenderingSurface ( )
inlineoverridevirtual

Reimplemented from flutter::PlatformView.

Definition at line 216 of file tester_main.cc.

216 {
217#if ALLOW_IMPELLER
219 FML_DCHECK(impeller_context_holder_.context);
220 auto surface = std::make_unique<GPUSurfaceVulkanImpeller>(
221 impeller_context_holder_.surface_context);
222 FML_DCHECK(surface->IsValid());
223 return surface;
224 }
225#endif // ALLOW_IMPELLER
226 auto surface = std::make_unique<TesterGPUSurfaceSoftware>(
227 this, true /* render to surface */);
228 FML_DCHECK(surface->IsValid());
229 return surface;
230 }
virtual const Settings & OnPlatformViewGetSettings() const =0
Called by the platform view on the platform thread to get the settings object associated with the pla...
PlatformView::Delegate & delegate_
VkSurfaceKHR surface
Definition main.cc:49
#define FML_DCHECK(condition)
Definition logging.h:103

◆ GetImpellerContext()

std::shared_ptr< impeller::Context > flutter::TesterPlatformView::GetImpellerContext ( ) const
inlineoverridevirtual

Reimplemented from flutter::PlatformView.

Definition at line 206 of file tester_main.cc.

206 {
207#if ALLOW_IMPELLER
208 return std::static_pointer_cast<impeller::Context>(
209 impeller_context_holder_.context);
210#else
211 return nullptr;
212#endif // ALLOW_IMPELLER
213 }

◆ PresentBackingStore()

bool flutter::TesterPlatformView::PresentBackingStore ( sk_sp< SkSurface backing_store)
inlineoverridevirtual

Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen.

Parameters
[in]backing_storeThe software backing store to present.
Returns
Returns if the platform could present the backing store onto the screen.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 255 of file tester_main.cc.

255 {
256 return true;
257 }

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