154 {
156 return false;
157 }
158
160
164 fbo_with_frame_info_callback) ||
166 return false;
167 }
168
169 return true;
170}
171
174 return false;
175 }
176
178
179 if (
SAFE_ACCESS(software_config, surface_present_callback,
nullptr) ==
180 nullptr) {
181 return false;
182 }
183
184 return true;
185}
186
189 return false;
190 }
191
193
195 bool command_queue =
196 SAFE_ACCESS(metal_config, present_command_queue,
nullptr);
197
198 bool present =
SAFE_ACCESS(metal_config, present_drawable_callback,
nullptr);
199 bool get_texture =
200 SAFE_ACCESS(metal_config, get_next_drawable_callback,
nullptr);
201
202 return device && command_queue && present && get_texture;
203}
204
207 return false;
208 }
209
211
216 !
SAFE_EXISTS(vulkan_config, get_instance_proc_address_callback) ||
217 !
SAFE_EXISTS(vulkan_config, get_next_image_callback) ||
218 !
SAFE_EXISTS(vulkan_config, present_image_callback)) {
219 return false;
220 }
221
222 return true;
223}
224
226 if (config == nullptr) {
227 return false;
228 }
229
230 switch (config->
type) {
239 default:
240 return false;
241 }
242
243 return false;
244}
245
246#if FML_OS_LINUX || FML_OS_WIN
247static void* DefaultGLProcResolver(
const char*
name) {
249#if FML_OS_LINUX
251#elif FML_OS_WIN
253#endif
254 return static_cast<void*>(
255 const_cast<uint8_t*
>(proc_library->ResolveSymbol(
name)));
256}
257#endif
258
259#ifdef SHELL_ENABLE_GL
260
261
267 return flutter_rect;
268}
269
270
271
274 static_cast<int32_t
>(flutter_rect.
top),
275 static_cast<int32_t
>(flutter_rect.
right),
276 static_cast<int32_t
>(flutter_rect.
bottom)};
278}
279#endif
280
286 platform_dispatch_table,
287 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
288 external_view_embedder,
289 bool enable_impeller) {
290#ifdef SHELL_ENABLE_GL
292 return nullptr;
293 }
294
297
300
301 auto gl_present =
305 if (present) {
307 } else {
308
309
310
311
312
313
314
315 std::optional<FlutterRect> frame_damage_rect;
316 if (gl_present_info.frame_damage) {
317 frame_damage_rect =
318 SkIRectToFlutterRect(*(gl_present_info.frame_damage));
319 }
320 std::optional<FlutterRect> buffer_damage_rect;
321 if (gl_present_info.buffer_damage) {
322 buffer_damage_rect =
323 SkIRectToFlutterRect(*(gl_present_info.buffer_damage));
324 }
325
328 .num_rects = frame_damage_rect ? size_t{1} : size_t{0},
329 .damage = frame_damage_rect ? &frame_damage_rect.value() : nullptr,
330 };
333 .num_rects = buffer_damage_rect ? size_t{1} : size_t{0},
334 .damage = buffer_damage_rect ? &buffer_damage_rect.value() : nullptr,
335 };
336
337
340 .fbo_id = gl_present_info.fbo_id,
341 .frame_damage = frame_damage,
342 .buffer_damage = buffer_damage,
343 };
344
345 return present_with_info(
user_data, &present_info);
346 }
347 };
348
349 auto gl_fbo_callback =
351 fbo_with_frame_info_callback =
354 if (fbo_callback) {
356 } else {
359 frame_info.
size = {gl_frame_info.
width, gl_frame_info.height};
360 return fbo_with_frame_info_callback(
user_data, &frame_info);
361 }
362 };
363
364 auto gl_populate_existing_damage =
367
368
369 if (!populate_existing_damage) {
371 .
fbo_id =
static_cast<uint32_t
>(
id),
372 .existing_damage = std::nullopt,
373 };
374 }
375
376
378 populate_existing_damage(
user_data,
id, &existing_damage);
379
380 std::optional<SkIRect> existing_damage_rect = std::nullopt;
381
382
383 if (existing_damage.
num_rects <= 0 || existing_damage.
damage ==
nullptr) {
384 FML_LOG(INFO) <<
"No damage was provided. Forcing full repaint.";
385 } else {
387 for (
size_t i = 0; i < existing_damage.
num_rects; i++) {
388 existing_damage_rect->join(
389 FlutterRectToSkIRect(existing_damage.
damage[i]));
390 }
391 }
392
393
395 .
fbo_id =
static_cast<uint32_t
>(
id),
396 .existing_damage = existing_damage_rect,
397 };
398 };
399
401 std::function<bool()> gl_make_resource_current_callback = nullptr;
402 if (
SAFE_ACCESS(open_gl_config, make_resource_current,
nullptr) !=
nullptr) {
403 gl_make_resource_current_callback =
406 };
407 }
408
409 std::function<
SkMatrix(
void)> gl_surface_transformation_callback =
nullptr;
410 if (
SAFE_ACCESS(open_gl_config, surface_transformation,
nullptr) !=
nullptr) {
411 gl_surface_transformation_callback =
415 transformation.
skewX,
417 transformation.
skewY,
420 transformation.
pers0,
421 transformation.
pers1,
423 );
424 };
425
426
427
428 if (external_view_embedder) {
429 external_view_embedder->SetSurfaceTransformationCallback(
430 gl_surface_transformation_callback);
431 }
432 }
433
435 if (
SAFE_ACCESS(open_gl_config, gl_proc_resolver,
nullptr) !=
nullptr) {
439 };
440 } else {
441#if FML_OS_LINUX || FML_OS_WIN
442 gl_proc_resolver = DefaultGLProcResolver;
443#endif
444 }
445
446 bool fbo_reset_after_present =
447 SAFE_ACCESS(open_gl_config, fbo_reset_after_present,
false);
448
450 gl_make_current,
451 gl_clear_current,
452 gl_present,
453 gl_fbo_callback,
454 gl_make_resource_current_callback,
455 gl_surface_transformation_callback,
456 gl_proc_resolver,
457 gl_populate_existing_damage,
458 };
459
461 [gl_dispatch_table, fbo_reset_after_present, platform_dispatch_table,
462 enable_impeller,
463 external_view_embedder =
464 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
465 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
466 std::move(external_view_embedder);
467 if (enable_impeller) {
468 return std::make_unique<flutter::PlatformViewEmbedder>(
469 shell,
470 shell.GetTaskRunners(),
471 std::make_unique<flutter::EmbedderSurfaceGLImpeller>(
472 gl_dispatch_table, fbo_reset_after_present,
473 view_embedder),
474 platform_dispatch_table,
475 view_embedder
476 );
477 }
478 return std::make_unique<flutter::PlatformViewEmbedder>(
479 shell,
480 shell.GetTaskRunners(),
481 std::make_unique<flutter::EmbedderSurfaceGL>(
482 gl_dispatch_table, fbo_reset_after_present,
483 view_embedder),
484 platform_dispatch_table,
485 view_embedder
486 );
487 });
488#else
489 return nullptr;
490#endif
491}
492
498 platform_dispatch_table,
499 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
500 external_view_embedder,
501 bool enable_impeller) {
503 return nullptr;
504 }
505
506#ifdef SHELL_ENABLE_METAL
516 return ptr(
user_data, &embedder_texture);
517 };
518 auto metal_get_texture =
523 frame_info.
size = {
static_cast<uint32_t
>(frame_size.width()),
524 static_cast<uint32_t>(frame_size.height())};
526
532 return texture_info;
533 };
534
535 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
536 std::move(external_view_embedder);
537
538 std::unique_ptr<flutter::EmbedderSurface> embedder_surface;
539
540 if (enable_impeller) {
542 metal_dispatch_table = {
544 .get_texture = metal_get_texture,
545 };
546 embedder_surface = std::make_unique<flutter::EmbedderSurfaceMetalImpeller>(
550 metal_dispatch_table, view_embedder);
551 } else {
554 .get_texture = metal_get_texture,
555 };
556 embedder_surface = std::make_unique<flutter::EmbedderSurfaceMetal>(
560 metal_dispatch_table, view_embedder);
561 }
562
563
564
566 [embedder_surface = std::move(embedder_surface), platform_dispatch_table,
567 external_view_embedder = view_embedder](
flutter::Shell& shell)
mutable {
568 return std::make_unique<flutter::PlatformViewEmbedder>(
569 shell,
570 shell.GetTaskRunners(),
571 std::move(embedder_surface),
572 platform_dispatch_table,
573 std::move(external_view_embedder)
574 );
575 });
576#else
577 return nullptr;
578#endif
579}
580
586 platform_dispatch_table,
587 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
588 external_view_embedder) {
590 return nullptr;
591 }
592
593#ifdef SHELL_ENABLE_VULKAN
594 std::function<void*(VkInstance, const char*)>
595 vulkan_get_instance_proc_address =
597 VkInstance
instance,
const char* proc_name) ->
void* {
599 };
600
601 auto vulkan_get_next_image =
606 .size = {static_cast<uint32_t>(frame_size.width()),
607 static_cast<uint32_t>(frame_size.height())},
608 };
609
611 };
612
613 auto vulkan_present_image_callback =
619 .format =
static_cast<uint32_t
>(
format),
620 };
622 };
623
624 auto vk_instance =
static_cast<VkInstance
>(config->
vulkan.
instance);
625 auto proc_addr =
626 vulkan_get_instance_proc_address(vk_instance, "vkGetInstanceProcAddr");
627
631 .get_next_image = vulkan_get_next_image,
632 .present_image = vulkan_present_image_callback,
633 };
634
635 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
636 std::move(external_view_embedder);
637
638 std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
639 std::make_unique<flutter::EmbedderSurfaceVulkan>(
648 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
649 view_embedder);
650
652 [embedder_surface = std::move(embedder_surface), platform_dispatch_table,
653 external_view_embedder =
655 return std::make_unique<flutter::PlatformViewEmbedder>(
656 shell,
657 shell.GetTaskRunners(),
658 std::move(embedder_surface),
659 platform_dispatch_table,
660 std::move(external_view_embedder)
661 );
662 });
663#else
664 return nullptr;
665#endif
666}
667
673 platform_dispatch_table,
674 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
675 external_view_embedder) {
677 return nullptr;
678 }
679
680 auto software_present_backing_store =
682 const void* allocation,
size_t row_bytes,
size_t height) ->
bool {
684 };
685
687 software_dispatch_table = {
688 software_present_backing_store,
689 };
690
692 [software_dispatch_table, platform_dispatch_table,
693 external_view_embedder =
694 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
695 return std::make_unique<flutter::PlatformViewEmbedder>(
696 shell,
697 shell.GetTaskRunners(),
698 software_dispatch_table,
699 platform_dispatch_table,
700 std::move(external_view_embedder)
701 );
702 });
703}
704
710 platform_dispatch_table,
711 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
712 external_view_embedder,
713 bool enable_impeller) {
714 if (config == nullptr) {
715 return nullptr;
716 }
717
718 switch (config->
type) {
721 config,
user_data, platform_dispatch_table,
722 std::move(external_view_embedder), enable_impeller);
725 config,
user_data, platform_dispatch_table,
726 std::move(external_view_embedder));
729 config,
user_data, platform_dispatch_table,
730 std::move(external_view_embedder), enable_impeller);
733 config,
user_data, platform_dispatch_table,
734 std::move(external_view_embedder));
735 default:
736 return nullptr;
737 }
738 return nullptr;
739}
740
745#ifdef SHELL_ENABLE_GL
750
753 skgpu::Mipmapped::kNo, texture_info);
754
756
758 context,
759 backend_texture,
761 1,
762 kN32_SkColorType,
764 &surface_properties,
766 texture->destruction_callback),
768 );
769
771 FML_LOG(
ERROR) <<
"Could not wrap embedder supplied render texture.";
772 return nullptr;
773 }
774
776#else
777 return nullptr;
778#endif
779}
780
785#ifdef SHELL_ENABLE_GL
789
790 auto backend_render_target =
793 1,
794 0,
795 framebuffer_info
796 );
797
799
801 context,
802 backend_render_target,
804 kN32_SkColorType,
806 &surface_properties,
810 );
811
813 FML_LOG(
ERROR) <<
"Could not wrap embedder supplied frame-buffer.";
814 return nullptr;
815 }
817#else
818 return nullptr;
819#endif
820}
821
826 const auto image_info =
828
829 struct Captures {
832 };
833 auto captures = std::make_unique<Captures>();
835 captures->user_data = software->
user_data;
836 auto release_proc = [](void* pixels, void* context) {
837 auto captures = reinterpret_cast<Captures*>(context);
838 if (captures->destruction_callback) {
839 captures->destruction_callback(captures->user_data);
840 }
841 delete captures;
842 };
843
848 release_proc,
849 captures.get()
850 );
851
854 << "Could not wrap embedder supplied software render buffer.";
857 }
858 return nullptr;
859 }
861 captures.release();
862 }
864}
865
871 if (!color_info) {
872 return nullptr;
873 }
874
877
878 struct Captures {
881 };
882 auto captures = std::make_unique<Captures>();
884 captures->user_data = software->
user_data;
885 auto release_proc = [](void* pixels, void* context) {
886 auto captures = reinterpret_cast<Captures*>(context);
887 if (captures->destruction_callback) {
888 captures->destruction_callback(captures->user_data);
889 }
890 };
891
896 release_proc,
897 captures.release()
898 );
899
902 << "Could not wrap embedder supplied software render buffer.";
905 }
906 return nullptr;
907 }
909}
910
915#ifdef SHELL_ENABLE_METAL
916 GrMtlTextureInfo texture_info;
918 FML_LOG(
ERROR) <<
"Embedder supplied null Metal texture.";
919 return nullptr;
920 }
921 sk_cfp<FlutterMetalTextureHandle> mtl_texture;
923 texture_info.fTexture = mtl_texture;
927 skgpu::Mipmapped::kNo,
928 texture_info
929 );
930
932
934 context,
935 backend_texture,
937
938
939 1,
941 nullptr,
942 &surface_properties,
946 );
947
949 FML_LOG(
ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
950 return nullptr;
951 }
952
954#else
955 return nullptr;
956#endif
957}
958
959static std::unique_ptr<flutter::EmbedderRenderTarget>
963 const std::shared_ptr<impeller::AiksContext>& aiks_context,
966#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING)
967
968 const auto& gl_context =
971
980
983 gl_context.GetReactor(), color0_tex, framebuffer->
name);
987
991 depth_stencil_texture_desc.
size =
size;
995
996 auto depth_stencil_tex = std::make_shared<impeller::TextureGLES>(
997 gl_context.GetReactor(), depth_stencil_texture_desc,
999
1002 depth0.
texture = depth_stencil_tex;
1005
1008 stencil0.
texture = depth_stencil_tex;
1011
1013
1017
1021
1022 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1023 backing_store, aiks_context,
1024 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1025 on_release, framebuffer_destruct);
1026#else
1027 return nullptr;
1028#endif
1029}
1030
1031static std::unique_ptr<flutter::EmbedderRenderTarget>
1035 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1038#if defined(SHELL_ENABLE_METAL) && defined(IMPELLER_SUPPORTS_RENDERING)
1040 FML_LOG(
ERROR) <<
"Embedder supplied null Metal texture.";
1041 return nullptr;
1042 }
1043
1045
1052
1057 if (!resolve_tex) {
1058 FML_LOG(
ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
1059 return nullptr;
1060 }
1061 resolve_tex->SetLabel("ImpellerBackingStoreResolve");
1062
1067 msaa_tex_desc.
format = resolve_tex->GetTextureDescriptor().format;
1070
1071 auto msaa_tex =
1072 aiks_context->GetContext()->GetResourceAllocator()->CreateTexture(
1073 msaa_tex_desc);
1074 if (!msaa_tex) {
1075 FML_LOG(
ERROR) <<
"Could not allocate MSAA color texture.";
1076 return nullptr;
1077 }
1078 msaa_tex->SetLabel("ImpellerBackingStoreColorMSAA");
1079
1086
1089
1090 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1091 backing_store, aiks_context,
1092 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1094#else
1095 return nullptr;
1096#endif
1097}
1098
1103#ifdef SHELL_ENABLE_VULKAN
1105 FML_LOG(
ERROR) <<
"Embedder supplied null Vulkan image.";
1106 return nullptr;
1107 }
1109 .
fImage =
reinterpret_cast<VkImage
>(
vulkan->image->image),
1117 .fSampleCount = 1,
1118 .fLevelCount = 1,
1119 };
1122
1124
1126 context,
1127 backend_texture,
1129 1,
1133 &surface_properties,
1135 vulkan->destruction_callback),
1137 );
1138
1140 FML_LOG(
ERROR) <<
"Could not wrap embedder supplied Vulkan render texture.";
1141 return nullptr;
1142 }
1143
1145#else
1146 return nullptr;
1147#endif
1148}
1149
1150static std::unique_ptr<flutter::EmbedderRenderTarget>
1154 if (!skia_surface) {
1155 return nullptr;
1156 }
1157 return std::make_unique<flutter::EmbedderRenderTargetSkia>(
1158 backing_store, std::move(skia_surface), std::move(on_release));
1159}
1160
1161static std::unique_ptr<flutter::EmbedderRenderTarget>
1166 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1167 bool enable_impeller) {
1169 backing_store.
struct_size =
sizeof(backing_store);
1170
1171
1172
1175
1176 {
1177 TRACE_EVENT0(
"flutter",
"FlutterCompositorCreateBackingStore");
1178 if (!c_create_callback(&config, &backing_store, compositor->
user_data)) {
1179 FML_LOG(
ERROR) <<
"Could not create the embedder backing store.";
1180 return nullptr;
1181 }
1182 }
1183
1184 if (backing_store.
struct_size !=
sizeof(backing_store)) {
1185 FML_LOG(
ERROR) <<
"Embedder modified the backing store struct size.";
1186 return nullptr;
1187 }
1188
1189
1190
1191
1192
1195 TRACE_EVENT0("flutter", "FlutterCompositorCollectBackingStore");
1196 c_collect_callback(&backing_store, user_data);
1197 });
1198
1199
1200
1201
1202 std::unique_ptr<flutter::EmbedderRenderTarget> render_target;
1203
1204 switch (backing_store.
type) {
1211 backing_store, std::move(skia_surface),
1212 collect_callback.Release());
1213 break;
1214 }
1216 if (enable_impeller) {
1218 backing_store, collect_callback.Release(), aiks_context, config,
1220 break;
1221 } else {
1225 backing_store, std::move(skia_surface),
1226 collect_callback.Release());
1227 break;
1228 }
1229 }
1230 }
1231 break;
1232 }
1235 context, config, &backing_store.
software);
1237 backing_store, std::move(skia_surface), collect_callback.Release());
1238 break;
1239 }
1242 context, config, &backing_store.
software2);
1244 backing_store, std::move(skia_surface), collect_callback.Release());
1245 break;
1246 }
1248 if (enable_impeller) {
1250 backing_store, collect_callback.Release(), aiks_context, config,
1251 &backing_store.
metal);
1252 } else {
1254 &backing_store.
metal);
1256 backing_store, std::move(skia_surface), collect_callback.Release());
1257 }
1258 break;
1259 }
1261 auto skia_surface =
1264 backing_store, std::move(skia_surface), collect_callback.Release());
1265 break;
1266 }
1267 };
1268
1269 if (!render_target) {
1270 FML_LOG(
ERROR) <<
"Could not create a surface from an embedder provided "
1271 "render target.";
1272 }
1273 return render_target;
1274}
1275
1276static std::pair<std::unique_ptr<flutter::EmbedderExternalViewEmbedder>,
1277 bool >
1279 bool enable_impeller) {
1280 if (compositor == nullptr) {
1281 return {nullptr, false};
1282 }
1283
1284 auto c_create_callback =
1285 SAFE_ACCESS(compositor, create_backing_store_callback,
nullptr);
1286 auto c_collect_callback =
1287 SAFE_ACCESS(compositor, collect_backing_store_callback,
nullptr);
1288 auto c_present_callback =
1289 SAFE_ACCESS(compositor, present_layers_callback,
nullptr);
1290 auto c_present_view_callback =
1291 SAFE_ACCESS(compositor, present_view_callback,
nullptr);
1292 bool avoid_backing_store_cache =
1293 SAFE_ACCESS(compositor, avoid_backing_store_cache,
false);
1294
1295
1296 if (!c_create_callback || !c_collect_callback) {
1297 FML_LOG(
ERROR) <<
"Required compositor callbacks absent.";
1298 return {nullptr, true};
1299 }
1300
1301 if ((!c_present_view_callback && !c_present_callback) ||
1302 (c_present_view_callback && c_present_callback)) {
1303 FML_LOG(
ERROR) <<
"Either present_layers_callback or present_view_callback "
1304 "must be provided but not both.";
1305 return {nullptr, true};
1306 }
1307
1309
1311 create_render_target_callback =
1312 [captured_compositor, enable_impeller](
1314 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1315 const auto& config) {
1317 context, aiks_context,
1318 enable_impeller);
1319 };
1320
1322 if (c_present_callback) {
1325 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1326 return c_present_callback(
const_cast<const FlutterLayer**
>(layers.data()),
1328 };
1329 } else {
1330 FML_DCHECK(c_present_view_callback !=
nullptr);
1331 present_callback = [c_present_view_callback,
1334 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1335
1338 .view_id = view_id,
1339 .layers =
const_cast<const FlutterLayer**
>(layers.data()),
1340 .layers_count = layers.
size(),
1342 };
1343
1344 return c_present_view_callback(&
info);
1345 };
1346 }
1347
1348 return {std::make_unique<flutter::EmbedderExternalViewEmbedder>(
1349 avoid_backing_store_cache, create_render_target_callback,
1350 present_callback),
1351 false};
1352}
1353
1354
1355static std::variant<flutter::ViewportMetrics, std::string>
1358 if (flutter_metrics == nullptr) {
1359 return "Invalid metrics handle.";
1360 }
1361
1363
1368 SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1370 SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1372 SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1374 SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1376
1378 return "Device pixel ratio was invalid. It must be greater than zero.";
1379 }
1380
1385 return "Physical view insets are invalid. They must be non-negative.";
1386 }
1387
1392 return "Physical view insets are invalid. They cannot be greater than "
1393 "physical height or width.";
1394 }
1395
1396 return metrics;
1397}
1398
1400 std::unique_ptr<flutter::PlatformMessage>
message;
1401};
1402
1405 if (elf) {
1407 }
1408 }
1409};
1410
1411using UniqueLoadedElf = std::unique_ptr<Dart_LoadedElf, LoadedElfDeleter>;
1412
1419};
1420
1426 "AOT data can only be created in AOT mode.");
1429 } else if (!data_out) {
1431 }
1432
1437 "Invalid ELF path specified.");
1438 }
1439
1440 auto aot_data = std::make_unique<_FlutterEngineAOTData>();
1441 const char*
error =
nullptr;
1442
1443#if OS_FUCHSIA
1444
1445
1447#else
1450 0,
1452 &aot_data->vm_snapshot_data,
1453 &aot_data->vm_snapshot_instrs,
1454 &aot_data->vm_isolate_data,
1455 &aot_data->vm_isolate_instrs
1456 );
1457#endif
1458
1459 if (loaded_elf == nullptr) {
1461 }
1462
1463 aot_data->loaded_elf.reset(loaded_elf);
1464
1465 *data_out = aot_data.release();
1467 }
1468 }
1469
1472 "Invalid FlutterEngineAOTDataSourceType type specified.");
1473}
1474
1476 if (!data) {
1477
1479 }
1480
1481
1484}
1485
1486
1487
1490 auto make_mapping_callback = [](
const char*
path,
bool executable) {
1491 return [
path, executable]() {
1492 if (executable) {
1494 } else {
1496 }
1497 };
1498 };
1499
1500
1502 settings.vm_snapshot_data = make_mapping_callback(
1503 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1504 }
1505
1506 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1507 settings.vm_snapshot_instr = make_mapping_callback(
1508 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1509 }
1510
1512 settings.isolate_snapshot_data = make_mapping_callback(
1513 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1514 }
1515
1516 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1517 settings.isolate_snapshot_instr = make_mapping_callback(
1518 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1519 true);
1520 }
1521
1522#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1523 settings.dart_library_sources_kernel = []() {
1526 };
1527#endif
1528
1529}
1530
1534
1535
1536 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1537 return [mapping,
size]() {
1538 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1539 };
1540 };
1541
1544 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1545
1547 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1548
1550 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1551
1553 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1554 }
1555
1557 settings.vm_snapshot_data = make_mapping_callback(
1559 }
1560
1561 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1562 settings.vm_snapshot_instr = make_mapping_callback(
1563 args->vm_snapshot_instructions,
1565 }
1566
1569 make_mapping_callback(
args->isolate_snapshot_data,
1571 }
1572
1573 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1574 settings.isolate_snapshot_instr = make_mapping_callback(
1575 args->isolate_snapshot_instructions,
1577 }
1578}
1579
1580
1581
1582
1587 update_semantics_custom_action_callback,
1589 return [update_semantics_node_callback,
1590 update_semantics_custom_action_callback,
1595
1596
1597 if (update_semantics_node_callback != nullptr) {
1598 for (
size_t i = 0; i < update_ptr->
nodes_count; i++) {
1599 update_semantics_node_callback(&update_ptr->
nodes[i],
user_data);
1600 }
1601 }
1602
1603 if (update_semantics_custom_action_callback != nullptr) {
1605 update_semantics_custom_action_callback(&update_ptr->
custom_actions[i],
1607 }
1608 }
1609
1610
1611
1612 if (update_semantics_node_callback != nullptr) {
1616 };
1617 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1618 }
1619
1620 if (update_semantics_custom_action_callback != nullptr) {
1624 };
1625 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1626 }
1627 };
1628}
1629
1630
1631
1636 return [update_semantics_callback,
user_data](
1640
1642 };
1643}
1644
1645
1646
1651 return [update_semantics_callback,
user_data](
1655
1657 };
1658}
1659
1660
1661
1662
1666
1667
1668
1669
1670
1671 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1674 }
1675
1676
1677
1678 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1681 }
1682
1683
1684
1685
1687 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1688 update_semantics_node_callback =
args->update_semantics_node_callback;
1689 }
1690
1692 update_semantics_custom_action_callback = nullptr;
1693 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1694 nullptr) {
1695 update_semantics_custom_action_callback =
1696 args->update_semantics_custom_action_callback;
1697 }
1698
1699 if (update_semantics_node_callback != nullptr ||
1700 update_semantics_custom_action_callback != nullptr) {
1702 update_semantics_node_callback, update_semantics_custom_action_callback,
1704 }
1705
1706
1707 return nullptr;
1708}
1709
1715 engine_out) {
1718
1721 }
1722
1724}
1725
1731 engine_out) {
1732
1736 "Flutter embedder version mismatch. There has been a breaking change. "
1737 "Please consult the changelog and update the embedder.");
1738 }
1739
1740 if (engine_out == nullptr) {
1742 "The engine out parameter was missing.");
1743 }
1744
1745 if (
args ==
nullptr) {
1747 "The Flutter project arguments were missing.");
1748 }
1749
1753 "The assets path in the Flutter project arguments was missing.");
1754 }
1755
1758 << "FlutterProjectArgs.main_path is deprecated and should be set null.";
1759 }
1760
1762 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
1763 "should be set null.";
1764 }
1765
1768 "The renderer configuration was invalid.");
1769 }
1770
1771 std::string icu_data_path;
1774 }
1775
1777 std::string persistent_cache_path =
1780 }
1781
1784 }
1785
1792 }
1793
1795
1803 "Multiple AOT sources specified. Embedders should provide either "
1804 "*_snapshot_* buffers or aot_data, not both.");
1805 }
1806 }
1807
1810 } else {
1812 }
1813
1814 settings.icu_data_path = icu_data_path;
1818
1820
1827 "Not running in AOT mode but could not resolve the kernel binary.");
1828 }
1830 }
1831
1834 };
1835 settings.task_observer_remove = [](intptr_t
key) {
1837 };
1838 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
1841 settings.root_isolate_create_callback =
1843 }
1848 const std::string& tag,
1851 };
1852 }
1855 }
1856
1857 bool has_update_semantics_2_callback =
1859 bool has_update_semantics_callback =
1861 bool has_legacy_update_semantics_callback =
1862 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
1863 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1864 nullptr;
1865
1866 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
1867 (has_update_semantics_callback ? 1 : 0) +
1868 (has_legacy_update_semantics_callback ? 1 : 0);
1869
1870 if (semantic_callback_count > 1) {
1873 "Multiple semantics update callbacks provided. "
1874 "Embedders should provide either `update_semantics_callback2`, "
1875 "`update_semantics_callback`, or both "
1876 "`update_semantics_node_callback` and "
1877 "`update_semantics_custom_action_callback`.");
1878 }
1879
1881 update_semantics_callback =
1883
1885 platform_message_response_callback = nullptr;
1886 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
1887 platform_message_response_callback =
1888 [ptr =
args->platform_message_callback,
1896 handle,
1897 };
1898 handle->message = std::move(
message);
1899 return ptr(&incoming_message,
user_data);
1900 };
1901 }
1902
1905 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
1907 };
1908 }
1909
1911 compute_platform_resolved_locale_callback = nullptr;
1912 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
1913 nullptr) {
1914 compute_platform_resolved_locale_callback =
1915 [ptr =
args->compute_platform_resolved_locale_callback](
1916 const std::vector<std::string>& supported_locales_data) {
1917 const size_t number_of_strings_per_locale = 3;
1918 size_t locale_count =
1919 supported_locales_data.size() / number_of_strings_per_locale;
1920 std::vector<FlutterLocale> supported_locales;
1921 std::vector<const FlutterLocale*> supported_locales_ptr;
1922 for (size_t i = 0; i < locale_count; ++i) {
1923 supported_locales.push_back(
1925 .language_code =
1926 supported_locales_data[i * number_of_strings_per_locale +
1927 0]
1928 .c_str(),
1929 .country_code =
1930 supported_locales_data[i * number_of_strings_per_locale +
1931 1]
1932 .c_str(),
1933 .script_code =
1934 supported_locales_data[i * number_of_strings_per_locale +
1935 2]
1936 .c_str(),
1937 .variant_code = nullptr});
1938 supported_locales_ptr.push_back(&supported_locales[i]);
1939 }
1940
1942 ptr(supported_locales_ptr.data(), locale_count);
1943
1944 std::unique_ptr<std::vector<std::string>>
out =
1945 std::make_unique<std::vector<std::string>>();
1948 if (language_code != "") {
1949 out->push_back(language_code);
1952 }
1953 }
1955 };
1956 }
1957
1959 on_pre_engine_restart_callback = nullptr;
1960 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
1961 on_pre_engine_restart_callback = [ptr =
1962 args->on_pre_engine_restart_callback,
1964 }
1965
1967 nullptr;
1969 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
1970 const std::string&
name,
bool listening) {
1972 listening};
1974 };
1975 }
1976
1979 if (external_view_embedder_result.second) {
1981 "Compositor arguments were invalid.");
1982 }
1983
1985 {
1986 update_semantics_callback,
1987 platform_message_response_callback,
1988 vsync_callback,
1989 compute_platform_resolved_locale_callback,
1990 on_pre_engine_restart_callback,
1991 channel_update_callback,
1992 };
1993
1995 config,
user_data, platform_dispatch_table,
1996 std::move(external_view_embedder_result.first),
settings.enable_impeller);
1997
1998 if (!on_create_platform_view) {
2001 "Could not infer platform view creation callback.");
2002 }
2003
2006 return std::make_unique<flutter::Rasterizer>(shell);
2007 };
2008
2010 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2011 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2012
2013#ifdef SHELL_ENABLE_GL
2015 external_texture_callback;
2018 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2019 nullptr) != nullptr) {
2020 external_texture_callback =
2022 int64_t texture_identifier,
size_t width,
2023 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2024 std::unique_ptr<FlutterOpenGLTexture>
texture =
2025 std::make_unique<FlutterOpenGLTexture>();
2027 return nullptr;
2028 }
2030 };
2031 external_texture_resolver =
2032 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2033 }
2034 }
2035#endif
2036#ifdef SHELL_ENABLE_METAL
2038 external_texture_metal_callback;
2041 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2042 external_texture_metal_callback =
2044 int64_t texture_identifier,
size_t width,
2045 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2046 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2047 std::make_unique<FlutterMetalExternalTexture>();
2050 return nullptr;
2051 }
2053 };
2054 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2055 external_texture_metal_callback);
2056 }
2057 }
2058#endif
2059 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2060 auto thread_config_callback = [&custom_task_runners](
2063 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2064 return;
2065 }
2067 switch (config.priority) {
2070 break;
2073 break;
2076 break;
2079 break;
2080 }
2081 custom_task_runners->thread_priority_setter(priority);
2082 };
2083 auto thread_host =
2085 custom_task_runners, thread_config_callback);
2086
2087 if (!thread_host || !thread_host->IsValid()) {
2089 "Could not set up or infer thread configuration "
2090 "to run the Flutter engine on.");
2091 }
2092
2093 auto task_runners = thread_host->GetTaskRunners();
2094
2095 if (!task_runners.IsValid()) {
2097 "Task runner configuration was invalid.");
2098 }
2099
2100 auto run_configuration =
2102
2104 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2105 if (!dart_entrypoint.empty()) {
2106 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2107 }
2108 }
2109
2113 "Could not determine Dart entrypoint arguments "
2114 "as dart_entrypoint_argc "
2115 "was set, but dart_entrypoint_argv was null.");
2116 }
2117 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2118 for (
int i = 0; i <
args->dart_entrypoint_argc; ++i) {
2119 arguments[i] = std::string{
args->dart_entrypoint_argv[i]};
2120 }
2121 run_configuration.SetEntrypointArgs(std::move(arguments));
2122 }
2123
2124 if (!run_configuration.IsValid()) {
2127 "Could not infer the Flutter project to run from given arguments.");
2128 }
2129
2130
2131 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2132 std::move(thread_host),
2133 std::move(task_runners),
2134 std::move(settings),
2135 std::move(run_configuration),
2136 on_create_platform_view,
2137 on_create_rasterizer,
2138 std::move(external_texture_resolver)
2139 );
2140
2141
2143 embedder_engine.release());
2145}
2146
2151 }
2152
2154
2155
2156
2157 if (embedder_engine->IsValid()) {
2159 }
2160
2161
2162 if (!embedder_engine->LaunchShell()) {
2164 "Could not launch the engine using supplied "
2165 "initialization arguments.");
2166 }
2167
2168
2169 if (!embedder_engine->NotifyCreated()) {
2171 "Could not create platform view components.");
2172 }
2173
2174
2175 if (!embedder_engine->RunRootIsolate()) {
2178 "Could not run the root isolate of the Flutter application using the "
2179 "project arguments specified.");
2180 }
2181
2183}
2184
2191 }
2192 if (!
info || !
info->view_metrics || !
info->add_view_callback) {
2194 "Add view info handle was invalid.");
2195 }
2196
2201 "Add view info was invalid. The implicit view cannot be added.");
2202 }
2204 view_id) {
2207 "Add view info was invalid. The info and "
2208 "window metric view IDs must match.");
2209 }
2210 }
2211
2212
2213
2214
2215
2216 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2218
2219 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2221 }
2222
2223 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2224
2225
2227 if (!embedder_engine->IsValid()) {
2229 }
2230
2232 [c_callback =
info->add_view_callback,
2239 };
2240
2241 embedder_engine->GetShell().GetPlatformView()->AddView(view_id, metrics,
2244}
2245
2252 }
2253 if (!
info || !
info->remove_view_callback) {
2255 "Remove view info handle was invalid.");
2256 }
2257
2261 "Remove view info was invalid. The implicit view cannot be removed.");
2262 }
2263
2264
2265
2266
2267
2268
2270 if (!embedder_engine->IsValid()) {
2272 }
2273
2275 [c_callback =
info->remove_view_callback,
2279 result.removed = removed;
2282 };
2283
2284 embedder_engine->GetShell().GetPlatformView()->RemoveView(
info->view_id,
2287}
2288
2294 }
2295
2298 embedder_engine->CollectShell();
2300}
2301
2307 }
2309 delete embedder_engine;
2311}
2312
2316 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2318 }
2321
2322 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2324 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2326 }
2327
2328 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2329
2331 view_id, metrics)
2334 "Viewport metrics were invalid.");
2335}
2336
2337
2340 switch (phase) {
2361 }
2363}
2364
2365
2366
2369 switch (device_kind) {
2378 }
2380}
2381
2382
2383
2386 switch (kind) {
2395 }
2397}
2398
2399
2400
2403 switch (change) {
2406
2407
2417 return 0;
2418 }
2419 return 0;
2420}
2421
2425 size_t events_count) {
2428 }
2429
2430 if (pointers == nullptr || events_count == 0) {
2432 }
2433
2434 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2435
2437
2438 for (size_t i = 0; i < events_count; ++i) {
2440 pointer_data.
Clear();
2441
2448
2452
2453
2461
2462
2463
2464 if (device_kind == 0) {
2468
2469 } else {
2472
2473
2477 }
2478 } else {
2479
2481 }
2482 }
2485
2492 packet->SetPointerData(i, pointer_data);
2494 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2495 }
2496
2498 ->DispatchPointerDataPacket(std::move(packet))
2501 "Could not dispatch pointer events to the "
2502 "running Flutter application.");
2503}
2504
2507 switch (event_kind) {
2514 }
2516}
2517
2520 switch (event_kind) {
2531 }
2533}
2534
2535
2536
2537
2540 const char* channel,
2541 const uint8_t* data,
2542 size_t size,
2546
2552 }
2553
2556 channel,
2557 data,
2558 size,
2559 response_handle,
2560 };
2561
2563
2564
2569 }
2570
2571 return release_result;
2572}
2573
2581 }
2582
2583 if (
event ==
nullptr) {
2585 }
2586
2588
2600
2601 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2602
2603 struct MessageData {
2606 };
2607
2608 MessageData* message_data =
2610
2613 packet->data().size(),
2614 [](
const uint8_t* data,
size_t size,
void*
user_data) {
2615 auto message_data = std::unique_ptr<MessageData>(
2616 reinterpret_cast<MessageData*>(user_data));
2617 if (message_data->callback == nullptr) {
2618 return;
2619 }
2620 bool handled = false;
2621 if (size == 1) {
2622 handled = *
data != 0;
2623 }
2624 message_data->callback(handled, message_data->user_data);
2625 },
2626 message_data);
2627}
2628
2634 }
2635
2636 if (flutter_message == nullptr) {
2638 }
2639
2640 if (
SAFE_ACCESS(flutter_message, channel,
nullptr) ==
nullptr) {
2643 }
2644
2645 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
2647
2648 if (message_size != 0 && message_data == nullptr) {
2651 "Message size was non-zero but the message data was nullptr.");
2652 }
2653
2655 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
2656
2658 if (response_handle && response_handle->
message) {
2659 response = response_handle->
message->response();
2660 }
2661
2662 std::unique_ptr<flutter::PlatformMessage>
message;
2663 if (message_size == 0) {
2664 message = std::make_unique<flutter::PlatformMessage>(
2665 flutter_message->
channel, response);
2666 } else {
2667 message = std::make_unique<flutter::PlatformMessage>(
2670 }
2671
2673 ->SendPlatformMessage(std::move(
message))
2676 "Could not send a message to the running "
2677 "Flutter application.");
2678}
2679
2687 }
2688
2689 if (data_callback == nullptr || response_out == nullptr) {
2692 }
2693
2697 };
2698
2700 ->GetTaskRunners()
2701 .GetPlatformTaskRunner();
2702
2704
2705 handle->message = std::make_unique<flutter::PlatformMessage>(
2706 "",
2707
2708
2709 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
2710 std::move(platform_task_runner), response_callback));
2711 *response_out = handle;
2713}
2714
2720 }
2721
2722 if (response == nullptr) {
2724 }
2725 delete response;
2727}
2728
2729
2733 const uint8_t* data,
2734 size_t data_length) {
2735 if (data_length != 0 && data == nullptr) {
2738 "Data size was non zero but the pointer to the data was null.");
2739 }
2740
2741 auto response = handle->
message->response();
2742
2743 if (response) {
2744 if (data_length == 0) {
2745 response->CompleteEmpty();
2746 } else {
2747 response->Complete(std::make_unique<fml::DataMapping>(
2748 std::vector<uint8_t>({
data,
data + data_length})));
2749 }
2750 }
2751
2752 delete handle;
2753
2755}
2756
2760}
2761
2764 int64_t texture_identifier) {
2767 }
2768
2769 if (texture_identifier == 0) {
2771 "Texture identifier was invalid.");
2772 }
2774 texture_identifier)) {
2776 "Could not register the specified texture.");
2777 }
2779}
2780
2783 int64_t texture_identifier) {
2786 }
2787
2788 if (texture_identifier == 0) {
2790 "Texture identifier was invalid.");
2791 }
2792
2794 texture_identifier)) {
2796 "Could not un-register the specified texture.");
2797 }
2798
2800}
2801
2804 int64_t texture_identifier) {
2807 }
2808 if (texture_identifier == 0) {
2810 }
2812 ->MarkTextureFrameAvailable(texture_identifier)) {
2815 "Could not mark the texture frame as being available.");
2816 }
2818}
2819
2822 bool enabled) {
2825 }
2827 enabled)) {
2829 "Could not update semantics state.");
2830 }
2832}
2833
2839 }
2841 ->SetAccessibilityFeatures(
flags)) {
2843 "Could not update accessibility features.");
2844 }
2846}
2847
2850 uint64_t node_id,
2852 const uint8_t* data,
2853 size_t data_length) {
2856 }
2860 node_id, engine_action,
2863 "Could not dispatch semantics action.");
2864 }
2866}
2867
2870 intptr_t baton,
2871 uint64_t frame_start_time_nanos,
2872 uint64_t frame_target_time_nanos) {
2875 }
2876
2878
2881
2884
2886 baton, start_time, target_time)) {
2889 "Could not notify the running engine instance of a Vsync event.");
2890 }
2891
2893}
2894
2899 }
2900
2901 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
2902
2904 ->ReloadSystemFonts()) {
2906 "Could not reload system fonts.");
2907 }
2908
2910}
2911
2914 nullptr);
2915}
2916
2919}
2920
2923 nullptr);
2924}
2925
2929 void* baton) {
2932 }
2933
2936 "Render thread callback was null.");
2937 }
2938
2940
2942 ->PostRenderThreadTask(task)
2945 "Could not post the render thread task.");
2946}
2947
2950}
2951
2957 }
2958
2962 "Could not run the specified task.");
2963}
2964
2967 const rapidjson::Document& document,
2968 const std::string& channel_name) {
2969 if (channel_name.empty()) {
2970 return false;
2971 }
2972
2973 rapidjson::StringBuffer
buffer;
2974 rapidjson::Writer<rapidjson::StringBuffer> writer(
buffer);
2975
2976 if (!document.Accept(writer)) {
2977 return false;
2978 }
2979
2981
2983 return false;
2984 }
2985
2986 auto platform_message = std::make_unique<flutter::PlatformMessage>(
2987 channel_name.c_str(),
2990 nullptr
2991 );
2992
2994 ->SendPlatformMessage(std::move(platform_message));
2995}
2996
3000 size_t locales_count) {
3003 }
3004
3005 if (locales_count == 0) {
3007 }
3008
3009 if (locales == nullptr) {
3011 }
3012
3013 rapidjson::Document document;
3014 auto& allocator = document.GetAllocator();
3015
3016 document.SetObject();
3017 document.AddMember("method", "setLocale", allocator);
3018
3019 rapidjson::Value
args(rapidjson::kArrayType);
3020 args.Reserve(locales_count * 4, allocator);
3021 for (size_t i = 0; i < locales_count; ++i) {
3023 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3024 if (language_code_str == nullptr || ::strlen(language_code_str) == 0) {
3027 "Language code is required but not present in FlutterLocale.");
3028 }
3029
3030 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3031 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3032 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3033
3034 rapidjson::Value language_code, country_code, script_code, variant_code;
3035
3036 language_code.SetString(language_code_str, allocator);
3037 country_code.SetString(country_code_str ? country_code_str : "", allocator);
3038 script_code.SetString(script_code_str ? script_code_str : "", allocator);
3039 variant_code.SetString(variant_code_str ? variant_code_str : "", allocator);
3040
3041
3042 args.PushBack(language_code, allocator);
3043 args.PushBack(country_code, allocator);
3044 args.PushBack(script_code, allocator);
3045 args.PushBack(variant_code, allocator);
3046 }
3047 document.AddMember(
"args",
args, allocator);
3048
3052 "Could not send message to update locale of "
3053 "a running Flutter application.");
3054}
3055
3058}
3059
3066 }
3067
3070 }
3071
3074 "Attempted to post to an illegal port.");
3075 }
3076
3077 if (object == nullptr) {
3079 "Invalid Dart object to post.");
3080 }
3081
3084
3085 switch (object->
type) {
3088 break;
3092 break;
3096 break;
3100 break;
3104 break;
3108 "kFlutterEngineDartObjectTypeString must be "
3109 "a null terminated string but was null.");
3110 }
3112 dart_object.
value.
as_string =
const_cast<char*
>(
object->string_value);
3113 break;
3118 "kFlutterEngineDartObjectTypeBuffer must "
3119 "specify a buffer but found nullptr.");
3120 }
3125
3126
3127
3128
3134 } else {
3135 struct ExternalTypedDataPeer {
3138 };
3139 auto peer = new ExternalTypedDataPeer();
3142
3143
3144
3145
3146
3148
3149
3150
3151
3152 delete peer;
3153 });
3160 +[](void* unused_isolate_callback_data, void* peer) {
3161 auto typed_peer = reinterpret_cast<ExternalTypedDataPeer*>(peer);
3162 typed_peer->trampoline(typed_peer->user_data);
3163 delete typed_peer;
3164 };
3165 }
3166 } break;
3167 default:
3170 "Invalid FlutterEngineDartObjectType type specified.");
3171 }
3172
3175 "Could not post the object to the Dart VM.");
3176 }
3177
3178
3179
3180 typed_data_finalizer.
Release();
3182}
3183
3189 }
3190
3191 engine->GetShell().NotifyLowMemoryWarning();
3192
3193 rapidjson::Document document;
3194 auto& allocator = document.GetAllocator();
3195
3196 document.SetObject();
3197 document.AddMember("type", "memoryPressure", allocator);
3198
3203 "Could not dispatch the low memory notification message.");
3204}
3205
3212 }
3213
3216 "Invalid native thread callback.");
3217 }
3218
3220 ->PostTaskOnEngineManagedNativeThreads(
3223 })
3226 "Internal error while attempting to post "
3227 "tasks to all threads.");
3228}
3229
3230namespace {
3232 size_t display_count) {
3233 std::set<FlutterEngineDisplayId> display_ids;
3234 for (size_t i = 0; i < display_count; i++) {
3235 if (displays[i].single_display && display_count != 1) {
3236 return false;
3237 }
3238 display_ids.insert(displays[i].display_id);
3239 }
3240
3241 return display_ids.size() == display_count;
3242}
3243}
3244
3249 size_t display_count) {
3250 if (raw_engine == nullptr) {
3252 }
3253
3254 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3257 "Invalid FlutterEngineDisplay configuration specified.");
3258 }
3259
3261
3262 switch (update_type) {
3264 std::vector<std::unique_ptr<flutter::Display>> displays;
3265 const auto* display = embedder_displays;
3266 for (size_t i = 0; i < display_count; i++) {
3267 displays.push_back(std::make_unique<flutter::Display>(
3274 reinterpret_cast<const uint8_t*>(display) + display->struct_size);
3275 }
3276 engine->GetShell().OnDisplayUpdates(std::move(displays));
3278 }
3279 default:
3282 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3283 }
3284}
3285
3290 }
3291
3295 "Could not schedule frame.");
3296}
3297
3304 }
3305
3308 "Next frame callback was null.");
3309 }
3310
3313
3316
3317 if (!weak_platform_view) {
3319 "Platform view unavailable.");
3320 }
3321
3322 weak_platform_view->SetNextFrameCallback(
3324
3326}
3327
3332 }
3333#define SET_PROC(member, function) \
3334 if (STRUCT_HAS_MEMBER(table, member)) { \
3335 table->member = &function; \
3336 }
3337
3349 SET_PROC(PlatformMessageCreateResponseHandle,
3351 SET_PROC(PlatformMessageReleaseResponseHandle,
3353 SET_PROC(SendPlatformMessageResponse,
3357 SET_PROC(MarkExternalTextureFrameAvailable,
3360 SET_PROC(UpdateAccessibilityFeatures,
3375 SET_PROC(PostCallbackOnAllNativeThreads,
3382#undef SET_PROC
3383
3385}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kUnknown_SkPixelGeometry
static sk_sp< SkColorSpace > MakeSRGB()
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
bool DispatchSemanticsAction(int node_id, flutter::SemanticsAction action, fml::MallocMapping args)
std::function< std::unique_ptr< FlutterOpenGLTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
std::function< std::unique_ptr< FlutterMetalExternalTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
std::function< bool(FlutterViewId view_id, const std::vector< const FlutterLayer * > &layers)> PresentCallback
std::function< std::unique_ptr< EmbedderRenderTarget >(GrDirectContext *context, const std::shared_ptr< impeller::AiksContext > &aiks_context, const FlutterBackingStoreConfig &config)> CreateRenderTargetCallback
static std::unique_ptr< EmbedderThreadHost > CreateEmbedderOrEngineManagedThreadHost(const FlutterCustomTaskRunners *custom_task_runners, const flutter::ThreadConfigSetter &config_setter=fml::Thread::SetCurrentThreadName)
std::function< void *(const char *)> GLProcResolver
static SkColorType ColorTypeFromFormat(const VkFormat format)
static void SetCacheDirectoryPath(std::string path)
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
fml::WeakPtr< PlatformView > GetPlatformView()
Platform views may only be accessed on the platform task runner.
std::function< void(intptr_t)> VsyncCallback
static std::unique_ptr< FileMapping > CreateReadExecute(const std::string &path)
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
static MallocMapping Copy(const T *begin, const T *end)
void RemoveTaskObserver(intptr_t key)
void AddTaskObserver(intptr_t key, const fml::closure &callback)
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
void RunExpiredTasksNow()
static fml::RefPtr< NativeLibrary > CreateForCurrentProcess()
static fml::RefPtr< NativeLibrary > Create(const char *path)
Wraps a closure that is invoked in the destructor unless released by the caller.
fml::closure SetClosure(const fml::closure &closure)
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
@ kDisplay
Suitable for threads which generate data for the display.
static void SetCurrentThreadName(const ThreadConfig &config)
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
constexpr int64_t ToNanoseconds() const
TimeDelta ToEpochDelta() const
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
static ContextGLES & Cast(Context &base)
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
RenderTarget & SetDepthAttachment(std::optional< DepthAttachment > attachment)
RenderTarget & SetStencilAttachment(std::optional< StencilAttachment > attachment)
static std::shared_ptr< TextureGLES > WrapFBO(ReactorGLES::Ref reactor, TextureDescriptor desc, GLuint fbo)
@ Dart_CObject_kTypedData
@ Dart_CObject_kExternalTypedData
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject *message)
#define SET_PROC(member, function)
void FlutterEngineTraceEventInstant(const char *name)
A profiling utility. Logs a trace duration instant event to the timeline. If the timeline is unavaila...
static FlutterEngineResult InternalSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const char *channel, const uint8_t *data, size_t size, FlutterDataCallback data_callback, void *user_data)
FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Mark that a new texture frame is available for a given texture identifier.
FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task)
Inform the engine to run the specified task. This task has been given to the engine via the FlutterTa...
FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos)
Notify the engine that a vsync event occurred. A baton passed to the platform via the vsync callback ...
const int32_t kFlutterSemanticsNodeIdBatchEnd
const int32_t kFlutterSemanticsCustomActionIdBatchEnd
static bool IsMetalRendererConfigValid(const FlutterRendererConfig *config)
FlutterEngineResult FlutterEngineRun(size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
Initialize and run a Flutter engine instance and return a handle to it. This is a convenience method ...
FlutterEngineResult FlutterEngineRegisterExternalTexture(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Register an external texture with a unique (per engine) identifier. Only rendering backends that supp...
FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)
Notify a running engine instance that the locale has been updated. The preferred locale must be the f...
const uint8_t kPlatformStrongDill[]
static flutter::Shell::CreateCallback< flutter::PlatformView > InferPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller)
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
static flutter::Shell::CreateCallback< flutter::PlatformView > InferVulkanPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder)
static bool DispatchJSONPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const rapidjson::Document &document, const std::string &channel_name)
FlutterEngineResult FlutterEngineScheduleFrame(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Schedule a new frame to redraw the content.
void FlutterEngineTraceEventDurationBegin(const char *name)
A profiling utility. Logs a trace duration begin event to the timeline. If the timeline is unavailabl...
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
flutter::PointerData::SignalKind ToPointerDataSignalKind(FlutterPointerSignalKind kind)
static std::pair< std::unique_ptr< flutter::EmbedderExternalViewEmbedder >, bool > InferExternalViewEmbedderFromArgs(const FlutterCompositor *compositor, bool enable_impeller)
uint64_t FlutterEngineGetCurrentTime()
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system mon...
static bool IsOpenGLRendererConfigValid(const FlutterRendererConfig *config)
FlutterEngineResult FlutterEngineSetNextFrameCallback(FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *user_data)
Schedule a callback to be called after the next frame is drawn. This must be called from the platform...
FlutterEngineResult __FlutterEngineFlushPendingTasksNow()
This API is only meant to be used by platforms that need to flush tasks on a message loop not control...
#define LOG_EMBEDDER_ERROR(code, reason)
FlutterEngineResult FlutterEnginePostRenderThreadTask(FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *baton)
Posts a task onto the Flutter render thread. Typically, this may be called from any thread as long as...
static flutter::KeyEventDeviceType MapKeyEventDeviceType(FlutterKeyEventDeviceType event_kind)
static bool IsRendererValid(const FlutterRendererConfig *config)
static std::unique_ptr< flutter::EmbedderRenderTarget > MakeRenderTargetFromBackingStoreImpeller(FlutterBackingStore backing_store, const fml::closure &on_release, const std::shared_ptr< impeller::AiksContext > &aiks_context, const FlutterBackingStoreConfig &config, const FlutterOpenGLFramebuffer *framebuffer)
std::unique_ptr< Dart_LoadedElf, LoadedElfDeleter > UniqueLoadedElf
FlutterEngineResult FlutterEngineDispatchSemanticsAction(FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t node_id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
Dispatch a semantics action to the specified semantics node.
FlutterEngineResult FlutterEnginePostDartObject(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDartPort port, const FlutterEngineDartObject *object)
Posts a Dart object to specified send port. The corresponding receive port for send port can be in an...
flutter::PointerData::DeviceKind ToPointerDataKind(FlutterPointerDeviceKind device_kind)
FLUTTER_EXPORT FlutterEngineResult FlutterEngineDeinitialize(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Stops running the Flutter engine instance. After this call, the embedder is also guaranteed that no m...
static sk_sp< SkSurface > MakeSkSurfaceFromBackingStore(GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterOpenGLTexture *texture)
flutter::PointerData::Change ToPointerDataChange(FlutterPointerPhase phase)
static constexpr FlutterViewId kFlutterImplicitViewId
FlutterEngineResult FlutterEnginePostCallbackOnAllNativeThreads(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data)
Schedule a callback to be run on all engine managed threads. The engine will attempt to service this ...
FLUTTER_EXPORT FlutterEngineResult FlutterEngineAddView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterAddViewInfo *info)
Adds a view.
FlutterEngineResult FlutterEngineInitialize(size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
Initialize a Flutter engine instance. This does not run the Flutter application code till the Flutter...
static std::unique_ptr< flutter::EmbedderRenderTarget > CreateEmbedderRenderTarget(const FlutterCompositor *compositor, const FlutterBackingStoreConfig &config, GrDirectContext *context, const std::shared_ptr< impeller::AiksContext > &aiks_context, bool enable_impeller)
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV3(FlutterUpdateSemanticsCallback2 update_semantics_callback, void *user_data)
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature flags)
Sets additional accessibility features.
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embed...
static std::unique_ptr< flutter::EmbedderRenderTarget > MakeRenderTargetFromSkSurface(FlutterBackingStore backing_store, sk_sp< SkSurface > skia_surface, fml::closure on_release)
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)
Creates a platform message response handle that allows the embedder to set a native callback for a re...
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
FlutterEngineResult FlutterEngineNotifyDisplayUpdate(FLUTTER_API_SYMBOL(FlutterEngine) raw_engine, const FlutterEngineDisplaysUpdateType update_type, const FlutterEngineDisplay *embedder_displays, size_t display_count)
Posts updates corresponding to display changes to a running engine instance.
FlutterEngineResult FlutterEngineSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message)
bool FlutterEngineRunsAOTCompiledDartCode(void)
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading re...
FlutterEngineResult FlutterEngineReloadSystemFonts(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Reloads the system fonts in engine.
static flutter::KeyEventType MapKeyEventType(FlutterKeyEventType event_kind)
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallback(const FlutterProjectArgs *args, void *user_data)
static flutter::Shell::CreateCallback< flutter::PlatformView > InferSoftwarePlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder)
const intptr_t kPlatformStrongDillSize
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV1(FlutterUpdateSemanticsNodeCallback update_semantics_node_callback, FlutterUpdateSemanticsCustomActionCallback update_semantics_custom_action_callback, void *user_data)
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
FlutterEngineResult FlutterEngineRunInitialized(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize....
static bool IsSoftwareRendererConfigValid(const FlutterRendererConfig *config)
static flutter::Shell::CreateCallback< flutter::PlatformView > InferOpenGLPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller)
void PopulateJITSnapshotMappingCallbacks(const FlutterProjectArgs *args, flutter::Settings &settings)
static bool IsVulkanRendererConfigValid(const FlutterRendererConfig *config)
FlutterEngineResult FlutterEngineNotifyLowMemoryWarning(FLUTTER_API_SYMBOL(FlutterEngine) raw_engine)
Posts a low memory notification to a running engine instance. The engine will do its best to release ...
FlutterEngineResult FlutterEngineUnregisterExternalTexture(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Unregister a previous texture registration.
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled(FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
Enable or disable accessibility semantics.
FlutterEngineResult FlutterEngineSendKeyEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Sends a key event to the engine. The framework will decide whether to handle this event in a synchron...
static flutter::Shell::CreateCallback< flutter::PlatformView > InferMetalPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller)
void FlutterEngineTraceEventDurationEnd(const char *name)
A profiling utility. Logs a trace duration end event to the timeline. If the timeline is unavailable ...
FlutterEngineResult FlutterEngineSendPlatformMessageResponse(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Send a response from the native side to a platform message from the Dart Flutter application.
const char * kFlutterKeyDataChannel
FLUTTER_EXPORT FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo *info)
Removes a view.
int64_t PointerDataButtonsForLegacyEvent(flutter::PointerData::Change change)
void PopulateAOTSnapshotMappingCallbacks(const FlutterProjectArgs *args, flutter::Settings &settings)
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV2(FlutterUpdateSemanticsCallback update_semantics_callback, void *user_data)
static std::variant< flutter::ViewportMetrics, std::string > MakeViewportMetricsFromWindowMetrics(const FlutterWindowMetricsEvent *flutter_metrics)
FlutterEngineResult FlutterEngineCreateAOTData(const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
Creates the necessary data structures to launch a Flutter Dart application in AOT mode....
#define FLUTTER_API_SYMBOL(symbol)
FlutterKeyEventDeviceType
@ kFlutterKeyEventDeviceTypeKeyboard
@ kFlutterKeyEventDeviceTypeDirectionalPad
@ kFlutterKeyEventDeviceTypeHdmi
@ kFlutterKeyEventDeviceTypeJoystick
@ kFlutterKeyEventDeviceTypeGamepad
void(* FlutterUpdateSemanticsCustomActionCallback)(const FlutterSemanticsCustomAction *, void *)
void(* FlutterUpdateSemanticsCallback)(const FlutterSemanticsUpdate *, void *)
@ kFlutterEngineAOTDataSourceTypeElfPath
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
void(* FlutterDataCallback)(const uint8_t *, size_t, void *)
FlutterPointerPhase
The phase of the pointer event.
@ kPanZoomUpdate
The pan/zoom updated.
@ kHover
The pointer moved while up.
@ kPanZoomStart
A pan/zoom started on this pointer.
@ kPanZoomEnd
The pan/zoom ended.
FlutterAccessibilityFeature
void(* FlutterNativeThreadCallback)(FlutterNativeThreadType type, void *user_data)
@ kFlutterEngineDartObjectTypeString
@ kFlutterEngineDartObjectTypeBool
@ kFlutterEngineDartObjectTypeDouble
@ kFlutterEngineDartObjectTypeInt32
@ kFlutterEngineDartObjectTypeBuffer
@ kFlutterEngineDartObjectTypeInt64
@ kFlutterEngineDartObjectTypeNull
void(* FlutterLogMessageCallback)(const char *, const char *, void *)
FlutterPointerSignalKind
The type of a pointer signal.
@ kFlutterPointerSignalKindScale
@ kFlutterPointerSignalKindScrollInertiaCancel
@ kFlutterPointerSignalKindScroll
@ kFlutterPointerSignalKindNone
void(* FlutterUpdateSemanticsNodeCallback)(const FlutterSemanticsNode *, void *)
FlutterEngineDisplaysUpdateType
@ kFlutterEngineDisplaysUpdateTypeStartup
FlutterThreadPriority
Valid values for priority of Thread.
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
@ kDisplay
Suitable for threads which generate data for the display.
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
void(* FlutterKeyEventCallback)(bool, void *)
@ kFlutterKeyEventTypeDown
@ kFlutterKeyEventTypeRepeat
void(* FlutterUpdateSemanticsCallback2)(const FlutterSemanticsUpdate2 *, void *)
int64_t FlutterEngineDartPort
@ kFlutterOpenGLTargetTypeFramebuffer
@ kFlutterOpenGLTargetTypeTexture
@ kFlutterBackingStoreTypeSoftware2
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
@ kFlutterBackingStoreTypeVulkan
Specifies a Vulkan backing store. This is backed by a Vulkan VkImage.
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
@ kFlutterBackingStoreTypeOpenGL
#define FLUTTER_ENGINE_VERSION
FlutterPointerDeviceKind
The device type that created a pointer event.
@ kFlutterPointerDeviceKindTouch
@ kFlutterPointerDeviceKindTrackpad
@ kFlutterPointerDeviceKindStylus
@ kFlutterPointerDeviceKindMouse
#define SAFE_EXISTS(pointer, member)
Checks if the member exists and is non-null.
#define SAFE_ACCESS(pointer, member, default_value)
#define SAFE_EXISTS_ONE_OF(pointer, member1, member2)
Checks if exactly one of member1 or member2 exists and is non-null.
VkPhysicalDevice physical_device
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
#define FML_LOG(severity)
#define FML_DCHECK(condition)
static const char * kApplicationKernelSnapshotFileName
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
SK_API GrBackendTexture MakeMtl(int width, int height, skgpu::Mipmapped, const GrMtlTextureInfo &mtlInfo, std::string_view label={})
SK_API GrBackendTexture MakeVk(int width, int height, const GrVkImageInfo &, std::string_view label={})
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
void(*)(ReleaseContext) RenderTargetReleaseProc
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
void(*)(ReleaseContext) TextureReleaseProc
void * GPUMTLDeviceHandle
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
@ kPointerButtonMousePrimary
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
@ kPointerButtonTouchContact
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
void * GPUMTLCommandQueueHandle
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::string JoinPaths(std::initializer_list< std::string > components)
void TraceEventInstant0(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids)
void TraceEvent0(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids)
void TraceEventEnd(TraceArg name)
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
internal::CopyableLambda< T > MakeCopyable(T lambda)
bool IsFile(const std::string &path)
std::function< void()> closure
std::shared_ptr< Texture > WrapTextureMTL(TextureDescriptor desc, const void *mtl_texture, std::function< void()> deletion_proc=nullptr)
FlutterSize size
The size of the render target the engine expects to render into.
FlutterVulkanBackingStore vulkan
FlutterMetalBackingStore metal
FlutterBackingStoreType type
Specifies the type of backing store.
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
FlutterSoftwareBackingStore software
The description of the software backing store.
FlutterSoftwareBackingStore2 software2
The description of the software backing store.
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStore).
An update to whether a message channel has a listener set or not.
FlutterBackingStoreCreateCallback create_backing_store_callback
FlutterBackingStoreCollectCallback collect_backing_store_callback
A structure to represent a damage region.
size_t num_rects
The number of rectangles within the damage region.
size_t struct_size
The size of this struct. Must be sizeof(FlutterDamage).
FlutterRect * damage
The actual damage region(s) in question.
FlutterEngineDartObjectType type
const char * string_value
const FlutterEngineDartBuffer * buffer_value
Function-pointer-based versions of the APIs above.
size_t struct_size
The size of this struct. Must be sizeof(FlutterFrameInfo).
FlutterUIntSize size
The size of the surface that will be backed by the fbo.
FlutterSize size
The size of the layer (in physical pixels).
FlutterMetalTextureHandle texture
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalTexture).
VoidCallback destruction_callback
FlutterOpenGLTexture texture
A texture for Flutter to render into.
FlutterOpenGLTargetType type
FlutterOpenGLFramebuffer framebuffer
uint32_t name
The name of the framebuffer.
VoidCallback destruction_callback
void * user_data
User data to be returned on the invocation of the destruction callback.
ProcResolver gl_proc_resolver
BoolCallback make_current
BoolPresentInfoCallback present_with_info
UIntCallback fbo_callback
TextureFrameCallback gl_external_texture_frame_callback
FlutterFrameBufferWithDamageCallback populate_existing_damage
TransformationCallback surface_transformation
BoolCallback make_resource_current
UIntFrameInfoCallback fbo_with_frame_info_callback
BoolCallback clear_current
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
size_t struct_size
The size of this struct. Must be sizeof(FlutterPresentInfo).
A structure to represent a rectangle.
FlutterVulkanRendererConfig vulkan
FlutterMetalRendererConfig metal
FlutterSoftwareRendererConfig software
FlutterOpenGLRendererConfig open_gl
FlutterSemanticsNode * nodes
size_t nodes_count
The number of semantics node updates.
size_t custom_actions_count
The number of semantics custom action updates.
FlutterSemanticsCustomAction * custom_actions
Array of semantics custom actions. Has length custom_actions_count.
VoidCallback destruction_callback
size_t row_bytes
The number of bytes in a single row of the allocation.
FlutterSoftwarePixelFormat pixel_format
VoidCallback destruction_callback
size_t row_bytes
The number of bytes in a single row of the allocation.
SoftwareSurfacePresentCallback surface_present_callback
size_t struct_size
The size of this struct. Must be sizeof(FlutterVulkanImage).
FlutterVulkanQueueHandle queue
FlutterVulkanDeviceHandle device
FlutterVulkanInstanceProcAddressCallback get_instance_proc_address_callback
size_t enabled_instance_extension_count
uint32_t queue_family_index
The queue family index of the VkQueue supplied in the next field.
FlutterVulkanImageCallback get_next_image_callback
const char ** enabled_instance_extensions
const char ** enabled_device_extensions
size_t enabled_device_extension_count
FlutterVulkanInstanceHandle instance
FlutterVulkanPresentCallback present_image_callback
FlutterVulkanPhysicalDeviceHandle physical_device
VkPhysicalDevice handle.
void operator()(Dart_LoadedElf *elf)
static constexpr SkIRect MakeEmpty()
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds
Dart_HandleFinalizer callback
union _Dart_CObject::@86 value
struct _Dart_CObject::@86::@90 as_typed_data
struct _Dart_CObject::@86::@91 as_external_typed_data
struct _Dart_CObject ** values
UniqueLoadedElf loaded_elf
const uint8_t * vm_isolate_instrs
const uint8_t * vm_snapshot_instrs
const uint8_t * vm_snapshot_data
const uint8_t * vm_isolate_data
PFN_vkGetInstanceProcAddr get_instance_proc_address
void * destruction_context
GPUMTLDestructionCallback destruction_callback
GPUMTLTextureHandle texture
KeyEventDeviceType device_type
int64_t pointer_identifier
double device_pixel_ratio
double physical_view_inset_bottom
double physical_view_inset_right
double physical_view_inset_top
double physical_view_inset_left
The ThreadConfig is the thread info include thread name, thread priority.
std::shared_ptr< Texture > resolve_texture
std::shared_ptr< Texture > texture
static constexpr Color DarkSlateGray()
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
DART_EXPORT Dart_LoadedElf * Dart_LoadELF(const char *filename, uint64_t file_offset, const char **error, const uint8_t **vm_snapshot_data, const uint8_t **vm_snapshot_instrs, const uint8_t **vm_isolate_data, const uint8_t **vm_isolate_instrs)
Please see documentation for Dart_LoadElf_Fd.
DART_EXPORT void Dart_UnloadELF(Dart_LoadedElf *loaded)
#define TRACE_EVENT0(category_group, name)
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetInstanceProcAddr)(VkInstance instance, const char *pName)