Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
flutter::FlutterMain Class Reference

#include <flutter_main.h>

Public Member Functions

 ~FlutterMain ()
 
const flutter::SettingsGetSettings () const
 

Static Public Member Functions

static bool Register (JNIEnv *env)
 
static FlutterMainGet ()
 
static AndroidRenderingAPI SelectedRenderingAPI (const flutter::Settings &settings)
 

Detailed Description

Definition at line 16 of file flutter_main.h.

Constructor & Destructor Documentation

◆ ~FlutterMain()

flutter::FlutterMain::~FlutterMain ( )
default

Member Function Documentation

◆ Get()

FlutterMain & flutter::FlutterMain::Get ( )
static

Definition at line 58 of file flutter_main.cc.

58 {
59 FML_CHECK(g_flutter_main) << "ensureInitializationComplete must have already "
60 "been called.";
61 return *g_flutter_main;
62}
#define FML_CHECK(condition)
Definition: logging.h:85
static std::unique_ptr< FlutterMain > g_flutter_main
Definition: flutter_main.cc:56

◆ GetSettings()

const flutter::Settings & flutter::FlutterMain::GetSettings ( ) const

Definition at line 64 of file flutter_main.cc.

64 {
65 return settings_;
66}

◆ Register()

bool flutter::FlutterMain::Register ( JNIEnv *  env)
static

Definition at line 209 of file flutter_main.cc.

209 {
210 static const JNINativeMethod methods[] = {
211 {
212 .name = "nativeInit",
213 .signature = "(Landroid/content/Context;[Ljava/lang/String;Ljava/"
214 "lang/String;Ljava/lang/String;Ljava/lang/String;J)V",
215 .fnPtr = reinterpret_cast<void*>(&Init),
216 },
217 {
218 .name = "nativePrefetchDefaultFontManager",
219 .signature = "()V",
220 .fnPtr = reinterpret_cast<void*>(&PrefetchDefaultFontManager),
221 },
222 };
223
224 jclass clazz = env->FindClass("io/flutter/embedding/engine/FlutterJNI");
225
226 if (clazz == nullptr) {
227 return false;
228 }
229
230 return env->RegisterNatives(clazz, methods, fml::size(methods)) == 0;
231}
Definition: __init__.py:1
static void PrefetchDefaultFontManager(JNIEnv *env, jclass jcaller)
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13

◆ SelectedRenderingAPI()

AndroidRenderingAPI flutter::FlutterMain::SelectedRenderingAPI ( const flutter::Settings settings)
static

Definition at line 234 of file flutter_main.cc.

235 {
236 if (settings.enable_software_rendering) {
237 FML_CHECK(!settings.enable_impeller)
238 << "Impeller does not support software rendering. Either disable "
239 "software rendering or disable impeller.";
241 }
242 constexpr AndroidRenderingAPI kVulkanUnsupportedFallback =
244
245 // Debug/Profile only functionality for testing a specific
246 // backend configuration.
247#ifndef FLUTTER_RELEASE
248 if (settings.requested_rendering_backend == "opengles" &
249 settings.enable_impeller) {
251 }
252 if (settings.requested_rendering_backend == "vulkan" &&
253 settings.enable_impeller) {
255 }
256#endif
257
258 if (settings.enable_impeller) {
259 // Vulkan must only be used on API level 29+, as older API levels do not
260 // have requisite features to support platform views.
261 //
262 // Even if this check returns true, Impeller may determine it cannot use
263 // Vulkan for some other reason, such as a missing required extension or
264 // feature.
265 int api_level = android_get_device_api_level();
266 if (api_level < kMinimumAndroidApiLevelForVulkan) {
267 return kVulkanUnsupportedFallback;
268 }
269 // Determine if Vulkan is supported by creating a Vulkan context and
270 // checking if it is valid.
271 impeller::ScopedValidationDisable disable_validation;
272 auto vulkan_backend = std::make_unique<AndroidContextVulkanImpeller>(
273 /*enable_vulkan_validation=*/false,
274 /*enable_vulkan_gpu_tracing=*/false,
275 /*quiet=*/true);
276 if (!vulkan_backend->IsValid()) {
277 return kVulkanUnsupportedFallback;
278 }
280 }
281
283}
AndroidRenderingAPI
Definition: settings.h:26
constexpr int kMinimumAndroidApiLevelForVulkan
Definition: flutter_main.cc:35

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