5#define FML_USED_ON_EMBEDDER
6#define RAPIDJSON_HAS_STDSTRING 1
23#include "third_party/dart/runtime/bin/elf_loader.h"
24#include "third_party/dart/runtime/include/dart_native_api.h"
25#include "third_party/skia/include/core/SkSurface.h"
26#include "third_party/skia/include/gpu/GpuTypes.h"
27#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
28#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
30#if !defined(FLUTTER_NO_EXPORT)
32#define FLUTTER_EXPORT __declspec(dllexport)
34#define FLUTTER_EXPORT __attribute__((visibility("default")))
39#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
69#include "rapidjson/rapidjson.h"
70#include "rapidjson/writer.h"
76#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
77#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
78#ifdef IMPELLER_SUPPORTS_RENDERING
90#ifdef SHELL_ENABLE_METAL
92#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlBackendSurface.h"
93#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h"
94#include "third_party/skia/include/ports/SkCFObject.h"
95#ifdef IMPELLER_SUPPORTS_RENDERING
104#ifdef SHELL_ENABLE_VULKAN
105#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
106#include "third_party/skia/include/gpu/ganesh/vk/GrVkTypes.h"
138 const char* code_name,
139 const char* function,
143 constexpr char kSeparator =
'\\';
145 constexpr char kSeparator =
'/';
147 const auto file_base =
148 (::strrchr(file, kSeparator) ? strrchr(file, kSeparator) + 1 : file);
149 char error[256] = {};
150 snprintf(
error, (
sizeof(
error) /
sizeof(
char)),
151 "%s (%d): '%s' returned '%s'. %s", file_base, line,
function,
153 std::cerr <<
error << std::endl;
157#define LOG_EMBEDDER_ERROR(code, reason) \
158 LogEmbedderError(code, reason, #code, __FUNCTION__, __FILE__, __LINE__)
170 fbo_with_frame_info_callback) ||
185 if (
SAFE_ACCESS(software_config, surface_present_callback,
nullptr) ==
202 SAFE_ACCESS(metal_config, present_command_queue,
nullptr);
204 bool present =
SAFE_ACCESS(metal_config, present_drawable_callback,
nullptr);
206 SAFE_ACCESS(metal_config, get_next_drawable_callback,
nullptr);
208 return device && command_queue && present && get_texture;
222 !
SAFE_EXISTS(vulkan_config, get_instance_proc_address_callback) ||
223 !
SAFE_EXISTS(vulkan_config, get_next_image_callback) ||
224 !
SAFE_EXISTS(vulkan_config, present_image_callback)) {
232 if (config ==
nullptr) {
236 switch (config->
type) {
252#if FML_OS_LINUX || FML_OS_WIN
253static void* DefaultGLProcResolver(
const char*
name) {
260 return static_cast<void*
>(
261 const_cast<uint8_t*
>(proc_library->ResolveSymbol(
name)));
265#ifdef SHELL_ENABLE_GL
270 static_cast<double>(dl_rect.
GetTop()),
271 static_cast<double>(dl_rect.
GetRight()),
272 static_cast<double>(dl_rect.
GetBottom())};
280 static_cast<int32_t
>(flutter_rect.
top),
281 static_cast<int32_t
>(flutter_rect.
right),
282 static_cast<int32_t
>(flutter_rect.
bottom));
288#define GL_BGRA8_EXT 0x93A1
291static std::optional<SkColorType> FlutterFormatToSkColorType(uint32_t format) {
294 return kBGRA_8888_SkColorType;
296 return kRGBA_8888_SkColorType;
299 <<
" to SkColorType.";
311 platform_dispatch_table,
312 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
313 external_view_embedder,
314 bool enable_impeller,
316#ifdef SHELL_ENABLE_GL
341 std::optional<FlutterRect> frame_damage_rect;
342 if (gl_present_info.frame_damage) {
344 DlIRectToFlutterRect(*(gl_present_info.frame_damage));
346 std::optional<FlutterRect> buffer_damage_rect;
347 if (gl_present_info.buffer_damage) {
349 DlIRectToFlutterRect(*(gl_present_info.buffer_damage));
354 .num_rects = frame_damage_rect ?
size_t{1} :
size_t{0},
355 .damage = frame_damage_rect ? &frame_damage_rect.value() :
nullptr,
359 .num_rects = buffer_damage_rect ?
size_t{1} :
size_t{0},
360 .damage = buffer_damage_rect ? &buffer_damage_rect.value() :
nullptr,
366 .fbo_id = gl_present_info.fbo_id,
367 .frame_damage = frame_damage,
368 .buffer_damage = buffer_damage,
371 return present_with_info(
user_data, &present_info);
375 auto gl_fbo_callback =
377 fbo_with_frame_info_callback =
385 frame_info.
size = {gl_frame_info.
width, gl_frame_info.height};
386 return fbo_with_frame_info_callback(
user_data, &frame_info);
390 auto gl_populate_existing_damage =
395 if (!populate_existing_damage) {
397 .
fbo_id =
static_cast<uint32_t
>(
id),
398 .existing_damage = std::nullopt,
404 populate_existing_damage(
user_data,
id, &existing_damage);
406 std::optional<flutter::DlIRect> existing_damage_rect = std::nullopt;
409 if (existing_damage.
num_rects <= 0 || existing_damage.
damage ==
nullptr) {
410 FML_LOG(INFO) <<
"No damage was provided. Forcing full repaint.";
413 for (
size_t i = 0;
i < existing_damage.
num_rects;
i++) {
414 existing_damage_rect = existing_damage_rect->Union(
415 FlutterRectToDlIRect(existing_damage.
damage[
i]));
421 .
fbo_id =
static_cast<uint32_t
>(
id),
422 .existing_damage = existing_damage_rect,
427 std::function<bool()> gl_make_resource_current_callback =
nullptr;
428 if (
SAFE_ACCESS(open_gl_config, make_resource_current,
nullptr) !=
nullptr) {
429 gl_make_resource_current_callback =
437 if (
SAFE_ACCESS(open_gl_config, surface_transformation,
nullptr) !=
nullptr) {
438 gl_surface_transformation_callback =
445 0.0f, 0.0f, 1.0f, 0.0f,
453 if (external_view_embedder) {
454 external_view_embedder->SetSurfaceTransformationCallback(
455 gl_surface_transformation_callback);
460 if (
SAFE_ACCESS(open_gl_config, gl_proc_resolver,
nullptr) !=
nullptr) {
466#if FML_OS_LINUX || FML_OS_WIN
467 gl_proc_resolver = DefaultGLProcResolver;
471 bool fbo_reset_after_present =
472 SAFE_ACCESS(open_gl_config, fbo_reset_after_present,
false);
479 gl_make_resource_current_callback,
480 gl_surface_transformation_callback,
482 gl_populate_existing_damage,
486 [gl_dispatch_table, fbo_reset_after_present, platform_dispatch_table,
487 enable_impeller, impeller_flags,
488 external_view_embedder =
489 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
490 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
491 std::move(external_view_embedder);
492 if (enable_impeller) {
493 return std::make_unique<flutter::PlatformViewEmbedder>(
496 std::make_unique<flutter::EmbedderSurfaceGLImpeller>(
497 gl_dispatch_table, fbo_reset_after_present, view_embedder,
499 platform_dispatch_table,
503 return std::make_unique<flutter::PlatformViewEmbedder>(
506 std::make_unique<flutter::EmbedderSurfaceGLSkia>(
507 gl_dispatch_table, fbo_reset_after_present,
509 platform_dispatch_table,
514 FML_LOG(ERROR) <<
"This Flutter Engine does not support OpenGL rendering.";
524 platform_dispatch_table,
525 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
526 external_view_embedder,
527 bool enable_impeller,
533#ifdef SHELL_ENABLE_METAL
543 return ptr(
user_data, &embedder_texture);
545 auto metal_get_texture =
550 frame_info.
size = {
static_cast<uint32_t
>(frame_size.width),
551 static_cast<uint32_t
>(frame_size.height)};
562 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
563 std::move(external_view_embedder);
568 view_embedder, platform_dispatch_table,
570 std::unique_ptr<flutter::EmbedderSurface> embedder_surface;
572 if (enable_impeller) {
574 metal_dispatch_table = {
576 .get_texture = metal_get_texture,
581 std::make_unique<flutter::EmbedderSurfaceMetalImpeller>(
585 metal_dispatch_table, view_embedder, impeller_flags);
589 metal_dispatch_table = {
591 .get_texture = metal_get_texture,
593 embedder_surface = std::make_unique<flutter::EmbedderSurfaceMetalSkia>(
597 metal_dispatch_table, view_embedder);
599 FML_LOG(FATAL) <<
"Impeller opt-out unavailable.";
603 return std::make_unique<flutter::PlatformViewEmbedder>(
606 std::move(embedder_surface),
607 platform_dispatch_table,
608 std::move(view_embedder)
612 FML_LOG(ERROR) <<
"This Flutter Engine does not support Metal rendering.";
622 platform_dispatch_table,
623 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
624 external_view_embedder,
625 bool enable_impeller,
631#ifdef SHELL_ENABLE_VULKAN
632 std::function<
void*(VkInstance,
const char*)>
633 vulkan_get_instance_proc_address =
635 VkInstance
instance,
const char* proc_name) ->
void* {
639 auto vulkan_get_next_image =
644 .size = {
static_cast<uint32_t
>(frame_size.width),
645 static_cast<uint32_t
>(frame_size.height)},
651 auto vulkan_present_image_callback =
662 auto vk_instance =
static_cast<VkInstance
>(config->
vulkan.
instance);
664 vulkan_get_instance_proc_address(vk_instance,
"vkGetInstanceProcAddr");
666 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
667 std::move(external_view_embedder);
669#if IMPELLER_SUPPORTS_RENDERING
670 if (enable_impeller) {
672 vulkan_dispatch_table = {
674 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
675 .get_next_image = vulkan_get_next_image,
676 .present_image = vulkan_present_image_callback,
679 std::unique_ptr<flutter::EmbedderSurfaceVulkanImpeller> embedder_surface =
680 std::make_unique<flutter::EmbedderSurfaceVulkanImpeller>(
689 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
690 view_embedder, impeller_flags);
693 [embedder_surface = std::move(embedder_surface),
694 platform_dispatch_table,
695 external_view_embedder =
697 return std::make_unique<flutter::PlatformViewEmbedder>(
700 std::move(embedder_surface),
701 platform_dispatch_table,
702 std::move(external_view_embedder)
709 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
710 .get_next_image = vulkan_get_next_image,
711 .present_image = vulkan_present_image_callback,
714 std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
715 std::make_unique<flutter::EmbedderSurfaceVulkan>(
724 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
728 [embedder_surface = std::move(embedder_surface),
729 platform_dispatch_table,
730 external_view_embedder =
732 return std::make_unique<flutter::PlatformViewEmbedder>(
735 std::move(embedder_surface),
736 platform_dispatch_table,
737 std::move(external_view_embedder)
744 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
745 .get_next_image = vulkan_get_next_image,
746 .present_image = vulkan_present_image_callback,
749 std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
750 std::make_unique<flutter::EmbedderSurfaceVulkan>(
759 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
763 [embedder_surface = std::move(embedder_surface), platform_dispatch_table,
764 external_view_embedder =
766 return std::make_unique<flutter::PlatformViewEmbedder>(
769 std::move(embedder_surface),
770 platform_dispatch_table,
771 std::move(external_view_embedder)
776 FML_LOG(ERROR) <<
"This Flutter Engine does not support Vulkan rendering.";
786 platform_dispatch_table,
787 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
788 external_view_embedder) {
793 auto software_present_backing_store =
795 const void* allocation,
size_t row_bytes,
size_t height) ->
bool {
800 software_dispatch_table = {
801 software_present_backing_store,
805 [software_dispatch_table, platform_dispatch_table,
806 external_view_embedder =
807 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
808 return std::make_unique<flutter::PlatformViewEmbedder>(
811 software_dispatch_table,
812 platform_dispatch_table,
813 std::move(external_view_embedder)
823 platform_dispatch_table,
824 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
825 external_view_embedder,
826 bool enable_impeller,
828 if (config ==
nullptr) {
832 switch (config->
type) {
835 config,
user_data, platform_dispatch_table,
836 std::move(external_view_embedder), enable_impeller, impeller_flags);
839 config,
user_data, platform_dispatch_table,
840 std::move(external_view_embedder));
843 config,
user_data, platform_dispatch_table,
844 std::move(external_view_embedder), enable_impeller, impeller_flags);
847 config,
user_data, platform_dispatch_table,
848 std::move(external_view_embedder), enable_impeller, impeller_flags);
856 GrDirectContext* context,
859#ifdef SHELL_ENABLE_GL
860 GrGLTextureInfo texture_info;
861 texture_info.fTarget =
texture->target;
862 texture_info.fID =
texture->name;
863 texture_info.fFormat =
texture->format;
865 GrBackendTexture backend_texture =
867 skgpu::Mipmapped::kNo, texture_info);
869 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
872 FlutterFormatToSkColorType(
texture->format);
877 auto surface = SkSurfaces::WrapBackendTexture(
880 kBottomLeft_GrSurfaceOrigin,
883 SkColorSpace::MakeSRGB(),
885 static_cast<SkSurfaces::TextureReleaseProc
>(
886 texture->destruction_callback),
891 FML_LOG(ERROR) <<
"Could not wrap embedder supplied render texture.";
902 GrDirectContext* context,
905#ifdef SHELL_ENABLE_GL
906 GrGLFramebufferInfo framebuffer_info = {};
907 framebuffer_info.fFormat = framebuffer->
target;
908 framebuffer_info.fFBOID = framebuffer->
name;
910 auto backend_render_target =
911 GrBackendRenderTargets::MakeGL(config.
size.
width,
918 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
921 FlutterFormatToSkColorType(framebuffer->
target);
926 auto surface = SkSurfaces::WrapBackendRenderTarget(
928 backend_render_target,
929 kBottomLeft_GrSurfaceOrigin,
931 SkColorSpace::MakeSRGB(),
933 static_cast<SkSurfaces::RenderTargetReleaseProc
>(
939 FML_LOG(ERROR) <<
"Could not wrap embedder supplied frame-buffer.";
949 GrDirectContext* context,
952#ifdef SHELL_ENABLE_GL
953 GrGLFramebufferInfo framebuffer_info = {};
955 framebuffer_info.fFBOID = 0;
957 auto backend_render_target =
958 GrBackendRenderTargets::MakeGL(config.
size.
width,
965 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
968 FlutterFormatToSkColorType(
surface->format);
973 auto sk_surface = SkSurfaces::WrapBackendRenderTarget(
975 backend_render_target,
976 kBottomLeft_GrSurfaceOrigin,
978 SkColorSpace::MakeSRGB(),
980 static_cast<SkSurfaces::RenderTargetReleaseProc
>(
981 surface->destruction_callback),
986 FML_LOG(ERROR) <<
"Could not wrap embedder supplied frame-buffer.";
996 GrDirectContext* context,
999 const auto image_info =
1006 auto captures = std::make_unique<Captures>();
1008 captures->user_data = software->
user_data;
1009 auto release_proc = [](
void* pixels,
void* context) {
1010 auto captures =
reinterpret_cast<Captures*
>(context);
1011 if (captures->destruction_callback) {
1012 captures->destruction_callback(captures->user_data);
1018 SkSurfaces::WrapPixels(image_info,
1027 <<
"Could not wrap embedder supplied software render buffer.";
1040 GrDirectContext* context,
1048 const auto image_info = SkImageInfo::Make(
1055 auto captures = std::make_unique<Captures>();
1057 captures->user_data = software->
user_data;
1058 auto release_proc = [](
void* pixels,
void* context) {
1059 auto captures =
reinterpret_cast<Captures*
>(context);
1060 if (captures->destruction_callback) {
1061 captures->destruction_callback(captures->user_data);
1066 SkSurfaces::WrapPixels(image_info,
1075 <<
"Could not wrap embedder supplied software render buffer.";
1085 GrDirectContext* context,
1088#if defined(SHELL_ENABLE_METAL) && !SLIMPELLER
1089 GrMtlTextureInfo texture_info;
1091 FML_LOG(ERROR) <<
"Embedder supplied null Metal texture.";
1094 sk_cfp<FlutterMetalTextureHandle> mtl_texture;
1096 texture_info.fTexture = mtl_texture;
1097 GrBackendTexture backend_texture =
1098 GrBackendTextures::MakeMtl(config.
size.
width,
1100 skgpu::Mipmapped::kNo,
1104 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
1106 auto surface = SkSurfaces::WrapBackendTexture(
1109 kTopLeft_GrSurfaceOrigin,
1111 kBGRA_8888_SkColorType,
1113 &surface_properties,
1114 static_cast<SkSurfaces::TextureReleaseProc
>(
1120 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
1130#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING)
1131static std::optional<impeller::PixelFormat> FlutterFormatToImpellerPixelFormat(
1140 <<
" to impeller::PixelFormat.";
1141 return std::nullopt;
1147static std::unique_ptr<flutter::EmbedderRenderTarget>
1151 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1154#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING)
1155 auto format = FlutterFormatToImpellerPixelFormat(framebuffer->
target);
1156 if (!
format.has_value()) {
1160 const auto& gl_context =
1162 const bool implicit_msaa = aiks_context->GetContext()
1164 ->SupportsImplicitResolvingMSAA();
1168 if (implicit_msaa) {
1176 color0_tex.
size = size;
1183 gl_context.GetReactor(), color0_tex, framebuffer->
name);
1186 if (implicit_msaa) {
1195 depth_stencil_texture_desc.
size = size;
1198 if (implicit_msaa) {
1199 depth_stencil_texture_desc.
type =
1208 gl_context.GetReactor(), depth_stencil_texture_desc);
1212 depth0.
texture = depth_stencil_tex;
1218 stencil0.
texture = depth_stencil_tex;
1232 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1233 backing_store, aiks_context,
1234 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1235 on_release, framebuffer_destruct);
1241static std::unique_ptr<flutter::EmbedderRenderTarget>
1245 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1248#if defined(SHELL_ENABLE_METAL) && defined(IMPELLER_SUPPORTS_RENDERING)
1250 FML_LOG(ERROR) <<
"Embedder supplied null Metal texture.";
1257 resolve_tex_desc.
size = size;
1268 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
1272 aiks_context->GetContext()->UpdateOffscreenLayerPixelFormat(
1273 resolve_tex->GetTextureDescriptor().format);
1275 resolve_tex->SetLabel(
"ImpellerBackingStoreResolve");
1281 msaa_tex_desc.
format = resolve_tex->GetTextureDescriptor().format;
1282 msaa_tex_desc.
size = size;
1286 aiks_context->GetContext()->GetResourceAllocator()->CreateTexture(
1289 FML_LOG(ERROR) <<
"Could not allocate MSAA color texture.";
1292 msaa_tex->SetLabel(
"ImpellerBackingStoreColorMSAA");
1304 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1305 backing_store, aiks_context,
1306 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1314 GrDirectContext* context,
1317#ifdef SHELL_ENABLE_VULKAN
1319 FML_LOG(ERROR) <<
"Embedder supplied null Vulkan image.";
1322 GrVkImageInfo image_info = {
1323 .fImage =
reinterpret_cast<VkImage
>(
vulkan->image->image),
1324 .fImageTiling = VK_IMAGE_TILING_OPTIMAL,
1325 .fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1326 .fFormat =
static_cast<VkFormat
>(
vulkan->image->format),
1327 .fImageUsageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
1328 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1329 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
1330 VK_IMAGE_USAGE_SAMPLED_BIT,
1334 auto backend_texture = GrBackendTextures::MakeVk(
1337 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
1339 auto surface = SkSurfaces::WrapBackendTexture(
1342 kTopLeft_GrSurfaceOrigin,
1345 static_cast<VkFormat
>(
vulkan->image->format)),
1346 SkColorSpace::MakeSRGB(),
1347 &surface_properties,
1348 static_cast<SkSurfaces::TextureReleaseProc
>(
1349 vulkan->destruction_callback),
1354 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Vulkan render texture.";
1364static std::unique_ptr<flutter::EmbedderRenderTarget>
1367 sk_sp<SkSurface> skia_surface,
1372 if (!skia_surface) {
1375 return std::make_unique<flutter::EmbedderRenderTargetSkia>(
1376 backing_store, std::move(skia_surface), std::move(on_release),
1377 std::move(on_make_current), std::move(on_clear_current));
1380static std::unique_ptr<flutter::EmbedderRenderTarget>
1382 sk_sp<SkSurface> skia_surface,
1385 std::move(on_release),
nullptr,
nullptr);
1388static std::unique_ptr<flutter::EmbedderRenderTarget>
1392 GrDirectContext* context,
1393 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1394 bool enable_impeller) {
1396 backing_store.
struct_size =
sizeof(backing_store);
1404 TRACE_EVENT0(
"flutter",
"FlutterCompositorCreateBackingStore");
1405 if (!c_create_callback(&config, &backing_store, compositor->
user_data)) {
1406 FML_LOG(ERROR) <<
"Could not create the embedder backing store.";
1411 if (backing_store.
struct_size !=
sizeof(backing_store)) {
1412 FML_LOG(ERROR) <<
"Embedder modified the backing store struct size.";
1422 TRACE_EVENT0(
"flutter",
"FlutterCompositorCollectBackingStore");
1423 c_collect_callback(&backing_store, user_data);
1429 std::unique_ptr<flutter::EmbedderRenderTarget> render_target;
1431 switch (backing_store.
type) {
1438 backing_store, std::move(skia_surface),
1443 if (enable_impeller) {
1445 backing_store, collect_callback.
Release(), aiks_context, config,
1452 backing_store, std::move(skia_surface),
1459 auto on_make_current =
1463 bool invalidate_api_state =
false;
1464 bool ok =
callback(context, &invalidate_api_state);
1465 return {ok, invalidate_api_state};
1468 auto on_clear_current =
1472 bool invalidate_api_state =
false;
1473 bool ok =
callback(context, &invalidate_api_state);
1474 return {ok, invalidate_api_state};
1477 if (enable_impeller) {
1480 FML_LOG(ERROR) <<
"Unimplemented";
1487 backing_store, std::move(skia_surface),
1488 collect_callback.
Release(), on_make_current, on_clear_current);
1498 context, config, &backing_store.
software);
1500 backing_store, std::move(skia_surface), collect_callback.
Release());
1505 context, config, &backing_store.
software2);
1507 backing_store, std::move(skia_surface), collect_callback.
Release());
1511 if (enable_impeller) {
1513 backing_store, collect_callback.
Release(), aiks_context, config,
1514 &backing_store.
metal);
1517 &backing_store.
metal);
1519 backing_store, std::move(skia_surface), collect_callback.
Release());
1524 if (enable_impeller) {
1525 FML_LOG(ERROR) <<
"Unimplemented";
1529 context, config, &backing_store.
vulkan);
1531 backing_store, std::move(skia_surface), collect_callback.
Release());
1537 if (!render_target) {
1538 FML_LOG(ERROR) <<
"Could not create a surface from an embedder provided "
1541 return render_target;
1549 bool enable_impeller) {
1550 if (compositor ==
nullptr) {
1551 return std::unique_ptr<flutter::EmbedderExternalViewEmbedder>{
nullptr};
1554 auto c_create_callback =
1555 SAFE_ACCESS(compositor, create_backing_store_callback,
nullptr);
1556 auto c_collect_callback =
1557 SAFE_ACCESS(compositor, collect_backing_store_callback,
nullptr);
1558 auto c_present_callback =
1559 SAFE_ACCESS(compositor, present_layers_callback,
nullptr);
1560 auto c_present_view_callback =
1561 SAFE_ACCESS(compositor, present_view_callback,
nullptr);
1562 bool avoid_backing_store_cache =
1563 SAFE_ACCESS(compositor, avoid_backing_store_cache,
false);
1566 if (!c_create_callback || !c_collect_callback) {
1568 "Required compositor callbacks absent.");
1571 if ((!c_present_view_callback && !c_present_callback) ||
1572 (c_present_view_callback && c_present_callback)) {
1574 "Either present_layers_callback or "
1575 "present_view_callback must be provided but not both.");
1581 create_render_target_callback =
1582 [captured_compositor, enable_impeller](
1583 GrDirectContext* context,
1584 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1585 const auto& config) {
1587 context, aiks_context,
1592 if (c_present_callback) {
1595 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1600 FML_DCHECK(c_present_view_callback !=
nullptr);
1601 present_callback = [c_present_view_callback,
1604 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1614 return c_present_view_callback(&info);
1618 return std::make_unique<flutter::EmbedderExternalViewEmbedder>(
1619 avoid_backing_store_cache, create_render_target_callback,
1624static std::variant<flutter::ViewportMetrics, std::string>
1627 if (flutter_metrics ==
nullptr) {
1628 return "Invalid metrics handle.";
1636 if (
SAFE_ACCESS(flutter_metrics, has_constraints,
false)) {
1656 return "Window metrics are invalid. Width and height must be within the "
1657 "specified constraints.";
1662 SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1664 SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1666 SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1668 SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1672 return "Device pixel ratio was invalid. It must be greater than zero.";
1679 return "Physical view insets are invalid. They must be non-negative.";
1686 return "Physical view insets are invalid. They cannot be greater than "
1687 "physical height or width.";
1694 std::unique_ptr<flutter::PlatformMessage>
message;
1700 ::Dart_UnloadELF(elf);
1720 "AOT data can only be created in AOT mode.");
1721 }
else if (!source) {
1723 }
else if (!data_out) {
1727 switch (source->
type) {
1731 "Invalid ELF path specified.");
1734 auto aot_data = std::make_unique<_FlutterEngineAOTData>();
1735 const char*
error =
nullptr;
1740 Dart_LoadedElf* loaded_elf =
nullptr;
1742 Dart_LoadedElf* loaded_elf = Dart_LoadELF(
1746 &aot_data->vm_snapshot_data,
1747 &aot_data->vm_snapshot_instrs,
1748 &aot_data->vm_isolate_data,
1749 &aot_data->vm_isolate_instrs
1753 if (loaded_elf ==
nullptr) {
1757 aot_data->loaded_elf.reset(loaded_elf);
1759 *data_out = aot_data.release();
1766 "Invalid FlutterEngineAOTDataSourceType type specified.");
1784 auto make_mapping_callback = [](
const char* path,
bool executable) {
1785 return [path, executable]() {
1797 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1800 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1802 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1807 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1810 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1812 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1816#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1830 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1831 return [mapping, size]() {
1832 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1838 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1841 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1844 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1847 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1855 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1857 args->vm_snapshot_instructions,
1863 make_mapping_callback(
args->isolate_snapshot_data,
1867 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1869 args->isolate_snapshot_instructions,
1881 update_semantics_custom_action_callback,
1883 return [update_semantics_node_callback,
1884 update_semantics_custom_action_callback,
user_data](
1891 if (update_semantics_node_callback !=
nullptr) {
1897 if (update_semantics_custom_action_callback !=
nullptr) {
1899 update_semantics_custom_action_callback(&update_ptr->
custom_actions[
i],
1906 if (update_semantics_node_callback !=
nullptr) {
1911 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1914 if (update_semantics_custom_action_callback !=
nullptr) {
1919 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1930 return [update_semantics_callback,
user_data](
1935 update_semantics_callback(update.get(),
user_data);
1945 return [update_semantics_callback,
user_data](
1950 update_semantics_callback(update.get(),
user_data);
1965 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1972 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1981 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1982 update_semantics_node_callback =
args->update_semantics_node_callback;
1986 update_semantics_custom_action_callback =
nullptr;
1987 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1989 update_semantics_custom_action_callback =
1990 args->update_semantics_custom_action_callback;
1993 if (update_semantics_node_callback !=
nullptr ||
1994 update_semantics_custom_action_callback !=
nullptr) {
1996 update_semantics_node_callback, update_semantics_custom_action_callback,
2030 "Flutter embedder version mismatch. There has been a breaking change. "
2031 "Please consult the changelog and update the embedder.");
2034 if (engine_out ==
nullptr) {
2036 "The engine out parameter was missing.");
2039 if (
args ==
nullptr) {
2041 "The Flutter project arguments were missing.");
2047 "The assets path in the Flutter project arguments was missing.");
2052 <<
"FlutterProjectArgs.main_path is deprecated and should be set null.";
2056 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
2057 "should be set null.";
2062 "The renderer configuration was invalid.");
2065 std::string icu_data_path;
2072 std::string persistent_cache_path =
2099 "Multiple AOT sources specified. Embedders should provide either "
2100 "*_snapshot_* buffers or aot_data, not both.");
2124 "Not running in AOT mode but could not resolve the kernel binary.");
2129 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
2141 const std::string& tag,
2150 std::cout << tag <<
": ";
2152 std::cout <<
message << std::endl;
2160 bool has_update_semantics_2_callback =
2162 bool has_update_semantics_callback =
2164 bool has_legacy_update_semantics_callback =
2165 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
2166 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
2169 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
2170 (has_update_semantics_callback ? 1 : 0) +
2171 (has_legacy_update_semantics_callback ? 1 : 0);
2173 if (semantic_callback_count > 1) {
2176 "Multiple semantics update callbacks provided. "
2177 "Embedders should provide either `update_semantics_callback2`, "
2178 "`update_semantics_callback`, or both "
2179 "`update_semantics_node_callback` and "
2180 "`update_semantics_custom_action_callback`.");
2184 update_semantics_callback =
2188 platform_message_response_callback =
nullptr;
2189 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
2190 platform_message_response_callback =
2191 [ptr =
args->platform_message_callback,
2201 handle->message = std::move(
message);
2202 return ptr(&incoming_message,
user_data);
2208 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
2214 compute_platform_resolved_locale_callback =
nullptr;
2215 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
2217 compute_platform_resolved_locale_callback =
2218 [ptr =
args->compute_platform_resolved_locale_callback](
2219 const std::vector<std::string>& supported_locales_data) {
2220 const size_t number_of_strings_per_locale = 3;
2221 size_t locale_count =
2222 supported_locales_data.size() / number_of_strings_per_locale;
2223 std::vector<FlutterLocale> supported_locales;
2224 std::vector<const FlutterLocale*> supported_locales_ptr;
2225 for (
size_t i = 0;
i < locale_count; ++
i) {
2226 supported_locales.push_back(
2229 supported_locales_data[
i * number_of_strings_per_locale +
2233 supported_locales_data[
i * number_of_strings_per_locale +
2237 supported_locales_data[
i * number_of_strings_per_locale +
2240 .variant_code =
nullptr});
2241 supported_locales_ptr.push_back(&supported_locales[
i]);
2245 ptr(supported_locales_ptr.data(), locale_count);
2247 std::unique_ptr<std::vector<std::string>> out =
2248 std::make_unique<std::vector<std::string>>();
2250 std::string language_code(
SAFE_ACCESS(result, language_code,
""));
2251 if (language_code !=
"") {
2252 out->push_back(language_code);
2253 out->emplace_back(
SAFE_ACCESS(result, country_code,
""));
2254 out->emplace_back(
SAFE_ACCESS(result, script_code,
""));
2262 on_pre_engine_restart_callback =
nullptr;
2263 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
2264 on_pre_engine_restart_callback = [ptr =
2265 args->on_pre_engine_restart_callback,
2272 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
2273 const std::string&
name,
bool listening) {
2281 view_focus_change_request_callback =
nullptr;
2284 view_focus_change_request_callback =
2285 [ptr =
args->view_focus_change_request_callback,
2300 if (!external_view_embedder_result.ok()) {
2301 FML_LOG(ERROR) << external_view_embedder_result.status().message();
2303 "Compositor arguments were invalid.");
2308 update_semantics_callback,
2309 platform_message_response_callback,
2311 compute_platform_resolved_locale_callback,
2312 on_pre_engine_restart_callback,
2313 channel_update_callback,
2314 view_focus_change_request_callback,
2322 config,
user_data, platform_dispatch_table,
2323 std::move(external_view_embedder_result.value()),
2326 if (!on_create_platform_view) {
2329 "Could not infer platform view creation callback.");
2334 return std::make_unique<flutter::Rasterizer>(shell);
2338 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2339 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2341#ifdef SHELL_ENABLE_GL
2343 external_texture_callback;
2346 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2347 nullptr) !=
nullptr) {
2348 external_texture_callback =
2350 int64_t texture_identifier,
size_t width,
2351 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2352 std::unique_ptr<FlutterOpenGLTexture>
texture =
2353 std::make_unique<FlutterOpenGLTexture>();
2359 external_texture_resolver =
2360 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2364#ifdef SHELL_ENABLE_METAL
2366 external_texture_metal_callback;
2369 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2370 external_texture_metal_callback =
2372 int64_t texture_identifier,
size_t width,
2373 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2374 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2375 std::make_unique<FlutterMetalExternalTexture>();
2382 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2383 external_texture_metal_callback);
2387 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2388 auto thread_config_callback = [&custom_task_runners](
2391 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2395 switch (config.priority) {
2409 custom_task_runners->thread_priority_setter(priority);
2413 custom_task_runners, thread_config_callback);
2415 if (!thread_host || !thread_host->IsValid()) {
2417 "Could not set up or infer thread configuration "
2418 "to run the Flutter engine on.");
2421 auto task_runners = thread_host->GetTaskRunners();
2423 if (!task_runners.IsValid()) {
2425 "Task runner configuration was invalid.");
2429 bool has_ui_thread_message_loop =
2430 task_runners.GetUITaskRunner()->GetTaskQueueId().is_valid();
2436 if (has_ui_thread_message_loop) {
2443 if (has_ui_thread_message_loop) {
2448 auto run_configuration =
2452 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2453 if (!dart_entrypoint.empty()) {
2454 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2461 "Could not determine Dart entrypoint arguments "
2462 "as dart_entrypoint_argc "
2463 "was set, but dart_entrypoint_argv was null.");
2465 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2466 for (
int i = 0;
i <
args->dart_entrypoint_argc; ++
i) {
2467 arguments[
i] = std::string{
args->dart_entrypoint_argv[
i]};
2469 run_configuration.SetEntrypointArgs(std::move(arguments));
2473 run_configuration.SetEngineId(
args->engine_id);
2476 if (!run_configuration.IsValid()) {
2479 "Could not infer the Flutter project to run from given arguments.");
2483 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2484 std::move(thread_host),
2485 std::move(task_runners),
2486 std::move(settings),
2487 std::move(run_configuration),
2488 on_create_platform_view,
2489 on_create_rasterizer,
2490 std::move(external_texture_resolver)
2495 embedder_engine.release());
2509 if (embedder_engine->IsValid()) {
2514 if (!embedder_engine->LaunchShell()) {
2516 "Could not launch the engine using supplied "
2517 "initialization arguments.");
2521 if (!embedder_engine->NotifyCreated()) {
2523 "Could not create platform view components.");
2527 if (!embedder_engine->RunRootIsolate()) {
2530 "Could not run the root isolate of the Flutter application using the "
2531 "project arguments specified.");
2546 "Add view info handle was invalid.");
2553 "Add view info was invalid. The implicit view cannot be added.");
2559 "Add view info was invalid. The info and "
2560 "window metric view IDs must match.");
2568 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2571 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2575 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2579 if (!embedder_engine->IsValid()) {
2588 result.
added = added;
2590 c_callback(&result);
2593 embedder_engine->GetShell().GetPlatformView()->AddView(
view_id, metrics,
2607 "Remove view info handle was invalid.");
2613 "Remove view info was invalid. The implicit view cannot be removed.");
2622 if (!embedder_engine->IsValid()) {
2633 c_callback(&result);
2636 embedder_engine->GetShell().GetPlatformView()->RemoveView(info->
view_id,
2649 "View focus event must not be null.");
2653 if (!embedder_engine->IsValid()) {
2659 "The event struct has invalid size.");
2667 embedder_engine->GetShell().GetPlatformView()->SendViewFocusEvent(
2682 embedder_engine->CollectShell();
2683 embedder_engine->CollectThreadHost();
2694 delete embedder_engine;
2701 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2707 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2709 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2713 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2719 "Viewport metrics were invalid.");
2754 switch (device_kind) {
2810 size_t events_count) {
2815 if (pointers ==
nullptr || events_count == 0) {
2819 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2823 for (
size_t i = 0;
i < events_count; ++
i) {
2825 pointer_data.
Clear();
2849 if (device_kind == 0) {
2880 packet->SetPointerData(
i, pointer_data);
2882 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2886 ->DispatchPointerDataPacket(std::move(packet))
2889 "Could not dispatch pointer events to the "
2890 "running Flutter application.");
2895 switch (event_kind) {
2908 switch (event_kind) {
2929 const uint8_t* data,
2959 return release_result;
2971 if (event ==
nullptr) {
2989 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2991 struct MessageData {
2996 MessageData* message_data =
3002 packet->data().size(),
3003 [](
const uint8_t* data,
size_t size,
void*
user_data) {
3004 auto message_data = std::unique_ptr<MessageData>(
3005 reinterpret_cast<MessageData*>(user_data));
3006 if (message_data->callback == nullptr) {
3009 bool handled =
false;
3011 handled = *data != 0;
3013 message_data->callback(handled, message_data->user_data);
3025 if (flutter_message ==
nullptr) {
3034 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
3037 if (message_size != 0 && message_data ==
nullptr) {
3040 "Message size was non-zero but the message data was nullptr.");
3044 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
3047 if (response_handle && response_handle->
message) {
3048 response = response_handle->
message->response();
3051 std::unique_ptr<flutter::PlatformMessage>
message;
3052 if (message_size == 0) {
3053 message = std::make_unique<flutter::PlatformMessage>(
3054 flutter_message->
channel, response);
3056 message = std::make_unique<flutter::PlatformMessage>(
3062 ->SendPlatformMessage(std::move(
message))
3065 "Could not send a message to the running "
3066 "Flutter application.");
3078 if (data_callback ==
nullptr || response_out ==
nullptr) {
3084 [
user_data, data_callback](
const uint8_t* data,
size_t size) {
3090 .GetPlatformTaskRunner();
3094 handle->message = std::make_unique<flutter::PlatformMessage>(
3098 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
3099 std::move(platform_task_runner), response_callback));
3100 *response_out = handle;
3111 if (response ==
nullptr) {
3122 const uint8_t* data,
3123 size_t data_length) {
3124 if (data_length != 0 && data ==
nullptr) {
3127 "Data size was non zero but the pointer to the data was null.");
3130 auto response = handle->
message->response();
3133 if (data_length == 0) {
3134 response->CompleteEmpty();
3136 response->Complete(std::make_unique<fml::DataMapping>(
3137 std::vector<uint8_t>({data, data + data_length})));
3153 int64_t texture_identifier) {
3158 if (texture_identifier == 0) {
3160 "Texture identifier was invalid.");
3163 texture_identifier)) {
3165 "Could not register the specified texture.");
3172 int64_t texture_identifier) {
3177 if (texture_identifier == 0) {
3179 "Texture identifier was invalid.");
3183 texture_identifier)) {
3185 "Could not un-register the specified texture.");
3193 int64_t texture_identifier) {
3197 if (texture_identifier == 0) {
3201 ->MarkTextureFrameAvailable(texture_identifier)) {
3204 "Could not mark the texture frame as being available.");
3218 "Could not update semantics state.");
3230 ->SetAccessibilityFeatures(flags)) {
3232 "Could not update accessibility features.");
3241 const uint8_t* data,
3242 size_t data_length) {
3249 .data_length = data_length};
3265 "Could not dispatch semantics action.");
3273 uint64_t frame_start_time_nanos,
3274 uint64_t frame_target_time_nanos) {
3288 baton, start_time, target_time)) {
3291 "Could not notify the running engine instance of a Vsync event.");
3303 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
3306 ->ReloadSystemFonts()) {
3308 "Could not reload system fonts.");
3338 "Render thread callback was null.");
3344 ->PostRenderThreadTask(task)
3347 "Could not post the render thread task.");
3362 reinterpret_cast<intptr_t
>(task->
runner))) {
3371 "Could not run the specified task.");
3376 const rapidjson::Document& document,
3377 const std::string& channel_name) {
3378 if (channel_name.empty()) {
3382 rapidjson::StringBuffer buffer;
3383 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3385 if (!document.Accept(writer)) {
3389 const char*
message = buffer.GetString();
3391 if (
message ==
nullptr || buffer.GetSize() == 0) {
3395 auto platform_message = std::make_unique<flutter::PlatformMessage>(
3396 channel_name.c_str(),
3403 ->SendPlatformMessage(std::move(platform_message));
3409 size_t locales_count) {
3414 if (locales_count == 0) {
3418 if (locales ==
nullptr) {
3422 rapidjson::Document document;
3423 auto&
allocator = document.GetAllocator();
3425 document.SetObject();
3426 document.AddMember(
"method",
"setLocale",
allocator);
3428 rapidjson::Value
args(rapidjson::kArrayType);
3430 for (
size_t i = 0;
i < locales_count; ++
i) {
3432 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3433 if (language_code_str ==
nullptr || ::strlen(language_code_str) == 0) {
3436 "Language code is required but not present in FlutterLocale.");
3439 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3440 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3441 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3443 rapidjson::Value language_code, country_code, script_code, variant_code;
3445 language_code.SetString(language_code_str,
allocator);
3446 country_code.SetString(country_code_str ? country_code_str :
"",
allocator);
3447 script_code.SetString(script_code_str ? script_code_str :
"",
allocator);
3448 variant_code.SetString(variant_code_str ? variant_code_str :
"",
allocator);
3461 "Could not send message to update locale of "
3462 "a running Flutter application.");
3481 if (port == ILLEGAL_PORT) {
3483 "Attempted to post to an illegal port.");
3486 if (
object ==
nullptr) {
3488 "Invalid Dart object to post.");
3491 Dart_CObject dart_object = {};
3494 switch (object->
type) {
3496 dart_object.type = Dart_CObject_kNull;
3499 dart_object.type = Dart_CObject_kBool;
3500 dart_object.value.as_bool =
object->bool_value;
3503 dart_object.type = Dart_CObject_kInt32;
3504 dart_object.value.as_int32 =
object->int32_value;
3507 dart_object.type = Dart_CObject_kInt64;
3508 dart_object.value.as_int64 =
object->int64_value;
3511 dart_object.type = Dart_CObject_kDouble;
3512 dart_object.value.as_double =
object->double_value;
3517 "kFlutterEngineDartObjectTypeString must be "
3518 "a null terminated string but was null.");
3520 dart_object.type = Dart_CObject_kString;
3521 dart_object.value.as_string =
const_cast<char*
>(
object->string_value);
3525 if (buffer ==
nullptr) {
3527 "kFlutterEngineDartObjectTypeBuffer must "
3528 "specify a buffer but found nullptr.");
3539 dart_object.type = Dart_CObject_kTypedData;
3540 dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
3541 dart_object.value.as_typed_data.length = buffer_size;
3542 dart_object.value.as_typed_data.values = buffer;
3544 struct ExternalTypedDataPeer {
3548 auto peer =
new ExternalTypedDataPeer();
3563 dart_object.type = Dart_CObject_kExternalTypedData;
3564 dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
3565 dart_object.value.as_external_typed_data.length = buffer_size;
3566 dart_object.value.as_external_typed_data.data = buffer;
3567 dart_object.value.as_external_typed_data.peer = peer;
3568 dart_object.value.as_external_typed_data.callback =
3569 +[](
void* unused_isolate_callback_data,
void* peer) {
3570 auto typed_peer =
reinterpret_cast<ExternalTypedDataPeer*
>(peer);
3571 typed_peer->trampoline(typed_peer->user_data);
3579 "Invalid FlutterEngineDartObjectType type specified.");
3582 if (!Dart_PostCObject(port, &dart_object)) {
3584 "Could not post the object to the Dart VM.");
3589 typed_data_finalizer.
Release();
3600 engine->GetShell().NotifyLowMemoryWarning();
3602 rapidjson::Document document;
3603 auto&
allocator = document.GetAllocator();
3605 document.SetObject();
3606 document.AddMember(
"type",
"memoryPressure",
allocator);
3612 "Could not dispatch the low memory notification message.");
3625 "Invalid native thread callback.");
3629 ->PostTaskOnEngineManagedNativeThreads(
3635 "Internal error while attempting to post "
3636 "tasks to all threads.");
3641 size_t display_count) {
3642 std::set<FlutterEngineDisplayId> display_ids;
3643 for (
size_t i = 0;
i < display_count;
i++) {
3644 if (
displays[
i].single_display && display_count != 1) {
3647 display_ids.insert(
displays[
i].display_id);
3650 return display_ids.size() == display_count;
3658 size_t display_count) {
3659 if (raw_engine ==
nullptr) {
3663 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3666 "Invalid FlutterEngineDisplay configuration specified.");
3671 switch (update_type) {
3673 std::vector<std::unique_ptr<flutter::Display>>
displays;
3674 const auto* display = embedder_displays;
3675 for (
size_t i = 0;
i < display_count;
i++) {
3676 displays.push_back(std::make_unique<flutter::Display>(
3683 reinterpret_cast<const uint8_t*
>(display) + display->struct_size);
3691 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3704 "Could not schedule frame.");
3717 "Next frame callback was null.");
3726 if (!weak_platform_view) {
3728 "Platform view unavailable.");
3731 weak_platform_view->SetNextFrameCallback(
3742#define SET_PROC(member, function) \
3743 if (STRUCT_HAS_MEMBER(table, member)) { \
3744 table->member = &function; \
3758 SET_PROC(PlatformMessageCreateResponseHandle,
3760 SET_PROC(PlatformMessageReleaseResponseHandle,
3762 SET_PROC(SendPlatformMessageResponse,
3766 SET_PROC(MarkExternalTextureFrameAvailable,
3769 SET_PROC(UpdateAccessibilityFeatures,
3785 SET_PROC(PostCallbackOnAllNativeThreads,
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(int64_t view_id, 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
std::function< SetCurrentResult()> MakeOrClearCurrentCallback
static bool RunnerIsValid(intptr_t runner)
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...
const Settings & GetSettings() const override
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
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)
static TaskQueueId Invalid()
@ 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
constexpr 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(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, GLuint fbo)
Create a texture by wrapping an external framebuffer object whose lifecycle is owned by the caller.
static std::shared_ptr< TextureGLES > CreatePlaceholder(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc)
Create a "texture" that is never expected to be bound/unbound explicitly or initialized in any way....
#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 embedder via the Flutter...
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[]
FlutterEngineResult FlutterEngineSendViewFocusEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterViewFocusEvent *event)
Notifies the engine that platform view focus state has changed.
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
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)
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)
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, impeller::Flags impeller_flags)
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
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, impeller::Flags impeller_flags)
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, impeller::Flags impeller_flags)
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 in the implicit view.
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.
static std::unique_ptr< flutter::EmbedderRenderTarget > MakeRenderTargetFromSkSurface(FlutterBackingStore backing_store, sk_sp< SkSurface > skia_surface, fml::closure on_release, flutter::EmbedderRenderTarget::MakeOrClearCurrentCallback on_make_current, flutter::EmbedderRenderTarget::MakeOrClearCurrentCallback on_clear_current)
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...
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)
static fml::StatusOr< std::unique_ptr< flutter::EmbedderExternalViewEmbedder > > InferExternalViewEmbedderFromArgs(const FlutterCompositor *compositor, bool enable_impeller)
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)
void PopulateJITSnapshotMappingCallbacks(const FlutterProjectArgs *args, flutter::Settings &settings)
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, bool enable_impeller, impeller::Flags impeller_flags)
static bool IsVulkanRendererConfigValid(const FlutterRendererConfig *config)
FlutterEngineResult FlutterEngineSendSemanticsAction(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterSendSemanticsActionInfo *info)
Dispatch a semantics action to the specified semantics node within a specific view.
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 FlutterEngineResult LogEmbedderError(FlutterEngineResult code, const char *reason, const char *code_name, const char *function, const char *file, int line)
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 *)
FlutterViewFocusState
Represents the focus state of a given [FlutterView].
@ kFlutterEngineAOTDataSourceTypeElfPath
FlutterViewFocusDirection
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 *)
void(* VoidCallback)(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
@ kFlutterOpenGLTargetTypeSurface
@ 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 STRUCT_HAS_MEMBER(pointer, member)
#define SAFE_EXISTS_ONE_OF(pointer, member1, member2)
Checks if exactly one of member1 or member2 exists and is non-null.
FlutterVulkanImage * image
VkPhysicalDevice physical_device
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
#define FML_DCHECK(condition)
Dart_NativeFunction function
std::shared_ptr< ImpellerAllocator > allocator
static const char * kApplicationKernelSnapshotFileName
void * GPUMTLDeviceHandle
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
impeller::Matrix DlMatrix
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
@ kPointerButtonMousePrimary
@ kPointerButtonTouchContact
impeller::IRect32 DlIRect
Settings SettingsFromCommandLine(const fml::CommandLine &command_line, bool require_merged_platform_ui_thread)
void * GPUMTLCommandQueueHandle
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)
impeller::ShaderType type
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
FlutterAddViewCallback add_view_callback
FlutterViewId view_id
The identifier for the view to add. This must be unique.
const FlutterWindowMetricsEvent * view_metrics
void * user_data
The |FlutterAddViewInfo.user_data|.
bool added
True if the add view operation succeeded.
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.
FlutterEngineAOTDataSourceType type
const char * elf_path
Absolute path to an ELF library file.
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
FlutterOpenGLSurface surface
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
FlutterOpenGLSurfaceCallback clear_current_callback
FlutterOpenGLSurfaceCallback make_current_callback
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.
FlutterRemoveViewCallback remove_view_callback
void * user_data
The |FlutterRemoveViewInfo.user_data|.
bool removed
True if the remove view operation succeeded.
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.
FlutterViewId view_id
The ID of the view that includes the node.
FlutterSemanticsAction action
The semantics action.
size_t data_length
The data length.
uint64_t node_id
The semantics node identifier.
const uint8_t * data
Data associated with the action.
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
FlutterViewFocusState state
The focus state of the view.
FlutterViewFocusDirection direction
The direction in which the focus transitioned across [FlutterView]s.
FlutterViewId view_id
The identifier of the view that received the focus event.
size_t struct_size
The size of this struct. Must be sizeof(FlutterVulkanImage).
uint32_t format
The VkFormat of the image (for example: VK_FORMAT_R8G8B8A8_UNORM).
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)
PFN_vkGetInstanceProcAddr get_instance_proc_address
PFN_vkGetInstanceProcAddr get_instance_proc_address
void * destruction_context
GPUMTLDestructionCallback destruction_callback
GPUMTLTextureHandle texture
KeyEventDeviceType device_type
int64_t pointer_identifier
std::string application_kernel_asset
LogMessageCallback log_message_callback
MappingCallback isolate_snapshot_instr
std::function< void(const DartIsolate &)> root_isolate_create_callback
TaskObserverRemove task_observer_remove
MappingCallback isolate_snapshot_data
MappingCallback vm_snapshot_data
TaskObserverAdd task_observer_add
bool impeller_antialiased_lines
std::string icu_data_path
MappingCallback vm_snapshot_instr
MappingCallback dart_library_sources_kernel
int64_t old_gen_heap_size
double physical_max_height_constraint
double physical_max_width_constraint
double device_pixel_ratio
double physical_min_height_constraint
double physical_view_inset_bottom
double physical_view_inset_right
double physical_view_inset_top
double physical_view_inset_left
double physical_min_width_constraint
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()
bool antialiased_lines
When turned on DrawLine will use the experimental antialiased path.
bool use_sdfs
Use SDFs for rendering.
constexpr auto GetBottom() const
constexpr auto GetTop() const
constexpr auto GetLeft() const
constexpr auto GetRight() const
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
#define TRACE_EVENT0(category_group, name)