Flutter Engine
 
Loading...
Searching...
No Matches
platform_view_android.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_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
6#define FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
7
8#include <memory>
9#include <string>
10#include <vector>
11
12#include <android/hardware_buffer_jni.h>
24
25namespace flutter {
26
28 public:
29 AndroidSurfaceFactoryImpl(const std::shared_ptr<AndroidContext>& context,
30 bool enable_impeller,
31 bool lazy_shader_mode);
32
34
35 std::unique_ptr<AndroidSurface> CreateSurface() override;
36
37 private:
38 const std::shared_ptr<AndroidContext>& android_context_;
39 const bool enable_impeller_;
40 const bool lazy_shader_mode_;
41};
42
43class PlatformViewAndroid final : public PlatformView {
44 public:
45 static bool Register(JNIEnv* env);
46
48 const flutter::TaskRunners& task_runners,
49 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade,
50 AndroidRenderingAPI rendering_api);
51
52 //----------------------------------------------------------------------------
53 /// @brief Creates a new PlatformViewAndroid but using an existing
54 /// Android GPU context to create new surfaces. This maximizes
55 /// resource sharing between 2 PlatformViewAndroids of 2 Shells.
56 ///
58 PlatformView::Delegate& delegate,
59 const flutter::TaskRunners& task_runners,
60 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade,
61 const std::shared_ptr<flutter::AndroidContext>& android_context);
62
64
66
69
70 void NotifyChanged(const DlISize& size);
71
72 // |PlatformView|
73 void NotifyDestroyed() override;
74
75 void DispatchPlatformMessage(JNIEnv* env,
76 std::string name,
77 jobject message_data,
78 jint message_position,
79 jint response_id);
80
81 void DispatchEmptyPlatformMessage(JNIEnv* env,
82 std::string name,
83 jint response_id);
84
85 void DispatchSemanticsAction(JNIEnv* env,
86 jint id,
87 jint action,
88 jobject args,
89 jint args_position);
90
92 int64_t texture_id,
93 const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture);
94
96 int64_t texture_id,
97 const fml::jni::ScopedJavaGlobalRef<jobject>& image_texture_entry,
99
100 // |PlatformView|
102 intptr_t loading_unit_id,
103 std::unique_ptr<const fml::Mapping> snapshot_data,
104 std::unique_ptr<const fml::Mapping> snapshot_instructions) override;
105
106 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
107 const std::string error_message,
108 bool transient) override;
109
110 // |PlatformView|
112 std::unique_ptr<AssetResolver> updated_asset_resolver,
114
115 const std::shared_ptr<AndroidContext>& GetAndroidContext() {
116 return android_context_;
117 }
118
119 std::shared_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
120 const override {
121 return platform_message_handler_;
122 }
123
124 /// @brief Whether the SurfaceControl based swapchain is enabled and active.
125 bool IsSurfaceControlEnabled() const;
126
127 // |PlatformView|
128 void SetupImpellerContext() override;
129
130 private:
131 const std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
132 std::shared_ptr<AndroidContext> android_context_;
133 std::shared_ptr<AndroidSurfaceFactoryImpl> surface_factory_;
134
135 PlatformViewAndroidDelegate platform_view_android_delegate_;
136
137 std::unique_ptr<AndroidSurface> android_surface_;
138 std::shared_ptr<PlatformMessageHandlerAndroid> platform_message_handler_;
139 bool android_meets_hcpp_criteria_ = false;
140
141 // |PlatformView|
142 void UpdateSemantics(
143 int64_t view_id,
146
147 // |PlatformView|
148 void SetApplicationLocale(std::string locale) override;
149
150 // |PlatformView|
151 void HandlePlatformMessage(
152 std::unique_ptr<flutter::PlatformMessage> message) override;
153
154 // |PlatformView|
155 void OnPreEngineRestart() const override;
156
157 // |PlatformView|
158 std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
159
160 // |PlatformView|
161 std::unique_ptr<Surface> CreateRenderingSurface() override;
162
163 // |PlatformView|
164 std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
165
166 // |PlatformView|
167 std::unique_ptr<SnapshotSurfaceProducer> CreateSnapshotSurfaceProducer()
168 override;
169
170 // |PlatformView|
171 sk_sp<GrDirectContext> CreateResourceContext() const override;
172
173 // |PlatformView|
174 void ReleaseResourceContext() const override;
175
176 // |PlatformView|
177 std::shared_ptr<impeller::Context> GetImpellerContext() const override;
178
179 // |PlatformView|
180 std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocales(
181 const std::vector<std::string>& supported_locale_data) override;
182
183 // |PlatformView|
184 void RequestDartDeferredLibrary(intptr_t loading_unit_id) override;
185
186 void InstallFirstFrameCallback();
187
188 void FireFirstFrameCallback();
189
190 double GetScaledFontSize(double unscaled_font_size,
191 int configuration_id) const override;
192
194};
195} // namespace flutter
196
197#endif // FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
GLenum type
std::unique_ptr< AndroidSurface > CreateSurface() override
AssetResolverType
Identifies the type of AssetResolver an instance is.
ImageLifecycle
Whether the last image should be reset when the context is destroyed.
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
void RegisterImageTexture(int64_t texture_id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_texture_entry, ImageExternalTexture::ImageLifecycle lifecycle)
void DispatchPlatformMessage(JNIEnv *env, std::string name, jobject message_data, jint message_position, jint response_id)
void RegisterExternalTexture(int64_t texture_id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture)
bool IsSurfaceControlEnabled() const
Whether the SurfaceControl based swapchain is enabled and active.
void NotifySurfaceWindowChanged(fml::RefPtr< AndroidNativeWindow > native_window)
std::shared_ptr< PlatformMessageHandler > GetPlatformMessageHandler() const override
Specifies a delegate that will receive PlatformMessages from Flutter to the host platform.
void NotifyChanged(const DlISize &size)
const std::shared_ptr< AndroidContext > & GetAndroidContext()
void DispatchEmptyPlatformMessage(JNIEnv *env, std::string name, jint response_id)
void SetupImpellerContext() override
Performs any deferred setup of the Impeller context.
void NotifyDestroyed() override
Used by embedders to notify the shell that the platform view has been destroyed. This notification us...
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_a...
void DispatchSemanticsAction(JNIEnv *env, jint id, jint action, jobject args, jint args_position)
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 ...
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,...
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
void NotifyCreated()
Used by embedders to notify the shell that a platform view has been created. This notification is use...
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS GBytes * message
G_BEGIN_DECLS FlutterViewId view_id
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
int64_t texture_id