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);
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.";
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.";
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.";
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.";
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.";
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)),
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>
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;
1465 return {ok, invalidate_api_state};
1468 auto on_clear_current =
1472 bool invalidate_api_state =
false;
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);
1500 backing_store, std::move(skia_surface), collect_callback.
Release());
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";
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](
1584 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1585 const auto& config) {
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 =
1746 &aot_data->vm_isolate_data,
1747 &aot_data->vm_isolate_instrs
1749 if (loaded_elf !=
nullptr) {
1750 aot_data->vm_snapshot_data = aot_data->vm_isolate_data;
1751 aot_data->vm_snapshot_instrs = aot_data->vm_isolate_instrs;
1755 if (loaded_elf ==
nullptr) {
1759 aot_data->loaded_elf.reset(loaded_elf);
1761 *data_out = aot_data.release();
1768 "Invalid FlutterEngineAOTDataSourceType type specified.");
1786 auto make_mapping_callback = [](
const char* path,
bool executable) {
1787 return [path, executable]() {
1799 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1802 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1804 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1809 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1812 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1814 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1818#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1832 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1833 return [mapping, size]() {
1834 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1840 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1843 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1846 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1849 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1857 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1859 args->vm_snapshot_instructions,
1865 make_mapping_callback(
args->isolate_snapshot_data,
1869 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1871 args->isolate_snapshot_instructions,
1883 update_semantics_custom_action_callback,
1885 return [update_semantics_node_callback,
1886 update_semantics_custom_action_callback,
user_data](
1893 if (update_semantics_node_callback !=
nullptr) {
1899 if (update_semantics_custom_action_callback !=
nullptr) {
1901 update_semantics_custom_action_callback(&update_ptr->
custom_actions[
i],
1908 if (update_semantics_node_callback !=
nullptr) {
1913 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1916 if (update_semantics_custom_action_callback !=
nullptr) {
1921 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1932 return [update_semantics_callback,
user_data](
1937 update_semantics_callback(update.get(),
user_data);
1947 return [update_semantics_callback,
user_data](
1952 update_semantics_callback(update.get(),
user_data);
1967 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1974 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1983 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1984 update_semantics_node_callback =
args->update_semantics_node_callback;
1988 update_semantics_custom_action_callback =
nullptr;
1989 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1991 update_semantics_custom_action_callback =
1992 args->update_semantics_custom_action_callback;
1995 if (update_semantics_node_callback !=
nullptr ||
1996 update_semantics_custom_action_callback !=
nullptr) {
1998 update_semantics_node_callback, update_semantics_custom_action_callback,
2032 "Flutter embedder version mismatch. There has been a breaking change. "
2033 "Please consult the changelog and update the embedder.");
2036 if (engine_out ==
nullptr) {
2038 "The engine out parameter was missing.");
2041 if (
args ==
nullptr) {
2043 "The Flutter project arguments were missing.");
2049 "The assets path in the Flutter project arguments was missing.");
2054 <<
"FlutterProjectArgs.main_path is deprecated and should be set null.";
2058 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
2059 "should be set null.";
2064 "The renderer configuration was invalid.");
2067 std::string icu_data_path;
2074 std::string persistent_cache_path =
2101 "Multiple AOT sources specified. Embedders should provide either "
2102 "*_snapshot_* buffers or aot_data, not both.");
2126 "Not running in AOT mode but could not resolve the kernel binary.");
2131 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
2143 const std::string& tag,
2152 std::cout << tag <<
": ";
2154 std::cout <<
message << std::endl;
2162 bool has_update_semantics_2_callback =
2164 bool has_update_semantics_callback =
2166 bool has_legacy_update_semantics_callback =
2167 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
2168 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
2171 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
2172 (has_update_semantics_callback ? 1 : 0) +
2173 (has_legacy_update_semantics_callback ? 1 : 0);
2175 if (semantic_callback_count > 1) {
2178 "Multiple semantics update callbacks provided. "
2179 "Embedders should provide either `update_semantics_callback2`, "
2180 "`update_semantics_callback`, or both "
2181 "`update_semantics_node_callback` and "
2182 "`update_semantics_custom_action_callback`.");
2186 update_semantics_callback =
2190 platform_message_response_callback =
nullptr;
2191 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
2192 platform_message_response_callback =
2193 [ptr =
args->platform_message_callback,
2203 handle->message = std::move(
message);
2204 return ptr(&incoming_message,
user_data);
2210 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
2216 compute_platform_resolved_locale_callback =
nullptr;
2217 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
2219 compute_platform_resolved_locale_callback =
2220 [ptr =
args->compute_platform_resolved_locale_callback](
2221 const std::vector<std::string>& supported_locales_data) {
2222 const size_t number_of_strings_per_locale = 3;
2223 size_t locale_count =
2224 supported_locales_data.size() / number_of_strings_per_locale;
2225 std::vector<FlutterLocale> supported_locales;
2226 std::vector<const FlutterLocale*> supported_locales_ptr;
2227 for (
size_t i = 0;
i < locale_count; ++
i) {
2228 supported_locales.push_back(
2231 supported_locales_data[
i * number_of_strings_per_locale +
2235 supported_locales_data[
i * number_of_strings_per_locale +
2239 supported_locales_data[
i * number_of_strings_per_locale +
2242 .variant_code =
nullptr});
2243 supported_locales_ptr.push_back(&supported_locales[
i]);
2247 ptr(supported_locales_ptr.data(), locale_count);
2249 std::unique_ptr<std::vector<std::string>> out =
2250 std::make_unique<std::vector<std::string>>();
2252 std::string language_code(
SAFE_ACCESS(result, language_code,
""));
2253 if (language_code !=
"") {
2254 out->push_back(language_code);
2255 out->emplace_back(
SAFE_ACCESS(result, country_code,
""));
2256 out->emplace_back(
SAFE_ACCESS(result, script_code,
""));
2264 on_pre_engine_restart_callback =
nullptr;
2265 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
2266 on_pre_engine_restart_callback = [ptr =
2267 args->on_pre_engine_restart_callback,
2274 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
2275 const std::string&
name,
bool listening) {
2283 view_focus_change_request_callback =
nullptr;
2286 view_focus_change_request_callback =
2287 [ptr =
args->view_focus_change_request_callback,
2302 if (!external_view_embedder_result.ok()) {
2303 FML_LOG(ERROR) << external_view_embedder_result.status().message();
2305 "Compositor arguments were invalid.");
2310 update_semantics_callback,
2311 platform_message_response_callback,
2313 compute_platform_resolved_locale_callback,
2314 on_pre_engine_restart_callback,
2315 channel_update_callback,
2316 view_focus_change_request_callback,
2324 config,
user_data, platform_dispatch_table,
2325 std::move(external_view_embedder_result.value()),
2328 if (!on_create_platform_view) {
2331 "Could not infer platform view creation callback.");
2336 return std::make_unique<flutter::Rasterizer>(shell);
2340 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2341 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2343#ifdef SHELL_ENABLE_GL
2345 external_texture_callback;
2348 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2349 nullptr) !=
nullptr) {
2350 external_texture_callback =
2352 int64_t texture_identifier,
size_t width,
2353 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2354 std::unique_ptr<FlutterOpenGLTexture>
texture =
2355 std::make_unique<FlutterOpenGLTexture>();
2361 external_texture_resolver =
2362 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2366#ifdef SHELL_ENABLE_METAL
2368 external_texture_metal_callback;
2371 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2372 external_texture_metal_callback =
2374 int64_t texture_identifier,
size_t width,
2375 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2376 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2377 std::make_unique<FlutterMetalExternalTexture>();
2384 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2385 external_texture_metal_callback);
2389 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2390 auto thread_config_callback = [&custom_task_runners](
2393 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2397 switch (config.priority) {
2411 custom_task_runners->thread_priority_setter(priority);
2415 custom_task_runners, thread_config_callback);
2417 if (!thread_host || !thread_host->IsValid()) {
2419 "Could not set up or infer thread configuration "
2420 "to run the Flutter engine on.");
2423 auto task_runners = thread_host->GetTaskRunners();
2425 if (!task_runners.IsValid()) {
2427 "Task runner configuration was invalid.");
2431 bool has_ui_thread_message_loop =
2432 task_runners.GetUITaskRunner()->GetTaskQueueId().is_valid();
2438 if (has_ui_thread_message_loop) {
2445 if (has_ui_thread_message_loop) {
2450 auto run_configuration =
2454 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2455 if (!dart_entrypoint.empty()) {
2456 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2463 "Could not determine Dart entrypoint arguments "
2464 "as dart_entrypoint_argc "
2465 "was set, but dart_entrypoint_argv was null.");
2467 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2468 for (
int i = 0;
i <
args->dart_entrypoint_argc; ++
i) {
2469 arguments[
i] = std::string{
args->dart_entrypoint_argv[
i]};
2471 run_configuration.SetEntrypointArgs(std::move(arguments));
2475 run_configuration.SetEngineId(
args->engine_id);
2478 if (!run_configuration.IsValid()) {
2481 "Could not infer the Flutter project to run from given arguments.");
2485 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2486 std::move(thread_host),
2487 std::move(task_runners),
2488 std::move(settings),
2489 std::move(run_configuration),
2490 on_create_platform_view,
2491 on_create_rasterizer,
2492 std::move(external_texture_resolver)
2497 embedder_engine.release());
2511 if (embedder_engine->IsValid()) {
2516 if (!embedder_engine->LaunchShell()) {
2518 "Could not launch the engine using supplied "
2519 "initialization arguments.");
2523 if (!embedder_engine->NotifyCreated()) {
2525 "Could not create platform view components.");
2529 if (!embedder_engine->RunRootIsolate()) {
2532 "Could not run the root isolate of the Flutter application using the "
2533 "project arguments specified.");
2548 "Add view info handle was invalid.");
2555 "Add view info was invalid. The implicit view cannot be added.");
2561 "Add view info was invalid. The info and "
2562 "window metric view IDs must match.");
2570 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2573 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2577 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2581 if (!embedder_engine->IsValid()) {
2590 result.
added = added;
2592 c_callback(&result);
2595 embedder_engine->GetShell().GetPlatformView()->AddView(
view_id, metrics,
2609 "Remove view info handle was invalid.");
2615 "Remove view info was invalid. The implicit view cannot be removed.");
2624 if (!embedder_engine->IsValid()) {
2635 c_callback(&result);
2638 embedder_engine->GetShell().GetPlatformView()->RemoveView(info->
view_id,
2651 "View focus event must not be null.");
2655 if (!embedder_engine->IsValid()) {
2661 "The event struct has invalid size.");
2669 embedder_engine->GetShell().GetPlatformView()->SendViewFocusEvent(
2684 embedder_engine->CollectShell();
2685 embedder_engine->CollectThreadHost();
2696 delete embedder_engine;
2703 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2709 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2711 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2715 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2721 "Viewport metrics were invalid.");
2756 switch (device_kind) {
2814 size_t events_count) {
2819 if (pointers ==
nullptr || events_count == 0) {
2823 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2827 for (
size_t i = 0;
i < events_count; ++
i) {
2829 pointer_data.
Clear();
2853 if (device_kind == 0) {
2884 packet->SetPointerData(
i, pointer_data);
2886 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2890 ->DispatchPointerDataPacket(std::move(packet))
2893 "Could not dispatch pointer events to the "
2894 "running Flutter application.");
2899 switch (event_kind) {
2912 switch (event_kind) {
2933 const uint8_t* data,
2963 return release_result;
2975 if (event ==
nullptr) {
2993 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2995 struct MessageData {
3000 MessageData* message_data =
3006 packet->data().size(),
3007 [](
const uint8_t* data,
size_t size,
void*
user_data) {
3008 auto message_data = std::unique_ptr<MessageData>(
3009 reinterpret_cast<MessageData*>(user_data));
3010 if (message_data->callback == nullptr) {
3013 bool handled =
false;
3015 handled = *data != 0;
3017 message_data->callback(handled, message_data->user_data);
3029 if (flutter_message ==
nullptr) {
3038 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
3041 if (message_size != 0 && message_data ==
nullptr) {
3044 "Message size was non-zero but the message data was nullptr.");
3048 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
3051 if (response_handle && response_handle->
message) {
3052 response = response_handle->
message->response();
3055 std::unique_ptr<flutter::PlatformMessage>
message;
3056 if (message_size == 0) {
3057 message = std::make_unique<flutter::PlatformMessage>(
3058 flutter_message->
channel, response);
3060 message = std::make_unique<flutter::PlatformMessage>(
3066 ->SendPlatformMessage(std::move(
message))
3069 "Could not send a message to the running "
3070 "Flutter application.");
3082 if (data_callback ==
nullptr || response_out ==
nullptr) {
3088 [
user_data, data_callback](
const uint8_t* data,
size_t size) {
3094 .GetPlatformTaskRunner();
3098 handle->message = std::make_unique<flutter::PlatformMessage>(
3102 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
3103 std::move(platform_task_runner), response_callback));
3104 *response_out = handle;
3115 if (response ==
nullptr) {
3126 const uint8_t* data,
3127 size_t data_length) {
3128 if (data_length != 0 && data ==
nullptr) {
3131 "Data size was non zero but the pointer to the data was null.");
3134 auto response = handle->
message->response();
3137 if (data_length == 0) {
3138 response->CompleteEmpty();
3140 response->Complete(std::make_unique<fml::DataMapping>(
3141 std::vector<uint8_t>({data, data + data_length})));
3157 int64_t texture_identifier) {
3162 if (texture_identifier == 0) {
3164 "Texture identifier was invalid.");
3167 texture_identifier)) {
3169 "Could not register the specified texture.");
3176 int64_t texture_identifier) {
3181 if (texture_identifier == 0) {
3183 "Texture identifier was invalid.");
3187 texture_identifier)) {
3189 "Could not un-register the specified texture.");
3197 int64_t texture_identifier) {
3201 if (texture_identifier == 0) {
3205 ->MarkTextureFrameAvailable(texture_identifier)) {
3208 "Could not mark the texture frame as being available.");
3222 "Could not update semantics state.");
3234 ->SetAccessibilityFeatures(flags)) {
3236 "Could not update accessibility features.");
3245 const uint8_t* data,
3246 size_t data_length) {
3253 .data_length = data_length};
3269 "Could not dispatch semantics action.");
3277 uint64_t frame_start_time_nanos,
3278 uint64_t frame_target_time_nanos) {
3292 baton, start_time, target_time)) {
3295 "Could not notify the running engine instance of a Vsync event.");
3307 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
3310 ->ReloadSystemFonts()) {
3312 "Could not reload system fonts.");
3342 "Render thread callback was null.");
3348 ->PostRenderThreadTask(task)
3351 "Could not post the render thread task.");
3366 reinterpret_cast<intptr_t
>(task->
runner))) {
3375 "Could not run the specified task.");
3380 const rapidjson::Document& document,
3381 const std::string& channel_name) {
3382 if (channel_name.empty()) {
3386 rapidjson::StringBuffer buffer;
3387 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3389 if (!document.Accept(writer)) {
3393 const char*
message = buffer.GetString();
3395 if (
message ==
nullptr || buffer.GetSize() == 0) {
3399 auto platform_message = std::make_unique<flutter::PlatformMessage>(
3400 channel_name.c_str(),
3407 ->SendPlatformMessage(std::move(platform_message));
3413 size_t locales_count) {
3418 if (locales_count == 0) {
3422 if (locales ==
nullptr) {
3426 rapidjson::Document document;
3427 auto&
allocator = document.GetAllocator();
3429 document.SetObject();
3430 document.AddMember(
"method",
"setLocale",
allocator);
3432 rapidjson::Value
args(rapidjson::kArrayType);
3434 for (
size_t i = 0;
i < locales_count; ++
i) {
3436 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3437 if (language_code_str ==
nullptr || ::strlen(language_code_str) == 0) {
3440 "Language code is required but not present in FlutterLocale.");
3443 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3444 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3445 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3447 rapidjson::Value language_code, country_code, script_code, variant_code;
3449 language_code.SetString(language_code_str,
allocator);
3450 country_code.SetString(country_code_str ? country_code_str :
"",
allocator);
3451 script_code.SetString(script_code_str ? script_code_str :
"",
allocator);
3452 variant_code.SetString(variant_code_str ? variant_code_str :
"",
allocator);
3465 "Could not send message to update locale of "
3466 "a running Flutter application.");
3485 if (port == ILLEGAL_PORT) {
3487 "Attempted to post to an illegal port.");
3490 if (
object ==
nullptr) {
3492 "Invalid Dart object to post.");
3495 Dart_CObject dart_object = {};
3498 switch (object->
type) {
3500 dart_object.type = Dart_CObject_kNull;
3503 dart_object.type = Dart_CObject_kBool;
3504 dart_object.value.as_bool =
object->bool_value;
3507 dart_object.type = Dart_CObject_kInt32;
3508 dart_object.value.as_int32 =
object->int32_value;
3511 dart_object.type = Dart_CObject_kInt64;
3512 dart_object.value.as_int64 =
object->int64_value;
3515 dart_object.type = Dart_CObject_kDouble;
3516 dart_object.value.as_double =
object->double_value;
3521 "kFlutterEngineDartObjectTypeString must be "
3522 "a null terminated string but was null.");
3524 dart_object.type = Dart_CObject_kString;
3525 dart_object.value.as_string =
const_cast<char*
>(
object->string_value);
3529 if (buffer ==
nullptr) {
3531 "kFlutterEngineDartObjectTypeBuffer must "
3532 "specify a buffer but found nullptr.");
3543 dart_object.type = Dart_CObject_kTypedData;
3544 dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
3545 dart_object.value.as_typed_data.length = buffer_size;
3546 dart_object.value.as_typed_data.values = buffer;
3548 struct ExternalTypedDataPeer {
3552 auto peer =
new ExternalTypedDataPeer();
3567 dart_object.type = Dart_CObject_kExternalTypedData;
3568 dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
3569 dart_object.value.as_external_typed_data.length = buffer_size;
3570 dart_object.value.as_external_typed_data.data = buffer;
3571 dart_object.value.as_external_typed_data.peer = peer;
3572 dart_object.value.as_external_typed_data.callback =
3573 +[](
void* unused_isolate_callback_data,
void* peer) {
3574 auto typed_peer =
reinterpret_cast<ExternalTypedDataPeer*
>(peer);
3575 typed_peer->trampoline(typed_peer->user_data);
3583 "Invalid FlutterEngineDartObjectType type specified.");
3586 if (!Dart_PostCObject(port, &dart_object)) {
3588 "Could not post the object to the Dart VM.");
3593 typed_data_finalizer.
Release();
3604 engine->GetShell().NotifyLowMemoryWarning();
3606 rapidjson::Document document;
3607 auto&
allocator = document.GetAllocator();
3609 document.SetObject();
3610 document.AddMember(
"type",
"memoryPressure",
allocator);
3616 "Could not dispatch the low memory notification message.");
3629 "Invalid native thread callback.");
3633 ->PostTaskOnEngineManagedNativeThreads(
3639 "Internal error while attempting to post "
3640 "tasks to all threads.");
3645 size_t display_count) {
3646 std::set<FlutterEngineDisplayId> display_ids;
3647 for (
size_t i = 0;
i < display_count;
i++) {
3648 if (
displays[
i].single_display && display_count != 1) {
3651 display_ids.insert(
displays[
i].display_id);
3654 return display_ids.size() == display_count;
3662 size_t display_count) {
3663 if (raw_engine ==
nullptr) {
3667 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3670 "Invalid FlutterEngineDisplay configuration specified.");
3675 switch (update_type) {
3677 std::vector<std::unique_ptr<flutter::Display>>
displays;
3678 const auto* display = embedder_displays;
3679 for (
size_t i = 0;
i < display_count;
i++) {
3680 displays.push_back(std::make_unique<flutter::Display>(
3687 reinterpret_cast<const uint8_t*
>(display) + display->struct_size);
3695 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3708 "Could not schedule frame.");
3721 "Next frame callback was null.");
3730 if (!weak_platform_view) {
3732 "Platform view unavailable.");
3735 weak_platform_view->SetNextFrameCallback(
3746#define SET_PROC(member, function) \
3747 if (STRUCT_HAS_MEMBER(table, member)) { \
3748 table->member = &function; \
3762 SET_PROC(PlatformMessageCreateResponseHandle,
3764 SET_PROC(PlatformMessageReleaseResponseHandle,
3766 SET_PROC(SendPlatformMessageResponse,
3770 SET_PROC(MarkExternalTextureFrameAvailable,
3773 SET_PROC(UpdateAccessibilityFeatures,
3789 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
@ kFlutterPointerDeviceKindInvertedStylus
@ 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)
std::shared_ptr< ContextGLES > context
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)