Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
platform_view.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_COMMON_PLATFORM_VIEW_H_
6#define FLUTTER_SHELL_COMMON_PLATFORM_VIEW_H_
7
8#include <functional>
9#include <memory>
10
15#include "flutter/fml/macros.h"
16#include "flutter/fml/mapping.h"
27#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
28
29namespace impeller {
30
31class Context;
32
33} // namespace impeller
34
35namespace flutter {
36
37//------------------------------------------------------------------------------
38/// @brief Platform views are created by the shell on the platform task
39/// runner. Unless explicitly specified, all platform view methods
40/// are called on the platform task runner as well. Platform views
41/// are usually sub-classed on a per platform basis and the bulk of
42/// the window system integration happens using that subclass. Since
43/// most platform window toolkits are usually only safe to access on
44/// a single "main" thread, any interaction that requires access to
45/// the underlying platform's window toolkit is routed through the
46/// platform view associated with that shell. This involves
47/// operations like settings up and tearing down the render surface,
48/// platform messages, interacting with accessibility features on
49/// the platform, input events, etc.
50///
52 public:
53 using AddViewCallback = std::function<void(bool added)>;
54 using RemoveViewCallback = std::function<void(bool removed)>;
55 //----------------------------------------------------------------------------
56 /// @brief Used to forward events from the platform view to interested
57 /// subsystems. This forwarding is done by the shell which sets
58 /// itself up as the delegate of the platform view.
59 ///
60 class Delegate {
61 public:
64 using KeyDataResponse = std::function<void(bool)>;
65 //--------------------------------------------------------------------------
66 /// @brief Notifies the delegate that the platform view was created
67 /// with the given render surface. This surface is platform
68 /// (iOS, Android) and client-rendering API (OpenGL, Software,
69 /// Metal, Vulkan) specific. This is usually a sign to the
70 /// rasterizer to set up and begin rendering to that surface.
71 ///
72 /// @param[in] surface The surface
73 ///
74 virtual void OnPlatformViewCreated(std::unique_ptr<Surface> surface) = 0;
75
76 //--------------------------------------------------------------------------
77 /// @brief Notifies the delegate that the platform view was destroyed.
78 /// This is usually a sign to the rasterizer to suspend
79 /// rendering a previously configured surface and collect any
80 /// intermediate resources.
81 ///
82 virtual void OnPlatformViewDestroyed() = 0;
83
84 //--------------------------------------------------------------------------
85 /// @brief Notifies the delegate that the platform needs to schedule a
86 /// frame to regenerate the layer tree and redraw the surface.
87 ///
88 virtual void OnPlatformViewScheduleFrame() = 0;
89
90 /// @brief Allocate resources for a new non-implicit view and inform
91 /// Dart about the view, and on success, schedules a new frame.
92 ///
93 /// After the operation, |callback| should be invoked with whether
94 /// the operation is successful.
95 ///
96 /// Adding |kFlutterImplicitViewId| or an existing view ID should
97 /// result in failure.
98 ///
99 /// @param[in] view_id The view ID of the new view.
100 /// @param[in] viewport_metrics The initial viewport metrics for the view.
101 /// @param[in] callback The callback that's invoked once the shell
102 /// has attempted to add the view.
103 ///
104 virtual void OnPlatformViewAddView(int64_t view_id,
105 const ViewportMetrics& viewport_metrics,
107
108 /// @brief Deallocate resources for a removed view and inform
109 /// Dart about the removal.
110 ///
111 /// After the operation, |callback| should be invoked with whether
112 /// the operation is successful.
113 ///
114 /// Removing |kFlutterImplicitViewId| or an non-existent view ID
115 /// should result in failure.
116 ///
117 /// @param[in] view_id The view ID of the view to be removed.
118 /// @param[in] callback The callback that's invoked once the shell has
119 /// attempted to remove the view.
120 ///
121 virtual void OnPlatformViewRemoveView(int64_t view_id,
123
124 /// @brief Notify the delegate that platform view focus state has changed.
125 ///
126 /// @param[in] event The focus event describing the change.
128 const ViewFocusEvent& event) = 0;
129
130 //--------------------------------------------------------------------------
131 /// @brief Notifies the delegate that the specified callback needs to
132 /// be invoked after the rasterizer is done rendering the next
133 /// frame. This callback will be called on the render thread and
134 /// it is caller responsibility to perform any re-threading as
135 /// necessary. Due to the asynchronous nature of rendering in
136 /// Flutter, embedders usually add a placeholder over the
137 /// contents in which Flutter is going to render when Flutter is
138 /// first initialized. This callback may be used as a signal to
139 /// remove that placeholder.
140 ///
141 /// @attention The callback will be invoked on the render thread and not
142 /// the calling thread.
143 ///
144 /// @param[in] closure The callback to execute on the next frame.
145 ///
147 const fml::closure& closure) = 0;
148
149 //--------------------------------------------------------------------------
150 /// @brief Notifies the delegate the viewport metrics of a view have
151 /// been updated. The rasterizer will need to be reconfigured to
152 /// render the frame in the updated viewport metrics.
153 ///
154 /// @param[in] view_id The ID for the view that `metrics` describes.
155 /// @param[in] metrics The updated viewport metrics.
156 ///
158 int64_t view_id,
159 const ViewportMetrics& metrics) = 0;
160
161 //--------------------------------------------------------------------------
162 /// @brief Notifies the delegate that the platform has dispatched a
163 /// platform message from the embedder to the Flutter
164 /// application. This message must be forwarded to the running
165 /// isolate hosted by the engine on the UI thread.
166 ///
167 /// @param[in] message The platform message to dispatch to the running
168 /// root isolate.
169 ///
171 std::unique_ptr<PlatformMessage> message) = 0;
172
173 //--------------------------------------------------------------------------
174 /// @brief Notifies the delegate that the platform view has encountered
175 /// a pointer event. This pointer event needs to be forwarded to
176 /// the running root isolate hosted by the engine on the UI
177 /// thread.
178 ///
179 /// @param[in] packet The pointer data packet containing multiple pointer
180 /// events.
181 ///
183 std::unique_ptr<PointerDataPacket> packet) = 0;
184
185 //--------------------------------------------------------------------------
186 /// @brief Requests the delegate to perform framework hit test from the
187 /// engine.
188 /// This API must be called from the UI thread.
189 /// Calling this from the platform thread causes
190 /// undefined behavior if the UI and platform threads
191 /// are not merged.
192 /// @param[in] view_id The identifier of the flutter view that
193 /// should be hit tested.
194 /// @param[in] offset The position in the view that should be hit tested.
195 ///
196 /// @return The hit test response.
197 ///
199 int64_t view_id,
200 const flutter::PointData offset) = 0;
201
202 //--------------------------------------------------------------------------
203 /// @brief Notifies the delegate that the platform view has encountered
204 /// an accessibility related action on the specified node. This
205 /// event must be forwarded to the running root isolate hosted
206 /// by the engine on the UI thread.
207 ///
208 /// @param[in] view_id The identifier of the view that contains this node.
209 /// @param[in] node_id The identifier of the accessibility node.
210 /// @param[in] action The accessibility related action performed on the
211 /// node of the specified ID.
212 /// @param[in] args An optional list of argument that apply to the
213 /// specified action.
214 ///
216 int64_t view_id,
217 int32_t node_id,
220
221 //--------------------------------------------------------------------------
222 /// @brief Notifies the delegate that the embedder has expressed an
223 /// opinion about whether the accessibility tree needs to be
224 /// enabled or disabled. This information needs to be forwarded
225 /// to the root isolate running on the UI thread.
226 ///
227 /// @param[in] enabled Whether the accessibility tree is enabled or
228 /// disabled.
229 ///
230 virtual void OnPlatformViewSetSemanticsEnabled(bool enabled) = 0;
231
232 //--------------------------------------------------------------------------
233 /// @brief Notifies the delegate that the embedder has expressed an
234 /// opinion about the features to enable in the accessibility
235 /// tree.
236 ///
237 /// The engine does not care about the accessibility feature
238 /// flags as all it does is forward this information from the
239 /// embedder to the framework. However, curious readers may
240 /// refer to `AccessibilityFeatures` in `window.dart` for
241 /// currently supported accessibility feature flags.
242 ///
243 /// @param[in] flags The features to enable in the accessibility tree.
244 ///
245 virtual void OnPlatformViewSetAccessibilityFeatures(int32_t flags) = 0;
246
247 //--------------------------------------------------------------------------
248 /// @brief Notifies the delegate that the embedder has specified a
249 /// texture that it want the rasterizer to composite within the
250 /// Flutter layer tree. All textures must have a unique
251 /// identifier. When the rasterizer encounters an external
252 /// texture within its hierarchy, it gives the embedder a chance
253 /// to update that texture on the raster thread before it
254 /// composites the same on-screen.
255 ///
256 /// @param[in] texture The texture that is being updated by the embedder
257 /// but composited by Flutter in its own hierarchy.
258 ///
260 std::shared_ptr<Texture> texture) = 0;
261
262 //--------------------------------------------------------------------------
263 /// @brief Notifies the delegate that the embedder will no longer
264 /// attempt to composite the specified texture within the layer
265 /// tree. This allows the rasterizer to collect associated
266 /// resources.
267 ///
268 /// @param[in] texture_id The identifier of the texture to unregister. If
269 /// the texture has not been previously registered,
270 /// this call does nothing.
271 ///
273
274 //--------------------------------------------------------------------------
275 /// @brief Notifies the delegate that the embedder has updated the
276 /// contents of the texture with the specified identifier.
277 /// Typically, Flutter will only render a frame if there is an
278 /// updated layer tree. However, in cases where the layer tree
279 /// is static but one of the externally composited textures has
280 /// been updated by the embedder, the embedder needs to notify
281 /// the rasterizer to render a new frame. In such cases, the
282 /// existing layer tree may be reused with the frame composited
283 /// with all updated external textures.
284 ///
285 /// @param[in] texture_id The identifier of the texture that has been
286 /// updated.
287 ///
289 int64_t texture_id) = 0;
290
291 //--------------------------------------------------------------------------
292 /// @brief Loads the dart shared library into the dart VM. When the
293 /// dart library is loaded successfully, the dart future
294 /// returned by the originating loadLibrary() call completes.
295 ///
296 /// The Dart compiler may generate separate shared libraries
297 /// files called 'loading units' when libraries are imported
298 /// as deferred. Each of these shared libraries are identified
299 /// by a unique loading unit id. Callers should open and resolve
300 /// a SymbolMapping from the shared library. The Mappings should
301 /// be moved into this method, as ownership will be assumed by
302 /// the dart root isolate after successful loading and released
303 /// after shutdown of the root isolate. The loading unit may not
304 /// be used after isolate shutdown. If loading fails, the
305 /// mappings will be released.
306 ///
307 /// This method is paired with a RequestDartDeferredLibrary
308 /// invocation that provides the embedder with the loading unit
309 /// id of the deferred library to load.
310 ///
311 ///
312 /// @param[in] loading_unit_id The unique id of the deferred library's
313 /// loading unit.
314 ///
315 /// @param[in] snapshot_data Dart snapshot data of the loading unit's
316 /// shared library.
317 ///
318 /// @param[in] snapshot_data Dart snapshot instructions of the loading
319 /// unit's shared library.
320 ///
322 intptr_t loading_unit_id,
323 std::unique_ptr<const fml::Mapping> snapshot_data,
324 std::unique_ptr<const fml::Mapping> snapshot_instructions) = 0;
325
326 //--------------------------------------------------------------------------
327 /// @brief Indicates to the dart VM that the request to load a deferred
328 /// library with the specified loading unit id has failed.
329 ///
330 /// The dart future returned by the initiating loadLibrary()
331 /// call will complete with an error.
332 ///
333 /// @param[in] loading_unit_id The unique id of the deferred library's
334 /// loading unit, as passed in by
335 /// RequestDartDeferredLibrary.
336 ///
337 /// @param[in] error_message The error message that will appear in the
338 /// dart Future.
339 ///
340 /// @param[in] transient A transient error is a failure due to
341 /// temporary conditions such as no network.
342 /// Transient errors allow the dart VM to
343 /// re-request the same deferred library and
344 /// loading_unit_id again. Non-transient
345 /// errors are permanent and attempts to
346 /// re-request the library will instantly
347 /// complete with an error.
348 virtual void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
349 const std::string error_message,
350 bool transient) = 0;
351
352 //--------------------------------------------------------------------------
353 /// @brief Replaces the asset resolver handled by the engine's
354 /// AssetManager of the specified `type` with
355 /// `updated_asset_resolver`. The matching AssetResolver is
356 /// removed and replaced with `updated_asset_resolvers`.
357 ///
358 /// AssetResolvers should be updated when the existing resolver
359 /// becomes obsolete and a newer one becomes available that
360 /// provides updated access to the same type of assets as the
361 /// existing one. This update process is meant to be performed
362 /// at runtime.
363 ///
364 /// If a null resolver is provided, nothing will be done. If no
365 /// matching resolver is found, the provided resolver will be
366 /// added to the end of the AssetManager resolvers queue. The
367 /// replacement only occurs with the first matching resolver.
368 /// Any additional matching resolvers are untouched.
369 ///
370 /// @param[in] updated_asset_resolver The asset resolver to replace the
371 /// resolver of matching type with.
372 ///
373 /// @param[in] type The type of AssetResolver to update. Only resolvers of
374 /// the specified type will be replaced by the updated
375 /// resolver.
376 ///
378 std::unique_ptr<AssetResolver> updated_asset_resolver,
380
381 //--------------------------------------------------------------------------
382 /// @brief Called by the platform view on the platform thread to get
383 /// the settings object associated with the platform view
384 /// instance.
385 ///
386 /// @return The settings.
387 ///
388 virtual const Settings& OnPlatformViewGetSettings() const = 0;
389
390 //--------------------------------------------------------------------------
391 /// @brief Returns a task runner that executes tasks on the IO thread
392 /// and stops running tasks after the shell shuts down the IO
393 /// thread.
394 ///
395 /// @return The task runner.
396 ///
397 virtual std::shared_ptr<fml::BasicTaskRunner>
399 };
400
401 //----------------------------------------------------------------------------
402 /// @brief Creates a platform view with the specified delegate and task
403 /// runner. The base class by itself does not do much but is
404 /// suitable for use in test environments where full platform
405 /// integration may not be necessary. The platform view may only
406 /// be created, accessed and destroyed on the platform task
407 /// runner.
408 ///
409 /// @param delegate The delegate. This is typically the shell.
410 /// @param[in] task_runners The task runners used by this platform view.
411 ///
412 explicit PlatformView(Delegate& delegate, const TaskRunners& task_runners);
413
414 //----------------------------------------------------------------------------
415 /// @brief Destroys the platform view. The platform view is owned by the
416 /// shell and will be destroyed by the same on the platform tasks
417 /// runner.
418 ///
419 virtual ~PlatformView();
420
421 //----------------------------------------------------------------------------
422 /// @brief Invoked by the shell to obtain a platform specific vsync
423 /// waiter. It is optional for platforms to override this method
424 /// and provide a custom vsync waiter because a timer based
425 /// fall-back waiter is used by default. However, it is highly
426 /// recommended that platform provide their own Vsync waiter as
427 /// the timer based fall-back will not render frames aligned with
428 /// vsync boundaries.
429 ///
430 /// @attention If a timer based fall-back is used, a warning is logged to the
431 /// console. In case this method is overridden in a subclass, it
432 /// must return a valid vsync waiter. Returning null will lead to
433 /// internal errors. If a valid vsync waiter cannot be returned,
434 /// subclasses should just call the based class method instead.
435 ///
436 /// @return A vsync waiter. If is an internal error to return a null
437 /// waiter.
438 ///
439 virtual std::unique_ptr<VsyncWaiter> CreateVSyncWaiter();
440
441 //----------------------------------------------------------------------------
442 /// @brief Used by embedders to dispatch a platform message to a
443 /// running root isolate hosted by the engine. If an isolate is
444 /// not running, the message is dropped. If there is no one on the
445 /// other side listening on the channel, the message is dropped.
446 /// When a platform message is dropped, any response handles
447 /// associated with that message will be dropped as well. All
448 /// users of platform messages must assume that message may not be
449 /// delivered and/or their response handles may not be invoked.
450 /// Platform messages are not buffered.
451 ///
452 /// For embedders that wish to respond to platform message
453 /// directed from the framework to the embedder, the
454 /// `HandlePlatformMessage` method may be overridden.
455 ///
456 /// @see HandlePlatformMessage()
457 ///
458 /// @param[in] message The platform message to deliver to the root isolate.
459 ///
460 void DispatchPlatformMessage(std::unique_ptr<PlatformMessage> message);
461
462 //----------------------------------------------------------------------------
463 /// @brief Overridden by embedders to perform actions in response to
464 /// platform messages sent from the framework to the embedder.
465 /// Default implementation of this method simply returns an empty
466 /// response.
467 ///
468 /// Embedders that wish to send platform messages to the framework
469 /// may use the `DispatchPlatformMessage` method. This method is
470 /// for messages that go the other way.
471 ///
472 /// @see DispatchPlatformMessage()
473 ///
474 /// @param[in] message The message
475 ///
476 virtual void HandlePlatformMessage(std::unique_ptr<PlatformMessage> message);
477
478 //----------------------------------------------------------------------------
479 /// @brief Used by embedders to dispatch an accessibility action to a
480 /// running isolate hosted by the engine.
481 ///
482 /// @param[in] view_id The identifier of the view.
483 /// @param[in] node_id The identifier of the accessibility node on which to
484 /// perform the action.
485 /// @param[in] action The action
486 /// @param[in] args The arguments
487 ///
488 void DispatchSemanticsAction(int64_t view_id,
489 int32_t node_id,
492
493 //----------------------------------------------------------------------------
494 /// @brief Used by embedder to notify the running isolate hosted by the
495 /// engine on the UI thread that the accessibility tree needs to
496 /// be generated.
497 ///
498 /// @attention Subclasses may choose to override this method to perform
499 /// platform specific functions. However, they must call the base
500 /// class method at some point in their implementation.
501 ///
502 /// @param[in] enabled Whether the accessibility tree needs to be generated.
503 ///
504 virtual void SetSemanticsEnabled(bool enabled);
505
506 //----------------------------------------------------------------------------
507 /// @brief Used by the embedder to specify the features to enable in the
508 /// accessibility tree generated by the isolate. This information
509 /// is forwarded to the root isolate hosted by the engine on the
510 /// UI thread.
511 ///
512 /// The engine does not care about the accessibility feature flags
513 /// as all it does is forward this information from the embedder
514 /// to the framework. However, curious readers may refer to
515 /// `AccessibilityFeatures` in `window.dart` for currently
516 /// supported accessibility feature flags.
517 ///
518 /// @attention Subclasses may choose to override this method to perform
519 /// platform specific functions. However, they must call the base
520 /// class method at some point in their implementation.
521 ///
522 /// @param[in] flags The features to enable in the accessibility tree.
523 ///
524 virtual void SetAccessibilityFeatures(int32_t flags);
525
526 //----------------------------------------------------------------------------
527 /// @brief Used by the framework to tell the embedder to apply the
528 /// specified semantics node updates. The default implementation
529 /// of this method does nothing.
530 ///
531 /// @see SemanticsNode, SemticsNodeUpdates,
532 /// CustomAccessibilityActionUpdates
533 ///
534 /// @param[in] view_id The ID of the view that this update is for
535 /// @param[in] updates A map with the stable semantics node identifier as
536 /// key and the node properties as the value.
537 /// @param[in] actions A map with the stable semantics node identifier as
538 /// key and the custom node action as the value.
539 ///
540 virtual void UpdateSemantics(int64_t view_id,
541 SemanticsNodeUpdates updates,
543
544 //----------------------------------------------------------------------------
545 /// @brief Used by the framework to set application locale in the
546 /// embedding
547 ///
548 /// @param[in] locale The application locale in BCP 47 format.
549 ///
550 virtual void SetApplicationLocale(std::string locale);
551
552 //----------------------------------------------------------------------------
553 /// @brief Used by the framework to tell the embedder to prepare or clear
554 /// resoruce for accepting semantics tree.
555 ///
556 /// @param[in] enabled whether framework starts or stops sending semantics
557 /// updates
558 ///
559 virtual void SetSemanticsTreeEnabled(bool enabled);
560
561 //----------------------------------------------------------------------------
562 /// @brief Used by the framework to tell the embedder that it has
563 /// registered a listener on a given channel.
564 ///
565 /// @param[in] name The name of the channel on which the listener has
566 /// set or cleared a listener.
567 /// @param[in] listening True if a listener has been set, false if it has
568 /// been cleared.
569 ///
570 virtual void SendChannelUpdate(const std::string& name, bool listening);
571
572 //----------------------------------------------------------------------------
573 /// @brief Used by embedders to specify the updated viewport metrics for
574 /// a view. In response to this call, on the raster thread, the
575 /// rasterizer may need to be reconfigured to the updated viewport
576 /// dimensions. On the UI thread, the framework may need to start
577 /// generating a new frame for the updated viewport metrics as
578 /// well.
579 ///
580 /// @param[in] view_id The ID for the view that `metrics` describes.
581 /// @param[in] metrics The updated viewport metrics.
582 ///
583 void SetViewportMetrics(int64_t view_id, const ViewportMetrics& metrics);
584
585 //----------------------------------------------------------------------------
586 /// @brief Used by embedders to notify the shell that a platform view
587 /// has been created. This notification is used to create a
588 /// rendering surface and pick the client rendering API to use to
589 /// render into this surface. No frames will be scheduled or
590 /// rendered before this call. The surface must remain valid till
591 /// the corresponding call to NotifyDestroyed.
592 ///
593 void NotifyCreated();
594
595 //----------------------------------------------------------------------------
596 /// @brief Used by embedders to notify the shell that the platform view
597 /// has been destroyed. This notification used to collect the
598 /// rendering surface and all associated resources. Frame
599 /// scheduling is also suspended.
600 ///
601 /// @attention Subclasses may choose to override this method to perform
602 /// platform specific functions. However, they must call the base
603 /// class method at some point in their implementation.
604 ///
605 virtual void NotifyDestroyed();
606
607 //----------------------------------------------------------------------------
608 /// @brief Used by embedders to schedule a frame. In response to this
609 /// call, the framework may need to start generating a new frame.
610 ///
611 void ScheduleFrame();
612
613 /// @brief Used by embedders to notify the shell of a new non-implicit view.
614 ///
615 /// This method notifies the shell to allocate resources and inform
616 /// Dart about the view, and on success, schedules a new frame.
617 /// Finally, it invokes |callback| with whether the operation is
618 /// successful.
619 ///
620 /// This operation is asynchronous; avoid using the view until
621 /// |callback| returns true. Callers should prepare resources for the
622 /// view (if any) in advance but be ready to clean up on failure.
623 ///
624 /// The callback is called on a different thread.
625 ///
626 /// Do not use for implicit views, which are added internally during
627 /// shell initialization. Adding |kFlutterImplicitViewId| or an
628 /// existing view ID will fail, indicated by |callback| returning
629 /// false.
630 ///
631 /// @param[in] view_id The view ID of the new view.
632 /// @param[in] viewport_metrics The initial viewport metrics for the view.
633 /// @param[in] callback The callback that's invoked once the shell
634 /// has attempted to add the view.
635 ///
636 void AddView(int64_t view_id,
637 const ViewportMetrics& viewport_metrics,
639
640 /// @brief Used by embedders to notify the shell of a removed non-implicit
641 /// view.
642 ///
643 /// This method notifies the shell to deallocate resources and inform
644 /// Dart about the removal. Finally, it invokes |callback| with
645 /// whether the operation is successful.
646 ///
647 /// This operation is asynchronous. The embedder should not deallocate
648 /// resources until the |callback| is invoked.
649 ///
650 /// The callback is called on a different thread.
651 ///
652 /// Do not use for implicit views, which are never removed throughout
653 /// the lifetime of the app.
654 /// Removing |kFlutterImplicitViewId| or an
655 /// non-existent view ID will fail, indicated by |callback| returning
656 /// false.
657 ///
658 /// @param[in] view_id The view ID of the view to be removed.
659 /// @param[in] callback The callback that's invoked once the shell has
660 /// attempted to remove the view.
661 ///
663
664 void SendViewFocusEvent(const ViewFocusEvent& event);
665
666 //----------------------------------------------------------------------------
667 /// @brief Used by the shell to obtain a Skia GPU context that is capable
668 /// of operating on the IO thread. The context must be in the same
669 /// share-group as the Skia GPU context used on the render thread.
670 /// This context will always be used on the IO thread. Because it
671 /// is in the same share-group as the separate render thread
672 /// context, any GPU resources uploaded in this context will be
673 /// visible to the render thread context (synchronization of GPU
674 /// resources is managed by Skia).
675 ///
676 /// If such context cannot be created on the IO thread, callers
677 /// may return `nullptr`. This will mean that all texture uploads
678 /// will be queued onto the render thread which will cause
679 /// performance issues. When this context is `nullptr`, an error
680 /// is logged to the console. It is highly recommended that all
681 /// platforms provide a resource context.
682 ///
683 /// @attention Unlike all other methods on the platform view, this will be
684 /// called on IO task runner.
685 ///
686 /// @return The Skia GPU context that is in the same share-group as the
687 /// main render thread GPU context. May be `nullptr` in case such
688 /// a context cannot be created.
689 ///
690 virtual sk_sp<GrDirectContext> CreateResourceContext() const;
691
692 virtual std::shared_ptr<impeller::Context> GetImpellerContext() const;
693
694 //----------------------------------------------------------------------------
695 /// @brief Used by the shell to notify the embedder that the resource
696 /// context previously obtained via a call to
697 /// `CreateResourceContext()` is being collected. The embedder
698 /// is free to collect an platform specific resources
699 /// associated with this context.
700 ///
701 /// @attention Unlike all other methods on the platform view, this will be
702 /// called on IO task runner.
703 ///
704 virtual void ReleaseResourceContext() const;
705
706 //--------------------------------------------------------------------------
707 /// @brief Returns a platform-specific PointerDataDispatcherMaker so the
708 /// `Engine` can construct the PointerDataPacketDispatcher based
709 /// on platforms.
711
712 //----------------------------------------------------------------------------
713 /// @brief Returns a weak pointer to the platform view. Since the
714 /// platform view may only be created, accessed and destroyed
715 /// on the platform thread, any access to the platform view
716 /// from a non-platform task runner needs a weak pointer to
717 /// the platform view along with a reference to the platform
718 /// task runner. A task must be posted to the platform task
719 /// runner with the weak pointer captured in the same. The
720 /// platform view method may only be called in the posted task
721 /// once the weak pointer validity has been checked. This
722 /// method is used by callers to obtain that weak pointer.
723 ///
724 /// @return The weak pointer to the platform view.
725 ///
727
728 //----------------------------------------------------------------------------
729 /// @brief Gives embedders a chance to react to a "cold restart" of the
730 /// running isolate. The default implementation of this method
731 /// does nothing.
732 ///
733 /// While a "hot restart" patches a running isolate, a "cold
734 /// restart" restarts the root isolate in a running shell.
735 ///
736 virtual void OnPreEngineRestart() const;
737
738 //----------------------------------------------------------------------------
739 /// @brief Sets a callback that gets executed when the rasterizer renders
740 /// the next frame. Due to the asynchronous nature of
741 /// rendering in Flutter, embedders usually add a placeholder
742 /// over the contents in which Flutter is going to render when
743 /// Flutter is first initialized. This callback may be used as
744 /// a signal to remove that placeholder. The callback is
745 /// executed on the render task runner and not the platform
746 /// task runner. It is the embedder's responsibility to
747 /// re-thread as necessary.
748 ///
749 /// @attention The callback is executed on the render task runner and not the
750 /// platform task runner. Embedders must re-thread as necessary.
751 ///
752 /// @param[in] closure The callback to execute on the render thread when the
753 /// next frame gets rendered.
754 ///
755 void SetNextFrameCallback(const fml::closure& closure);
756
757 //----------------------------------------------------------------------------
758 /// @brief Dispatches pointer events from the embedder to the
759 /// framework. Each pointer data packet may contain multiple
760 /// pointer input events. Each call to this method wakes up
761 /// the UI thread.
762 ///
763 /// @param[in] packet The pointer data packet to dispatch to the framework.
764 ///
765 void DispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet);
766
767 //----------------------------------------------------------------------------
768 /// @brief Requests to perform framework hit test from the engine.
769 ///
770 /// @param[in] view_id The identifier of the flutter view that
771 /// should be hit tested.
772 /// @param[in] offset The position in the view that should be hit tested.
773 ///
774 /// @return The hit test response.
775 ///
776 HitTestResponse HitTest(int64_t view_id, const flutter::PointData offset);
777
778 //--------------------------------------------------------------------------
779 /// @brief Used by the embedder to specify a texture that it wants the
780 /// rasterizer to composite within the Flutter layer tree. All
781 /// textures must have a unique identifier. When the
782 /// rasterizer encounters an external texture within its
783 /// hierarchy, it gives the embedder a chance to update that
784 /// texture on the raster thread before it composites the same
785 /// on-screen.
786 ///
787 /// @attention This method must only be called once per texture. When the
788 /// texture is updated, calling `MarkTextureFrameAvailable`
789 /// with the specified texture identifier is sufficient to
790 /// make Flutter re-render the frame with the updated texture
791 /// composited in-line.
792 ///
793 /// @see UnregisterTexture, MarkTextureFrameAvailable
794 ///
795 /// @param[in] texture The texture that is being updated by the embedder
796 /// but composited by Flutter in its own hierarchy.
797 ///
798 void RegisterTexture(std::shared_ptr<flutter::Texture> texture);
799
800 //--------------------------------------------------------------------------
801 /// @brief Used by the embedder to notify the rasterizer that it will
802 /// no longer attempt to composite the specified texture within
803 /// the layer tree. This allows the rasterizer to collect
804 /// associated resources.
805 ///
806 /// @attention This call must only be called once per texture identifier.
807 ///
808 /// @see RegisterTexture, MarkTextureFrameAvailable
809 ///
810 /// @param[in] texture_id The identifier of the texture to unregister. If
811 /// the texture has not been previously registered,
812 /// this call does nothing.
813 ///
814 void UnregisterTexture(int64_t texture_id);
815
816 //--------------------------------------------------------------------------
817 /// @brief Used by the embedder to notify the rasterizer that the context
818 /// of the previously registered texture have been updated.
819 /// Typically, Flutter will only render a frame if there is an
820 /// updated layer tree. However, in cases where the layer tree
821 /// is static but one of the externally composited textures
822 /// has been updated by the embedder, the embedder needs to
823 /// notify the rasterizer to render a new frame. In such
824 /// cases, the existing layer tree may be reused with the
825 /// frame re-composited with all updated external textures.
826 /// Unlike the calls to register and unregister the texture,
827 /// this call must be made each time a new texture frame is
828 /// available.
829 ///
830 /// @see RegisterTexture, UnregisterTexture
831 ///
832 /// @param[in] texture_id The identifier of the texture that has been
833 /// updated.
834 ///
836
837 //--------------------------------------------------------------------------
838 /// @brief Directly invokes platform-specific APIs to compute the
839 /// locale the platform would have natively resolved to.
840 ///
841 /// @param[in] supported_locale_data The vector of strings that represents
842 /// the locales supported by the app.
843 /// Each locale consists of three
844 /// strings: languageCode, countryCode,
845 /// and scriptCode in that order.
846 ///
847 /// @return A vector of 3 strings languageCode, countryCode, and
848 /// scriptCode that represents the locale selected by the
849 /// platform. Empty strings mean the value was unassigned. Empty
850 /// vector represents a null locale.
851 ///
852 virtual std::unique_ptr<std::vector<std::string>>
854 const std::vector<std::string>& supported_locale_data);
855
856 virtual std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder();
857
858 //--------------------------------------------------------------------------
859 /// @brief Invoked when the dart VM requests that a deferred library
860 /// be loaded. Notifies the engine that the deferred library
861 /// identified by the specified loading unit id should be
862 /// downloaded and loaded into the Dart VM via
863 /// `LoadDartDeferredLibrary`
864 ///
865 /// Upon encountering errors or otherwise failing to load a
866 /// loading unit with the specified id, the failure should be
867 /// directly reported to dart by calling
868 /// `LoadDartDeferredLibraryFailure` to ensure the waiting dart
869 /// future completes with an error.
870 ///
871 /// @param[in] loading_unit_id The unique id of the deferred library's
872 /// loading unit. This id is to be passed
873 /// back into LoadDartDeferredLibrary
874 /// in order to identify which deferred
875 /// library to load.
876 ///
877 virtual void RequestDartDeferredLibrary(intptr_t loading_unit_id);
878
879 //--------------------------------------------------------------------------
880 /// @brief Loads the Dart shared library into the Dart VM. When the
881 /// Dart library is loaded successfully, the Dart future
882 /// returned by the originating loadLibrary() call completes.
883 ///
884 /// The Dart compiler may generate separate shared libraries
885 /// files called 'loading units' when libraries are imported
886 /// as deferred. Each of these shared libraries are identified
887 /// by a unique loading unit id. Callers should open and resolve
888 /// a SymbolMapping from the shared library. The Mappings should
889 /// be moved into this method, as ownership will be assumed by the
890 /// dart isolate after successful loading and released after
891 /// shutdown of the dart isolate. If loading fails, the mappings
892 /// will naturally go out of scope.
893 ///
894 /// This method is paired with a RequestDartDeferredLibrary
895 /// invocation that provides the embedder with the loading unit id
896 /// of the deferred library to load.
897 ///
898 ///
899 /// @param[in] loading_unit_id The unique id of the deferred library's
900 /// loading unit, as passed in by
901 /// RequestDartDeferredLibrary.
902 ///
903 /// @param[in] snapshot_data Dart snapshot data of the loading unit's
904 /// shared library.
905 ///
906 /// @param[in] snapshot_data Dart snapshot instructions of the loading
907 /// unit's shared library.
908 ///
909 virtual void LoadDartDeferredLibrary(
910 intptr_t loading_unit_id,
911 std::unique_ptr<const fml::Mapping> snapshot_data,
912 std::unique_ptr<const fml::Mapping> snapshot_instructions);
913
914 //--------------------------------------------------------------------------
915 /// @brief Indicates to the dart VM that the request to load a deferred
916 /// library with the specified loading unit id has failed.
917 ///
918 /// The dart future returned by the initiating loadLibrary() call
919 /// will complete with an error.
920 ///
921 /// @param[in] loading_unit_id The unique id of the deferred library's
922 /// loading unit, as passed in by
923 /// RequestDartDeferredLibrary.
924 ///
925 /// @param[in] error_message The error message that will appear in the
926 /// dart Future.
927 ///
928 /// @param[in] transient A transient error is a failure due to
929 /// temporary conditions such as no network.
930 /// Transient errors allow the dart VM to
931 /// re-request the same deferred library and
932 /// loading_unit_id again. Non-transient
933 /// errors are permanent and attempts to
934 /// re-request the library will instantly
935 /// complete with an error.
936 ///
937 virtual void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
938 const std::string error_message,
939 bool transient);
940
941 //--------------------------------------------------------------------------
942 /// @brief Replaces the asset resolver handled by the engine's
943 /// AssetManager of the specified `type` with
944 /// `updated_asset_resolver`. The matching AssetResolver is
945 /// removed and replaced with `updated_asset_resolvers`.
946 ///
947 /// AssetResolvers should be updated when the existing resolver
948 /// becomes obsolete and a newer one becomes available that
949 /// provides updated access to the same type of assets as the
950 /// existing one. This update process is meant to be performed
951 /// at runtime.
952 ///
953 /// If a null resolver is provided, nothing will be done. If no
954 /// matching resolver is found, the provided resolver will be
955 /// added to the end of the AssetManager resolvers queue. The
956 /// replacement only occurs with the first matching resolver.
957 /// Any additional matching resolvers are untouched.
958 ///
959 /// @param[in] updated_asset_resolver The asset resolver to replace the
960 /// resolver of matching type with.
961 ///
962 /// @param[in] type The type of AssetResolver to update. Only resolvers of
963 /// the specified type will be replaced by the updated
964 /// resolver.
965 ///
966 virtual void UpdateAssetResolverByType(
967 std::unique_ptr<AssetResolver> updated_asset_resolver,
969
970 //--------------------------------------------------------------------------
971 /// @brief Creates an object that produces surfaces suitable for raster
972 /// snapshotting. The rasterizer will request this surface if no
973 /// on screen surface is currently available when an application
974 /// requests a snapshot, e.g. if `Scene.toImage` or
975 /// `Picture.toImage` are called while the application is in the
976 /// background.
977 ///
978 /// Not all backends support this kind of surface usage, and the
979 /// default implementation returns nullptr. Platforms should
980 /// override this if they can support GPU operations in the
981 /// background and support GPU resource context usage.
982 ///
983 virtual std::unique_ptr<SnapshotSurfaceProducer>
985
986 //--------------------------------------------------------------------------
987 /// @brief Specifies a delegate that will receive PlatformMessages from
988 /// Flutter to the host platform.
989 ///
990 /// @details If this returns `null` that means PlatformMessages should be sent
991 /// to the PlatformView. That is to protect legacy behavior, any embedder
992 /// that wants to support executing Platform Channel handlers on background
993 /// threads should be returning a thread-safe PlatformMessageHandler instead.
994 virtual std::shared_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
995 const;
996
997 //----------------------------------------------------------------------------
998 /// @brief Get the settings for this platform view instance.
999 ///
1000 /// @return The settings.
1001 ///
1002 const Settings& GetSettings() const;
1003
1004 //--------------------------------------------------------------------------
1005 /// @brief Synchronously invokes platform-specific APIs to apply the
1006 /// system text scaling on the given unscaled font size.
1007 ///
1008 /// Platforms that support this feature (currently it's only
1009 /// implemented for Android SDK level 34+) will send a valid
1010 /// configuration_id to potential callers, before this method can
1011 /// be called.
1012 ///
1013 /// @param[in] unscaled_font_size The unscaled font size specified by the
1014 /// app developer. The value is in logical
1015 /// pixels, and is guaranteed to be finite and
1016 /// non-negative.
1017 /// @param[in] configuration_id The unique id of the configuration to use
1018 /// for computing the scaled font size.
1019 ///
1020 /// @return The scaled font size in logical pixels, or -1 if the given
1021 /// configuration_id did not match a valid configuration.
1022 ///
1023 virtual double GetScaledFontSize(double unscaled_font_size,
1024 int configuration_id) const;
1025
1026 //--------------------------------------------------------------------------
1027 /// @brief Notifies the client that the Flutter view focus state has
1028 /// changed and the platform view should be updated.
1029 ///
1030 /// Called on platform thread.
1031 ///
1032 /// @param[in] request The request to change the focus state of the view.
1033 virtual void RequestViewFocusChange(const ViewFocusChangeRequest& request);
1034
1035 //--------------------------------------------------------------------------
1036 /// @brief Performs any deferred setup of the Impeller context
1037 ///
1038 /// This is intended to be called from the raster thread so that
1039 /// Impeller context creation can be moved off the startup path.
1040 virtual void SetupImpellerContext() {}
1041
1042 protected:
1043 // This is the only method called on the raster task runner.
1044 virtual std::unique_ptr<Surface> CreateRenderingSurface();
1045
1049
1050 private:
1052};
1053
1054} // namespace flutter
1055
1056#endif // FLUTTER_SHELL_COMMON_PLATFORM_VIEW_H_
AssetResolverType
Identifies the type of AssetResolver an instance is.
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
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,...
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...
virtual void OnPlatformViewDispatchSemanticsAction(int64_t view_id, 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 s...
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_a...
virtual void OnPlatformViewUnregisterTexture(int64_t texture_id)=0
Notifies the delegate that the embedder will no longer attempt to composite the specified texture wit...
virtual HitTestResponse OnPlatformViewHitTest(int64_t view_id, const flutter::PointData offset)=0
Requests the delegate to perform framework hit test from the engine. This API must be called from the...
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...
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...
virtual std::shared_ptr< fml::BasicTaskRunner > OnPlatformViewGetShutdownSafeIOTaskRunner() const =0
Returns a task runner that executes tasks on the IO thread and stops running tasks after the shell sh...
virtual void OnPlatformViewRemoveView(int64_t view_id, RemoveViewCallback callback)=0
Deallocate resources for a removed view and inform Dart about the removal.
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 b...
virtual void OnPlatformViewSetAccessibilityFeatures(int32_t flags)=0
Notifies the delegate that the embedder has expressed an opinion about the features to enable in the ...
virtual void OnPlatformViewSendViewFocusEvent(const ViewFocusEvent &event)=0
Notify the delegate that platform view focus state has changed.
virtual void OnPlatformViewSetSemanticsEnabled(bool enabled)=0
Notifies the delegate that the embedder has expressed an opinion about whether the accessibility tree...
virtual void OnPlatformViewCreated(std::unique_ptr< Surface > surface)=0
Notifies the delegate that the platform view was created with the given render surface....
virtual const Settings & OnPlatformViewGetSettings() const =0
Called by the platform view on the platform thread to get the settings object associated with the pla...
std::function< void(bool)> KeyDataResponse
virtual void OnPlatformViewScheduleFrame()=0
Notifies the delegate that the platform needs to schedule a frame to regenerate the layer tree and re...
PlatformView::AddViewCallback AddViewCallback
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,...
virtual void OnPlatformViewDestroyed()=0
Notifies the delegate that the platform view was destroyed. This is usually a sign to the rasterizer ...
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 ...
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 Fl...
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::RemoveViewCallback RemoveViewCallback
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
virtual void NotifyDestroyed()
Used by embedders to notify the shell that the platform view has been destroyed. This notification us...
virtual void RequestViewFocusChange(const ViewFocusChangeRequest &request)
Notifies the client that the Flutter view focus state has changed and the platform view should be upd...
std::function< void(bool removed)> RemoveViewCallback
void SetNextFrameCallback(const fml::closure &closure)
Sets a callback that gets executed when the rasterizer renders the next frame. Due to the asynchronou...
virtual void SetSemanticsEnabled(bool enabled)
Used by embedder to notify the running isolate hosted by the engine on the UI thread that the accessi...
virtual std::shared_ptr< PlatformMessageHandler > GetPlatformMessageHandler() const
Specifies a delegate that will receive PlatformMessages from Flutter to the host platform.
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 Flutte...
virtual void HandlePlatformMessage(std::unique_ptr< PlatformMessage > message)
Overridden by embedders to perform actions in response to platform messages sent from the framework t...
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....
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 f...
void DispatchSemanticsAction(int64_t view_id, 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 ~PlatformView()
Destroys the platform view. The platform view is owned by the shell and will be destroyed by the same...
virtual PointerDataDispatcherMaker GetDispatcherMaker()
Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPac...
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,...
virtual void SetSemanticsTreeEnabled(bool enabled)
Used by the framework to tell the embedder to prepare or clear resoruce for accepting semantics tree.
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,...
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_a...
const Settings & GetSettings() const
Get the settings for this platform view instance.
std::function< void(bool added)> AddViewCallback
virtual void SetApplicationLocale(std::string locale)
Used by the framework to set application locale in the embedding.
void DispatchPlatformMessage(std::unique_ptr< PlatformMessage > message)
Used by embedders to dispatch a platform message to a running root isolate hosted by the engine....
PlatformView::Delegate & delegate_
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 resolv...
HitTestResponse HitTest(int64_t view_id, const flutter::PointData offset)
Requests to perform framework hit test from the engine.
void NotifyCreated()
Used by embedders to notify the shell that a platform view has been created. This notification is use...
fml::WeakPtr< PlatformView > GetWeakPtr() const
Returns a weak pointer to the platform view. Since the platform view may only be created,...
virtual std::unique_ptr< SnapshotSurfaceProducer > CreateSnapshotSurfaceProducer()
Creates an object that produces surfaces suitable for raster snapshotting. The rasterizer will reques...
virtual void SetupImpellerContext()
Performs any deferred setup of the Impeller context.
void UnregisterTexture(int64_t texture_id)
Used by the embedder to notify the rasterizer that it will no longer attempt to composite the specifi...
virtual std::shared_ptr< ExternalViewEmbedder > CreateExternalViewEmbedder()
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 ...
virtual void OnPreEngineRestart() const
Gives embedders a chance to react to a "cold restart" of the running isolate. The default implementat...
virtual void ReleaseResourceContext() const
Used by the shell to notify the embedder that the resource context previously obtained via a call 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 def...
virtual std::unique_ptr< VsyncWaiter > CreateVSyncWaiter()
Invoked by the shell to obtain a platform specific vsync waiter. It is optional for platforms to over...
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 std::unique_ptr< Surface > CreateRenderingSurface()
virtual std::shared_ptr< impeller::Context > GetImpellerContext() const
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.
virtual void UpdateSemantics(int64_t view_id, SemanticsNodeUpdates updates, CustomAccessibilityActionUpdates actions)
Used by the framework to tell the embedder to apply the specified semantics node updates....
void SendViewFocusEvent(const ViewFocusEvent &event)
fml::WeakPtrFactory< PlatformView > weak_factory_
void DispatchPointerDataPacket(std::unique_ptr< PointerDataPacket > packet)
Dispatches pointer events from the embedder to the framework. Each pointer data packet may contain mu...
void RemoveView(int64_t view_id, RemoveViewCallback callback)
Used by embedders to notify the shell of a removed non-implicit view.
void ScheduleFrame()
Used by embedders to schedule a frame. In response to this call, the framework may need to start gene...
void MarkTextureFrameAvailable(int64_t texture_id)
Used by the embedder to notify the rasterizer that the context of the previously registered texture h...
const TaskRunners task_runners_
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
const char * message
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
FlTexture * texture
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
std::function< void()> closure
Definition closure.h:14
impeller::ShaderType type
int64_t texture_id