#include <platform_view_android.h>
Public Member Functions | |
| PlatformViewAndroid (PlatformView::Delegate &delegate, const flutter::TaskRunners &task_runners, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade, AndroidRenderingAPI rendering_api) | |
| PlatformViewAndroid (PlatformView::Delegate &delegate, const flutter::TaskRunners &task_runners, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade, const std::shared_ptr< flutter::AndroidContext > &android_context) | |
| Creates a new PlatformViewAndroid but using an existing Android GPU context to create new surfaces. This maximizes resource sharing between 2 PlatformViewAndroids of 2 Shells. | |
| ~PlatformViewAndroid () override | |
| void | NotifyCreated (fml::RefPtr< AndroidNativeWindow > native_window) |
| void | NotifySurfaceWindowChanged (fml::RefPtr< AndroidNativeWindow > native_window) |
| void | NotifyChanged (const DlISize &size) |
| void | NotifyDestroyed () override |
| 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 | DispatchPlatformMessage (JNIEnv *env, std::string name, jobject message_data, jint message_position, jint response_id) |
| void | DispatchEmptyPlatformMessage (JNIEnv *env, std::string name, jint response_id) |
| void | DispatchSemanticsAction (JNIEnv *env, jint id, jint action, jobject args, jint args_position) |
| void | RegisterExternalTexture (int64_t texture_id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture) |
| void | RegisterImageTexture (int64_t texture_id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_texture_entry, ImageExternalTexture::ImageLifecycle lifecycle) |
| void | LoadDartDeferredLibrary (intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions) override |
| 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. | |
| void | LoadDartDeferredLibraryError (intptr_t loading_unit_id, const std::string error_message, bool transient) override |
| Indicates to the dart VM that the request to load a deferred library with the specified loading unit id has failed. | |
| void | UpdateAssetResolverByType (std::unique_ptr< AssetResolver > updated_asset_resolver, AssetResolver::AssetResolverType type) override |
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. | |
| const std::shared_ptr< AndroidContext > & | GetAndroidContext () |
| std::shared_ptr< PlatformMessageHandler > | GetPlatformMessageHandler () const override |
| Specifies a delegate that will receive PlatformMessages from Flutter to the host platform. | |
| bool | IsSurfaceControlEnabled () const |
| Whether the SurfaceControl based swapchain is enabled and active. | |
| void | SetupImpellerContext () override |
| Performs any deferred setup of the Impeller context. | |
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. | |
| 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 (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 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 | SetSemanticsTreeEnabled (bool enabled) |
| Used by the framework to tell the embedder to prepare or clear resoruce for accepting semantics tree. | |
| 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. | |
| 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. | |
| void | SendViewFocusEvent (const ViewFocusEvent &event) |
| virtual PointerDataDispatcherMaker | GetDispatcherMaker () |
Returns a platform-specific PointerDataDispatcherMaker so the Engine can construct the PointerDataPacketDispatcher based on platforms. | |
| fml::WeakPtr< 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. | |
| 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. | |
| const Settings & | GetSettings () const |
| Get the settings for this platform view instance. | |
| virtual void | RequestViewFocusChange (const ViewFocusChangeRequest &request) |
| Notifies the client that the Flutter view focus state has changed and the platform view should be updated. | |
Static Public Member Functions | |
| static bool | Register (JNIEnv *env) |
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::Delegate & | delegate_ |
| const TaskRunners | task_runners_ |
| fml::WeakPtrFactory< PlatformView > | weak_factory_ |
Definition at line 43 of file platform_view_android.h.
| flutter::PlatformViewAndroid::PlatformViewAndroid | ( | PlatformView::Delegate & | delegate, |
| const flutter::TaskRunners & | task_runners, | ||
| const std::shared_ptr< PlatformViewAndroidJNI > & | jni_facade, | ||
| AndroidRenderingAPI | rendering_api | ||
| ) |
Definition at line 137 of file platform_view_android.cc.
| flutter::PlatformViewAndroid::PlatformViewAndroid | ( | PlatformView::Delegate & | delegate, |
| const flutter::TaskRunners & | task_runners, | ||
| const std::shared_ptr< PlatformViewAndroidJNI > & | jni_facade, | ||
| const std::shared_ptr< flutter::AndroidContext > & | android_context | ||
| ) |
Creates a new PlatformViewAndroid but using an existing Android GPU context to create new surfaces. This maximizes resource sharing between 2 PlatformViewAndroids of 2 Shells.
Definition at line 152 of file platform_view_android.cc.
References flutter::Settings::enable_impeller, flutter::Settings::enable_surface_control, FML_CHECK, flutter::Settings::impeller_enable_lazy_shader_mode, and flutter::PlatformView::Delegate::OnPlatformViewGetSettings().
|
overridedefault |
| void flutter::PlatformViewAndroid::DispatchEmptyPlatformMessage | ( | JNIEnv * | env, |
| std::string | name, | ||
| jint | response_id | ||
| ) |
Definition at line 272 of file platform_view_android.cc.
References flutter::PlatformView::DispatchPlatformMessage(), flutter::TaskRunners::GetPlatformTaskRunner(), flutter::name, and flutter::PlatformView::task_runners_.
| void flutter::PlatformViewAndroid::DispatchPlatformMessage | ( | JNIEnv * | env, |
| std::string | name, | ||
| jobject | message_data, | ||
| jint | message_position, | ||
| jint | response_id | ||
| ) |
Definition at line 251 of file platform_view_android.cc.
References fml::MallocMapping::Copy(), flutter::PlatformView::DispatchPlatformMessage(), flutter::TaskRunners::GetPlatformTaskRunner(), message, flutter::name, and flutter::PlatformView::task_runners_.
| void flutter::PlatformViewAndroid::DispatchSemanticsAction | ( | JNIEnv * | env, |
| jint | id, | ||
| jint | action, | ||
| jobject | args, | ||
| jint | args_position | ||
| ) |
Definition at line 298 of file platform_view_android.cc.
References action, args, fml::MallocMapping::Copy(), flutter::PlatformView::DispatchSemanticsAction(), and flutter::kImplicitViewId.
|
inline |
Definition at line 115 of file platform_view_android.h.
Referenced by flutter::AndroidShellHolder::Spawn().
|
inlineoverridevirtual |
Specifies a delegate that will receive PlatformMessages from Flutter to the host platform.
If this returns null that means PlatformMessages should be sent to the PlatformView. That is to protect legacy behavior, any embedder that wants to support executing Platform Channel handlers on background threads should be returning a thread-safe PlatformMessageHandler instead.
Reimplemented from flutter::PlatformView.
Definition at line 119 of file platform_view_android.h.
| bool flutter::PlatformViewAndroid::IsSurfaceControlEnabled | ( | ) | const |
Whether the SurfaceControl based swapchain is enabled and active.
Definition at line 554 of file platform_view_android.cc.
References impeller::BackendCast< ContextVK, Context >::Cast(), and impeller::ContextVK::GetShouldEnableSurfaceControlSwapchain().
|
overridevirtual |
Loads the Dart shared library into the Dart VM. When the Dart library is loaded successfully, the Dart future returned by the originating loadLibrary() call completes.
The Dart compiler may generate separate shared libraries files called 'loading units' when libraries are imported as deferred. Each of these shared libraries are identified by a unique loading unit id. Callers should open and resolve a SymbolMapping from the shared library. The Mappings should be moved into this method, as ownership will be assumed by the dart isolate after successful loading and released after shutdown of the dart isolate. If loading fails, the mappings will naturally go out of scope.
This method is paired with a RequestDartDeferredLibrary invocation that provides the embedder with the loading unit id of the deferred library to load.
| [in] | loading_unit_id | The unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary. |
| [in] | snapshot_data | Dart snapshot data of the loading unit's shared library. |
| [in] | snapshot_data | Dart snapshot instructions of the loading unit's shared library. |
Reimplemented from flutter::PlatformView.
Definition at line 504 of file platform_view_android.cc.
References flutter::PlatformView::delegate_, and flutter::PlatformView::Delegate::LoadDartDeferredLibrary().
|
overridevirtual |
Indicates to the dart VM that the request to load a deferred library with the specified loading unit id has failed.
The dart future returned by the initiating loadLibrary() call will complete with an error.
| [in] | loading_unit_id | The unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary. |
| [in] | error_message | The error message that will appear in the dart Future. |
| [in] | transient | A transient error is a failure due to temporary conditions such as no network. Transient errors allow the dart VM to re-request the same deferred library and loading_unit_id again. Non-transient errors are permanent and attempts to re-request the library will instantly complete with an error. |
Reimplemented from flutter::PlatformView.
Definition at line 513 of file platform_view_android.cc.
References flutter::PlatformView::delegate_, and flutter::PlatformView::Delegate::LoadDartDeferredLibraryError().
| void flutter::PlatformViewAndroid::NotifyChanged | ( | const DlISize & | size | ) |
Definition at line 237 of file platform_view_android.cc.
References flutter::TaskRunners::GetRasterTaskRunner(), fml::TaskRunner::RunNowOrPostTask(), flutter::size, surface, flutter::PlatformView::task_runners_, and fml::AutoResetWaitableEvent::Wait().
| void flutter::PlatformViewAndroid::NotifyCreated | ( | fml::RefPtr< AndroidNativeWindow > | native_window | ) |
Definition at line 185 of file platform_view_android.cc.
References flutter::TaskRunners::GetRasterTaskRunner(), flutter::PlatformView::NotifyCreated(), fml::TaskRunner::RunNowOrPostTask(), surface, flutter::PlatformView::task_runners_, and fml::AutoResetWaitableEvent::Wait().
|
overridevirtual |
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.
Reimplemented from flutter::PlatformView.
Definition at line 222 of file platform_view_android.cc.
References flutter::TaskRunners::GetRasterTaskRunner(), flutter::PlatformView::NotifyDestroyed(), fml::TaskRunner::RunNowOrPostTask(), surface, flutter::PlatformView::task_runners_, and fml::AutoResetWaitableEvent::Wait().
| void flutter::PlatformViewAndroid::NotifySurfaceWindowChanged | ( | fml::RefPtr< AndroidNativeWindow > | native_window | ) |
Definition at line 204 of file platform_view_android.cc.
References flutter::TaskRunners::GetRasterTaskRunner(), fml::TaskRunner::RunNowOrPostTask(), flutter::PlatformView::ScheduleFrame(), surface, flutter::PlatformView::task_runners_, and fml::AutoResetWaitableEvent::Wait().
|
static |
Definition at line 1010 of file platform_view_android_jni_impl.cc.
References fml::jni::CheckException(), fml::jni::ClearException(), FML_CHECK, FML_LOG, flutter::g_acquire_latest_image_method, flutter::g_attach_to_gl_context_method, flutter::g_compute_platform_resolved_locale_method, flutter::g_detach_from_gl_context_method, flutter::g_flutter_callback_info_class, flutter::g_flutter_callback_info_constructor, flutter::g_flutter_jni_class, flutter::g_get_transform_matrix_method, flutter::g_hardware_buffer_class, flutter::g_hardware_buffer_close_method, flutter::g_image_class, flutter::g_image_close_method, flutter::g_image_consumer_texture_registry_interface, flutter::g_image_get_hardware_buffer_method, flutter::g_java_long_class, flutter::g_java_weak_reference_class, flutter::g_java_weak_reference_get_method, flutter::g_mutators_stack_class, flutter::g_mutators_stack_init_method, flutter::g_mutators_stack_push_clippath_method, flutter::g_mutators_stack_push_cliprect_method, flutter::g_mutators_stack_push_cliprrect_method, flutter::g_mutators_stack_push_opacity_method, flutter::g_mutators_stack_push_transform_method, flutter::g_path_fill_type_class, flutter::g_path_fill_type_even_odd_field, flutter::g_path_fill_type_winding_field, flutter::g_request_dart_deferred_library_method, flutter::g_surface_texture_wrapper_should_update, flutter::g_texture_wrapper_class, flutter::g_update_tex_image_method, flutter::path_class, flutter::path_close_method, flutter::path_conic_to_method, flutter::path_constructor, flutter::path_cubic_to_method, flutter::path_line_to_method, flutter::path_move_to_method, flutter::path_quad_to_method, flutter::path_set_fill_type_method, and flutter::RegisterApi().
Referenced by JNI_OnLoad().
| void flutter::PlatformViewAndroid::RegisterExternalTexture | ( | int64_t | texture_id, |
| const fml::jni::ScopedJavaGlobalRef< jobject > & | surface_texture | ||
| ) |
Definition at line 333 of file platform_view_android.cc.
References FML_CHECK, FML_LOG, flutter::kImpellerAutoselect, flutter::kImpellerOpenGLES, flutter::kImpellerVulkan, flutter::kSkiaOpenGLES, flutter::kSoftware, flutter::PlatformView::RegisterTexture(), and texture_id.
| void flutter::PlatformViewAndroid::RegisterImageTexture | ( | int64_t | texture_id, |
| const fml::jni::ScopedJavaGlobalRef< jobject > & | image_texture_entry, | ||
| ImageExternalTexture::ImageLifecycle | lifecycle | ||
| ) |
Definition at line 381 of file platform_view_android.cc.
References FML_CHECK, FML_LOG, flutter::kImpellerAutoselect, flutter::kImpellerOpenGLES, flutter::kImpellerVulkan, flutter::kSkiaOpenGLES, flutter::kSoftware, flutter::PlatformView::RegisterTexture(), and texture_id.
|
overridevirtual |
Performs any deferred setup of the Impeller context.
This is intended to be called from the raster thread so that
Impeller context creation can be moved off the startup path.
Reimplemented from flutter::PlatformView.
Definition at line 563 of file platform_view_android.cc.
|
overridevirtual |
Replaces the asset resolver handled by the engine's AssetManager of the specified type with updated_asset_resolver. The matching AssetResolver is removed and replaced with updated_asset_resolvers.
AssetResolvers should be updated when the existing resolver becomes obsolete and a newer one becomes available that provides updated access to the same type of assets as the existing one. This update process is meant to be performed at runtime.
If a null resolver is provided, nothing will be done. If no matching resolver is found, the provided resolver will be added to the end of the AssetManager resolvers queue. The replacement only occurs with the first matching resolver. Any additional matching resolvers are untouched.
| [in] | updated_asset_resolver | The asset resolver to replace the resolver of matching type with. |
| [in] | type | The type of AssetResolver to update. Only resolvers of the specified type will be replaced by the updated resolver. |
Reimplemented from flutter::PlatformView.
Definition at line 522 of file platform_view_android.cc.
References flutter::PlatformView::delegate_, type, and flutter::PlatformView::Delegate::UpdateAssetResolverByType().