5#define FML_USED_ON_EMBEDDER
6#define RAPIDJSON_HAS_STDSTRING 1
21#include "third_party/dart/runtime/bin/elf_loader.h"
22#include "third_party/dart/runtime/include/dart_native_api.h"
23#include "third_party/skia/include/core/SkSurface.h"
24#include "third_party/skia/include/gpu/GpuTypes.h"
25#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
26#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
28#if !defined(FLUTTER_NO_EXPORT)
30#define FLUTTER_EXPORT __declspec(dllexport)
32#define FLUTTER_EXPORT __attribute__((visibility("default")))
37#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
67#include "rapidjson/rapidjson.h"
68#include "rapidjson/writer.h"
74#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
75#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
76#ifdef IMPELLER_SUPPORTS_RENDERING
88#ifdef SHELL_ENABLE_METAL
90#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlBackendSurface.h"
91#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h"
92#include "third_party/skia/include/ports/SkCFObject.h"
93#ifdef IMPELLER_SUPPORTS_RENDERING
102#ifdef SHELL_ENABLE_VULKAN
103#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
104#include "third_party/skia/include/gpu/ganesh/vk/GrVkTypes.h"
136 const char* code_name,
137 const char* function,
141 constexpr char kSeparator =
'\\';
143 constexpr char kSeparator =
'/';
145 const auto file_base =
146 (::strrchr(file, kSeparator) ? strrchr(file, kSeparator) + 1 : file);
147 char error[256] = {};
148 snprintf(
error, (
sizeof(
error) /
sizeof(
char)),
149 "%s (%d): '%s' returned '%s'. %s", file_base, line,
function,
151 std::cerr <<
error << std::endl;
155#define LOG_EMBEDDER_ERROR(code, reason) \
156 LogEmbedderError(code, reason, #code, __FUNCTION__, __FILE__, __LINE__)
168 fbo_with_frame_info_callback) ||
183 if (
SAFE_ACCESS(software_config, surface_present_callback,
nullptr) ==
200 SAFE_ACCESS(metal_config, present_command_queue,
nullptr);
202 bool present =
SAFE_ACCESS(metal_config, present_drawable_callback,
nullptr);
204 SAFE_ACCESS(metal_config, get_next_drawable_callback,
nullptr);
206 return device && command_queue && present && get_texture;
220 !
SAFE_EXISTS(vulkan_config, get_instance_proc_address_callback) ||
221 !
SAFE_EXISTS(vulkan_config, get_next_image_callback) ||
222 !
SAFE_EXISTS(vulkan_config, present_image_callback)) {
230 if (config ==
nullptr) {
234 switch (config->
type) {
250#if FML_OS_LINUX || FML_OS_WIN
251static void* DefaultGLProcResolver(
const char*
name) {
258 return static_cast<void*
>(
259 const_cast<uint8_t*
>(proc_library->ResolveSymbol(
name)));
263#ifdef SHELL_ENABLE_GL
268 static_cast<double>(dl_rect.
GetTop()),
269 static_cast<double>(dl_rect.
GetRight()),
270 static_cast<double>(dl_rect.
GetBottom())};
278 static_cast<int32_t
>(flutter_rect.
top),
279 static_cast<int32_t
>(flutter_rect.
right),
280 static_cast<int32_t
>(flutter_rect.
bottom));
286#define GL_BGRA8_EXT 0x93A1
289static std::optional<SkColorType> FlutterFormatToSkColorType(uint32_t format) {
292 return kBGRA_8888_SkColorType;
294 return kRGBA_8888_SkColorType;
297 <<
" to SkColorType.";
309 platform_dispatch_table,
310 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
311 external_view_embedder,
312 bool enable_impeller) {
313#ifdef SHELL_ENABLE_GL
338 std::optional<FlutterRect> frame_damage_rect;
339 if (gl_present_info.frame_damage) {
341 DlIRectToFlutterRect(*(gl_present_info.frame_damage));
343 std::optional<FlutterRect> buffer_damage_rect;
344 if (gl_present_info.buffer_damage) {
346 DlIRectToFlutterRect(*(gl_present_info.buffer_damage));
351 .num_rects = frame_damage_rect ?
size_t{1} :
size_t{0},
352 .damage = frame_damage_rect ? &frame_damage_rect.value() :
nullptr,
356 .num_rects = buffer_damage_rect ?
size_t{1} :
size_t{0},
357 .damage = buffer_damage_rect ? &buffer_damage_rect.value() :
nullptr,
363 .fbo_id = gl_present_info.fbo_id,
364 .frame_damage = frame_damage,
365 .buffer_damage = buffer_damage,
368 return present_with_info(
user_data, &present_info);
372 auto gl_fbo_callback =
374 fbo_with_frame_info_callback =
382 frame_info.
size = {gl_frame_info.
width, gl_frame_info.height};
383 return fbo_with_frame_info_callback(
user_data, &frame_info);
387 auto gl_populate_existing_damage =
392 if (!populate_existing_damage) {
394 .
fbo_id =
static_cast<uint32_t
>(
id),
395 .existing_damage = std::nullopt,
401 populate_existing_damage(
user_data,
id, &existing_damage);
403 std::optional<flutter::DlIRect> existing_damage_rect = std::nullopt;
406 if (existing_damage.
num_rects <= 0 || existing_damage.
damage ==
nullptr) {
407 FML_LOG(INFO) <<
"No damage was provided. Forcing full repaint.";
410 for (
size_t i = 0;
i < existing_damage.
num_rects;
i++) {
411 existing_damage_rect = existing_damage_rect->Union(
412 FlutterRectToDlIRect(existing_damage.
damage[
i]));
418 .
fbo_id =
static_cast<uint32_t
>(
id),
419 .existing_damage = existing_damage_rect,
424 std::function<bool()> gl_make_resource_current_callback =
nullptr;
425 if (
SAFE_ACCESS(open_gl_config, make_resource_current,
nullptr) !=
nullptr) {
426 gl_make_resource_current_callback =
434 if (
SAFE_ACCESS(open_gl_config, surface_transformation,
nullptr) !=
nullptr) {
435 gl_surface_transformation_callback =
442 0.0f, 0.0f, 1.0f, 0.0f,
450 if (external_view_embedder) {
451 external_view_embedder->SetSurfaceTransformationCallback(
452 gl_surface_transformation_callback);
457 if (
SAFE_ACCESS(open_gl_config, gl_proc_resolver,
nullptr) !=
nullptr) {
463#if FML_OS_LINUX || FML_OS_WIN
464 gl_proc_resolver = DefaultGLProcResolver;
468 bool fbo_reset_after_present =
469 SAFE_ACCESS(open_gl_config, fbo_reset_after_present,
false);
476 gl_make_resource_current_callback,
477 gl_surface_transformation_callback,
479 gl_populate_existing_damage,
483 [gl_dispatch_table, fbo_reset_after_present, platform_dispatch_table,
485 external_view_embedder =
486 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
487 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
488 std::move(external_view_embedder);
489 if (enable_impeller) {
490 return std::make_unique<flutter::PlatformViewEmbedder>(
493 std::make_unique<flutter::EmbedderSurfaceGLImpeller>(
494 gl_dispatch_table, fbo_reset_after_present,
496 platform_dispatch_table,
500 return std::make_unique<flutter::PlatformViewEmbedder>(
503 std::make_unique<flutter::EmbedderSurfaceGLSkia>(
504 gl_dispatch_table, fbo_reset_after_present,
506 platform_dispatch_table,
511 FML_LOG(ERROR) <<
"This Flutter Engine does not support OpenGL rendering.";
521 platform_dispatch_table,
522 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
523 external_view_embedder,
524 bool enable_impeller) {
529#ifdef SHELL_ENABLE_METAL
539 return ptr(
user_data, &embedder_texture);
541 auto metal_get_texture =
546 frame_info.
size = {
static_cast<uint32_t
>(frame_size.width),
547 static_cast<uint32_t
>(frame_size.height)};
558 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
559 std::move(external_view_embedder);
561 std::unique_ptr<flutter::EmbedderSurface> embedder_surface;
563 if (enable_impeller) {
565 metal_dispatch_table = {
567 .get_texture = metal_get_texture,
569 embedder_surface = std::make_unique<flutter::EmbedderSurfaceMetalImpeller>(
573 metal_dispatch_table, view_embedder);
579 .get_texture = metal_get_texture,
581 embedder_surface = std::make_unique<flutter::EmbedderSurfaceMetalSkia>(
585 metal_dispatch_table, view_embedder);
587 FML_LOG(FATAL) <<
"Impeller opt-out unavailable.";
594 [embedder_surface = std::move(embedder_surface), platform_dispatch_table,
595 external_view_embedder = view_embedder](
flutter::Shell& shell)
mutable {
596 return std::make_unique<flutter::PlatformViewEmbedder>(
599 std::move(embedder_surface),
600 platform_dispatch_table,
601 std::move(external_view_embedder)
605 FML_LOG(ERROR) <<
"This Flutter Engine does not support Metal rendering.";
615 platform_dispatch_table,
616 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
617 external_view_embedder,
618 bool enable_impeller) {
623#ifdef SHELL_ENABLE_VULKAN
624 std::function<
void*(VkInstance,
const char*)>
625 vulkan_get_instance_proc_address =
627 VkInstance
instance,
const char* proc_name) ->
void* {
631 auto vulkan_get_next_image =
636 .size = {
static_cast<uint32_t
>(frame_size.width),
637 static_cast<uint32_t
>(frame_size.height)},
643 auto vulkan_present_image_callback =
654 auto vk_instance =
static_cast<VkInstance
>(config->
vulkan.
instance);
656 vulkan_get_instance_proc_address(vk_instance,
"vkGetInstanceProcAddr");
658 std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder =
659 std::move(external_view_embedder);
661#if IMPELLER_SUPPORTS_RENDERING
662 if (enable_impeller) {
664 vulkan_dispatch_table = {
666 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
667 .get_next_image = vulkan_get_next_image,
668 .present_image = vulkan_present_image_callback,
671 std::unique_ptr<flutter::EmbedderSurfaceVulkanImpeller> embedder_surface =
672 std::make_unique<flutter::EmbedderSurfaceVulkanImpeller>(
681 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
685 [embedder_surface = std::move(embedder_surface),
686 platform_dispatch_table,
687 external_view_embedder =
689 return std::make_unique<flutter::PlatformViewEmbedder>(
692 std::move(embedder_surface),
693 platform_dispatch_table,
694 std::move(external_view_embedder)
701 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
702 .get_next_image = vulkan_get_next_image,
703 .present_image = vulkan_present_image_callback,
706 std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
707 std::make_unique<flutter::EmbedderSurfaceVulkan>(
716 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
720 [embedder_surface = std::move(embedder_surface),
721 platform_dispatch_table,
722 external_view_embedder =
724 return std::make_unique<flutter::PlatformViewEmbedder>(
727 std::move(embedder_surface),
728 platform_dispatch_table,
729 std::move(external_view_embedder)
736 reinterpret_cast<PFN_vkGetInstanceProcAddr
>(proc_addr),
737 .get_next_image = vulkan_get_next_image,
738 .present_image = vulkan_present_image_callback,
741 std::unique_ptr<flutter::EmbedderSurfaceVulkan> embedder_surface =
742 std::make_unique<flutter::EmbedderSurfaceVulkan>(
751 static_cast<VkQueue
>(config->
vulkan.
queue), vulkan_dispatch_table,
755 [embedder_surface = std::move(embedder_surface), platform_dispatch_table,
756 external_view_embedder =
758 return std::make_unique<flutter::PlatformViewEmbedder>(
761 std::move(embedder_surface),
762 platform_dispatch_table,
763 std::move(external_view_embedder)
768 FML_LOG(ERROR) <<
"This Flutter Engine does not support Vulkan rendering.";
778 platform_dispatch_table,
779 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
780 external_view_embedder) {
785 auto software_present_backing_store =
787 const void* allocation,
size_t row_bytes,
size_t height) ->
bool {
792 software_dispatch_table = {
793 software_present_backing_store,
797 [software_dispatch_table, platform_dispatch_table,
798 external_view_embedder =
799 std::move(external_view_embedder)](
flutter::Shell& shell)
mutable {
800 return std::make_unique<flutter::PlatformViewEmbedder>(
803 software_dispatch_table,
804 platform_dispatch_table,
805 std::move(external_view_embedder)
815 platform_dispatch_table,
816 std::unique_ptr<flutter::EmbedderExternalViewEmbedder>
817 external_view_embedder,
818 bool enable_impeller) {
819 if (config ==
nullptr) {
823 switch (config->
type) {
826 config,
user_data, platform_dispatch_table,
827 std::move(external_view_embedder), enable_impeller);
830 config,
user_data, platform_dispatch_table,
831 std::move(external_view_embedder));
834 config,
user_data, platform_dispatch_table,
835 std::move(external_view_embedder), enable_impeller);
838 config,
user_data, platform_dispatch_table,
839 std::move(external_view_embedder), enable_impeller);
847 GrDirectContext* context,
850#ifdef SHELL_ENABLE_GL
851 GrGLTextureInfo texture_info;
852 texture_info.fTarget =
texture->target;
853 texture_info.fID =
texture->name;
854 texture_info.fFormat =
texture->format;
856 GrBackendTexture backend_texture =
858 skgpu::Mipmapped::kNo, texture_info);
860 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
863 FlutterFormatToSkColorType(
texture->format);
868 auto surface = SkSurfaces::WrapBackendTexture(
871 kBottomLeft_GrSurfaceOrigin,
874 SkColorSpace::MakeSRGB(),
876 static_cast<SkSurfaces::TextureReleaseProc
>(
877 texture->destruction_callback),
882 FML_LOG(ERROR) <<
"Could not wrap embedder supplied render texture.";
893 GrDirectContext* context,
896#ifdef SHELL_ENABLE_GL
897 GrGLFramebufferInfo framebuffer_info = {};
898 framebuffer_info.fFormat = framebuffer->
target;
899 framebuffer_info.fFBOID = framebuffer->
name;
901 auto backend_render_target =
902 GrBackendRenderTargets::MakeGL(config.
size.
width,
909 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
912 FlutterFormatToSkColorType(framebuffer->
target);
917 auto surface = SkSurfaces::WrapBackendRenderTarget(
919 backend_render_target,
920 kBottomLeft_GrSurfaceOrigin,
922 SkColorSpace::MakeSRGB(),
924 static_cast<SkSurfaces::RenderTargetReleaseProc
>(
930 FML_LOG(ERROR) <<
"Could not wrap embedder supplied frame-buffer.";
940 GrDirectContext* context,
943#ifdef SHELL_ENABLE_GL
944 GrGLFramebufferInfo framebuffer_info = {};
946 framebuffer_info.fFBOID = 0;
948 auto backend_render_target =
949 GrBackendRenderTargets::MakeGL(config.
size.
width,
956 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
959 FlutterFormatToSkColorType(
surface->format);
964 auto sk_surface = SkSurfaces::WrapBackendRenderTarget(
966 backend_render_target,
967 kBottomLeft_GrSurfaceOrigin,
969 SkColorSpace::MakeSRGB(),
971 static_cast<SkSurfaces::RenderTargetReleaseProc
>(
972 surface->destruction_callback),
977 FML_LOG(ERROR) <<
"Could not wrap embedder supplied frame-buffer.";
987 GrDirectContext* context,
990 const auto image_info =
997 auto captures = std::make_unique<Captures>();
999 captures->user_data = software->
user_data;
1000 auto release_proc = [](
void* pixels,
void* context) {
1001 auto captures =
reinterpret_cast<Captures*
>(context);
1002 if (captures->destruction_callback) {
1003 captures->destruction_callback(captures->user_data);
1009 SkSurfaces::WrapPixels(image_info,
1018 <<
"Could not wrap embedder supplied software render buffer.";
1031 GrDirectContext* context,
1039 const auto image_info = SkImageInfo::Make(
1046 auto captures = std::make_unique<Captures>();
1048 captures->user_data = software->
user_data;
1049 auto release_proc = [](
void* pixels,
void* context) {
1050 auto captures =
reinterpret_cast<Captures*
>(context);
1051 if (captures->destruction_callback) {
1052 captures->destruction_callback(captures->user_data);
1057 SkSurfaces::WrapPixels(image_info,
1066 <<
"Could not wrap embedder supplied software render buffer.";
1076 GrDirectContext* context,
1079#if defined(SHELL_ENABLE_METAL) && !SLIMPELLER
1080 GrMtlTextureInfo texture_info;
1082 FML_LOG(ERROR) <<
"Embedder supplied null Metal texture.";
1085 sk_cfp<FlutterMetalTextureHandle> mtl_texture;
1087 texture_info.fTexture = mtl_texture;
1088 GrBackendTexture backend_texture =
1089 GrBackendTextures::MakeMtl(config.
size.
width,
1091 skgpu::Mipmapped::kNo,
1095 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
1097 auto surface = SkSurfaces::WrapBackendTexture(
1100 kTopLeft_GrSurfaceOrigin,
1102 kBGRA_8888_SkColorType,
1104 &surface_properties,
1105 static_cast<SkSurfaces::TextureReleaseProc
>(
1111 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
1121#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING)
1122static std::optional<impeller::PixelFormat> FlutterFormatToImpellerPixelFormat(
1131 <<
" to impeller::PixelFormat.";
1132 return std::nullopt;
1138static std::unique_ptr<flutter::EmbedderRenderTarget>
1142 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1145#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING)
1146 auto format = FlutterFormatToImpellerPixelFormat(framebuffer->
target);
1147 if (!
format.has_value()) {
1151 const auto& gl_context =
1153 const bool implicit_msaa = aiks_context->GetContext()
1155 ->SupportsImplicitResolvingMSAA();
1159 if (implicit_msaa) {
1167 color0_tex.
size = size;
1174 gl_context.GetReactor(), color0_tex, framebuffer->
name);
1177 if (implicit_msaa) {
1186 depth_stencil_texture_desc.
size = size;
1189 if (implicit_msaa) {
1190 depth_stencil_texture_desc.
type =
1199 gl_context.GetReactor(), depth_stencil_texture_desc);
1203 depth0.
texture = depth_stencil_tex;
1209 stencil0.
texture = depth_stencil_tex;
1223 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1224 backing_store, aiks_context,
1225 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1226 on_release, framebuffer_destruct);
1232static std::unique_ptr<flutter::EmbedderRenderTarget>
1236 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1239#if defined(SHELL_ENABLE_METAL) && defined(IMPELLER_SUPPORTS_RENDERING)
1241 FML_LOG(ERROR) <<
"Embedder supplied null Metal texture.";
1248 resolve_tex_desc.
size = size;
1259 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Metal render texture.";
1263 aiks_context->GetContext()->UpdateOffscreenLayerPixelFormat(
1264 resolve_tex->GetTextureDescriptor().format);
1266 resolve_tex->SetLabel(
"ImpellerBackingStoreResolve");
1272 msaa_tex_desc.
format = resolve_tex->GetTextureDescriptor().format;
1273 msaa_tex_desc.
size = size;
1277 aiks_context->GetContext()->GetResourceAllocator()->CreateTexture(
1280 FML_LOG(ERROR) <<
"Could not allocate MSAA color texture.";
1283 msaa_tex->SetLabel(
"ImpellerBackingStoreColorMSAA");
1295 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1296 backing_store, aiks_context,
1297 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1305 GrDirectContext* context,
1308#ifdef SHELL_ENABLE_VULKAN
1310 FML_LOG(ERROR) <<
"Embedder supplied null Vulkan image.";
1313 GrVkImageInfo image_info = {
1314 .fImage =
reinterpret_cast<VkImage
>(
vulkan->image->image),
1315 .fImageTiling = VK_IMAGE_TILING_OPTIMAL,
1316 .fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1317 .fFormat =
static_cast<VkFormat
>(
vulkan->image->format),
1318 .fImageUsageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
1319 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1320 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
1321 VK_IMAGE_USAGE_SAMPLED_BIT,
1325 auto backend_texture = GrBackendTextures::MakeVk(
1328 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
1330 auto surface = SkSurfaces::WrapBackendTexture(
1333 kTopLeft_GrSurfaceOrigin,
1336 static_cast<VkFormat
>(
vulkan->image->format)),
1337 SkColorSpace::MakeSRGB(),
1338 &surface_properties,
1339 static_cast<SkSurfaces::TextureReleaseProc
>(
1340 vulkan->destruction_callback),
1345 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Vulkan render texture.";
1355static std::unique_ptr<flutter::EmbedderRenderTarget>
1358 sk_sp<SkSurface> skia_surface,
1363 if (!skia_surface) {
1366 return std::make_unique<flutter::EmbedderRenderTargetSkia>(
1367 backing_store, std::move(skia_surface), std::move(on_release),
1368 std::move(on_make_current), std::move(on_clear_current));
1371static std::unique_ptr<flutter::EmbedderRenderTarget>
1373 sk_sp<SkSurface> skia_surface,
1376 std::move(on_release),
nullptr,
nullptr);
1379static std::unique_ptr<flutter::EmbedderRenderTarget>
1383 GrDirectContext* context,
1384 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1385 bool enable_impeller) {
1387 backing_store.
struct_size =
sizeof(backing_store);
1395 TRACE_EVENT0(
"flutter",
"FlutterCompositorCreateBackingStore");
1396 if (!c_create_callback(&config, &backing_store, compositor->
user_data)) {
1397 FML_LOG(ERROR) <<
"Could not create the embedder backing store.";
1402 if (backing_store.
struct_size !=
sizeof(backing_store)) {
1403 FML_LOG(ERROR) <<
"Embedder modified the backing store struct size.";
1413 TRACE_EVENT0(
"flutter",
"FlutterCompositorCollectBackingStore");
1414 c_collect_callback(&backing_store, user_data);
1420 std::unique_ptr<flutter::EmbedderRenderTarget> render_target;
1422 switch (backing_store.
type) {
1429 backing_store, std::move(skia_surface),
1434 if (enable_impeller) {
1436 backing_store, collect_callback.
Release(), aiks_context, config,
1443 backing_store, std::move(skia_surface),
1450 auto on_make_current =
1454 bool invalidate_api_state =
false;
1455 bool ok =
callback(context, &invalidate_api_state);
1456 return {ok, invalidate_api_state};
1459 auto on_clear_current =
1463 bool invalidate_api_state =
false;
1464 bool ok =
callback(context, &invalidate_api_state);
1465 return {ok, invalidate_api_state};
1468 if (enable_impeller) {
1471 FML_LOG(ERROR) <<
"Unimplemented";
1478 backing_store, std::move(skia_surface),
1479 collect_callback.
Release(), on_make_current, on_clear_current);
1489 context, config, &backing_store.
software);
1491 backing_store, std::move(skia_surface), collect_callback.
Release());
1496 context, config, &backing_store.
software2);
1498 backing_store, std::move(skia_surface), collect_callback.
Release());
1502 if (enable_impeller) {
1504 backing_store, collect_callback.
Release(), aiks_context, config,
1505 &backing_store.
metal);
1508 &backing_store.
metal);
1510 backing_store, std::move(skia_surface), collect_callback.
Release());
1515 if (enable_impeller) {
1516 FML_LOG(ERROR) <<
"Unimplemented";
1520 context, config, &backing_store.
vulkan);
1522 backing_store, std::move(skia_surface), collect_callback.
Release());
1528 if (!render_target) {
1529 FML_LOG(ERROR) <<
"Could not create a surface from an embedder provided "
1532 return render_target;
1540 bool enable_impeller) {
1541 if (compositor ==
nullptr) {
1542 return std::unique_ptr<flutter::EmbedderExternalViewEmbedder>{
nullptr};
1545 auto c_create_callback =
1546 SAFE_ACCESS(compositor, create_backing_store_callback,
nullptr);
1547 auto c_collect_callback =
1548 SAFE_ACCESS(compositor, collect_backing_store_callback,
nullptr);
1549 auto c_present_callback =
1550 SAFE_ACCESS(compositor, present_layers_callback,
nullptr);
1551 auto c_present_view_callback =
1552 SAFE_ACCESS(compositor, present_view_callback,
nullptr);
1553 bool avoid_backing_store_cache =
1554 SAFE_ACCESS(compositor, avoid_backing_store_cache,
false);
1557 if (!c_create_callback || !c_collect_callback) {
1559 "Required compositor callbacks absent.");
1562 if ((!c_present_view_callback && !c_present_callback) ||
1563 (c_present_view_callback && c_present_callback)) {
1565 "Either present_layers_callback or "
1566 "present_view_callback must be provided but not both.");
1572 create_render_target_callback =
1573 [captured_compositor, enable_impeller](
1574 GrDirectContext* context,
1575 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1576 const auto& config) {
1578 context, aiks_context,
1583 if (c_present_callback) {
1586 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1591 FML_DCHECK(c_present_view_callback !=
nullptr);
1592 present_callback = [c_present_view_callback,
1595 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1605 return c_present_view_callback(&info);
1609 return std::make_unique<flutter::EmbedderExternalViewEmbedder>(
1610 avoid_backing_store_cache, create_render_target_callback,
1615static std::variant<flutter::ViewportMetrics, std::string>
1618 if (flutter_metrics ==
nullptr) {
1619 return "Invalid metrics handle.";
1627 if (
SAFE_ACCESS(flutter_metrics, has_constraints,
false)) {
1647 return "Window metrics are invalid. Width and height must be within the "
1648 "specified constraints.";
1653 SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1655 SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1657 SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1659 SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1663 return "Device pixel ratio was invalid. It must be greater than zero.";
1670 return "Physical view insets are invalid. They must be non-negative.";
1677 return "Physical view insets are invalid. They cannot be greater than "
1678 "physical height or width.";
1685 std::unique_ptr<flutter::PlatformMessage>
message;
1691 ::Dart_UnloadELF(elf);
1711 "AOT data can only be created in AOT mode.");
1712 }
else if (!source) {
1714 }
else if (!data_out) {
1718 switch (source->
type) {
1722 "Invalid ELF path specified.");
1725 auto aot_data = std::make_unique<_FlutterEngineAOTData>();
1726 const char*
error =
nullptr;
1731 Dart_LoadedElf* loaded_elf =
nullptr;
1733 Dart_LoadedElf* loaded_elf = Dart_LoadELF(
1737 &aot_data->vm_snapshot_data,
1738 &aot_data->vm_snapshot_instrs,
1739 &aot_data->vm_isolate_data,
1740 &aot_data->vm_isolate_instrs
1744 if (loaded_elf ==
nullptr) {
1748 aot_data->loaded_elf.reset(loaded_elf);
1750 *data_out = aot_data.release();
1757 "Invalid FlutterEngineAOTDataSourceType type specified.");
1775 auto make_mapping_callback = [](
const char* path,
bool executable) {
1776 return [path, executable]() {
1788 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1791 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1793 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1798 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1801 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1803 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1807#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1821 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1822 return [mapping, size]() {
1823 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1829 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1832 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1835 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1838 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1846 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1848 args->vm_snapshot_instructions,
1854 make_mapping_callback(
args->isolate_snapshot_data,
1858 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1860 args->isolate_snapshot_instructions,
1872 update_semantics_custom_action_callback,
1874 return [update_semantics_node_callback,
1875 update_semantics_custom_action_callback,
user_data](
1882 if (update_semantics_node_callback !=
nullptr) {
1888 if (update_semantics_custom_action_callback !=
nullptr) {
1890 update_semantics_custom_action_callback(&update_ptr->
custom_actions[
i],
1897 if (update_semantics_node_callback !=
nullptr) {
1902 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1905 if (update_semantics_custom_action_callback !=
nullptr) {
1910 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1921 return [update_semantics_callback,
user_data](
1926 update_semantics_callback(update.get(),
user_data);
1936 return [update_semantics_callback,
user_data](
1941 update_semantics_callback(update.get(),
user_data);
1956 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1963 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1972 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1973 update_semantics_node_callback =
args->update_semantics_node_callback;
1977 update_semantics_custom_action_callback =
nullptr;
1978 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1980 update_semantics_custom_action_callback =
1981 args->update_semantics_custom_action_callback;
1984 if (update_semantics_node_callback !=
nullptr ||
1985 update_semantics_custom_action_callback !=
nullptr) {
1987 update_semantics_node_callback, update_semantics_custom_action_callback,
2021 "Flutter embedder version mismatch. There has been a breaking change. "
2022 "Please consult the changelog and update the embedder.");
2025 if (engine_out ==
nullptr) {
2027 "The engine out parameter was missing.");
2030 if (
args ==
nullptr) {
2032 "The Flutter project arguments were missing.");
2038 "The assets path in the Flutter project arguments was missing.");
2043 <<
"FlutterProjectArgs.main_path is deprecated and should be set null.";
2047 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
2048 "should be set null.";
2053 "The renderer configuration was invalid.");
2056 std::string icu_data_path;
2063 std::string persistent_cache_path =
2090 "Multiple AOT sources specified. Embedders should provide either "
2091 "*_snapshot_* buffers or aot_data, not both.");
2115 "Not running in AOT mode but could not resolve the kernel binary.");
2120 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
2132 const std::string& tag,
2141 std::cout << tag <<
": ";
2143 std::cout <<
message << std::endl;
2151 bool has_update_semantics_2_callback =
2153 bool has_update_semantics_callback =
2155 bool has_legacy_update_semantics_callback =
2156 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
2157 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
2160 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
2161 (has_update_semantics_callback ? 1 : 0) +
2162 (has_legacy_update_semantics_callback ? 1 : 0);
2164 if (semantic_callback_count > 1) {
2167 "Multiple semantics update callbacks provided. "
2168 "Embedders should provide either `update_semantics_callback2`, "
2169 "`update_semantics_callback`, or both "
2170 "`update_semantics_node_callback` and "
2171 "`update_semantics_custom_action_callback`.");
2175 update_semantics_callback =
2179 platform_message_response_callback =
nullptr;
2180 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
2181 platform_message_response_callback =
2182 [ptr =
args->platform_message_callback,
2192 handle->message = std::move(
message);
2193 return ptr(&incoming_message,
user_data);
2199 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
2205 compute_platform_resolved_locale_callback =
nullptr;
2206 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
2208 compute_platform_resolved_locale_callback =
2209 [ptr =
args->compute_platform_resolved_locale_callback](
2210 const std::vector<std::string>& supported_locales_data) {
2211 const size_t number_of_strings_per_locale = 3;
2212 size_t locale_count =
2213 supported_locales_data.size() / number_of_strings_per_locale;
2214 std::vector<FlutterLocale> supported_locales;
2215 std::vector<const FlutterLocale*> supported_locales_ptr;
2216 for (
size_t i = 0;
i < locale_count; ++
i) {
2217 supported_locales.push_back(
2220 supported_locales_data[
i * number_of_strings_per_locale +
2224 supported_locales_data[
i * number_of_strings_per_locale +
2228 supported_locales_data[
i * number_of_strings_per_locale +
2231 .variant_code =
nullptr});
2232 supported_locales_ptr.push_back(&supported_locales[
i]);
2236 ptr(supported_locales_ptr.data(), locale_count);
2238 std::unique_ptr<std::vector<std::string>> out =
2239 std::make_unique<std::vector<std::string>>();
2241 std::string language_code(
SAFE_ACCESS(result, language_code,
""));
2242 if (language_code !=
"") {
2243 out->push_back(language_code);
2244 out->emplace_back(
SAFE_ACCESS(result, country_code,
""));
2245 out->emplace_back(
SAFE_ACCESS(result, script_code,
""));
2253 on_pre_engine_restart_callback =
nullptr;
2254 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
2255 on_pre_engine_restart_callback = [ptr =
2256 args->on_pre_engine_restart_callback,
2263 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
2264 const std::string&
name,
bool listening) {
2272 view_focus_change_request_callback =
nullptr;
2275 view_focus_change_request_callback =
2276 [ptr =
args->view_focus_change_request_callback,
2291 if (!external_view_embedder_result.ok()) {
2292 FML_LOG(ERROR) << external_view_embedder_result.status().message();
2294 "Compositor arguments were invalid.");
2299 update_semantics_callback,
2300 platform_message_response_callback,
2302 compute_platform_resolved_locale_callback,
2303 on_pre_engine_restart_callback,
2304 channel_update_callback,
2305 view_focus_change_request_callback,
2309 config,
user_data, platform_dispatch_table,
2310 std::move(external_view_embedder_result.value()),
2313 if (!on_create_platform_view) {
2316 "Could not infer platform view creation callback.");
2321 return std::make_unique<flutter::Rasterizer>(shell);
2325 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2326 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2328#ifdef SHELL_ENABLE_GL
2330 external_texture_callback;
2333 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2334 nullptr) !=
nullptr) {
2335 external_texture_callback =
2337 int64_t texture_identifier,
size_t width,
2338 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2339 std::unique_ptr<FlutterOpenGLTexture>
texture =
2340 std::make_unique<FlutterOpenGLTexture>();
2346 external_texture_resolver =
2347 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2351#ifdef SHELL_ENABLE_METAL
2353 external_texture_metal_callback;
2356 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2357 external_texture_metal_callback =
2359 int64_t texture_identifier,
size_t width,
2360 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2361 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2362 std::make_unique<FlutterMetalExternalTexture>();
2369 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2370 external_texture_metal_callback);
2374 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2375 auto thread_config_callback = [&custom_task_runners](
2378 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2382 switch (config.priority) {
2396 custom_task_runners->thread_priority_setter(priority);
2400 custom_task_runners, thread_config_callback);
2402 if (!thread_host || !thread_host->IsValid()) {
2404 "Could not set up or infer thread configuration "
2405 "to run the Flutter engine on.");
2408 auto task_runners = thread_host->GetTaskRunners();
2410 if (!task_runners.IsValid()) {
2412 "Task runner configuration was invalid.");
2416 bool has_ui_thread_message_loop =
2417 task_runners.GetUITaskRunner()->GetTaskQueueId().is_valid();
2423 if (has_ui_thread_message_loop) {
2430 if (has_ui_thread_message_loop) {
2435 auto run_configuration =
2439 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2440 if (!dart_entrypoint.empty()) {
2441 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2448 "Could not determine Dart entrypoint arguments "
2449 "as dart_entrypoint_argc "
2450 "was set, but dart_entrypoint_argv was null.");
2452 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2453 for (
int i = 0;
i <
args->dart_entrypoint_argc; ++
i) {
2454 arguments[
i] = std::string{
args->dart_entrypoint_argv[
i]};
2456 run_configuration.SetEntrypointArgs(std::move(arguments));
2460 run_configuration.SetEngineId(
args->engine_id);
2463 if (!run_configuration.IsValid()) {
2466 "Could not infer the Flutter project to run from given arguments.");
2470 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2471 std::move(thread_host),
2472 std::move(task_runners),
2473 std::move(settings),
2474 std::move(run_configuration),
2475 on_create_platform_view,
2476 on_create_rasterizer,
2477 std::move(external_texture_resolver)
2482 embedder_engine.release());
2496 if (embedder_engine->IsValid()) {
2501 if (!embedder_engine->LaunchShell()) {
2503 "Could not launch the engine using supplied "
2504 "initialization arguments.");
2508 if (!embedder_engine->NotifyCreated()) {
2510 "Could not create platform view components.");
2514 if (!embedder_engine->RunRootIsolate()) {
2517 "Could not run the root isolate of the Flutter application using the "
2518 "project arguments specified.");
2533 "Add view info handle was invalid.");
2540 "Add view info was invalid. The implicit view cannot be added.");
2546 "Add view info was invalid. The info and "
2547 "window metric view IDs must match.");
2555 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2558 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2562 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2566 if (!embedder_engine->IsValid()) {
2575 result.
added = added;
2577 c_callback(&result);
2580 embedder_engine->GetShell().GetPlatformView()->AddView(
view_id, metrics,
2594 "Remove view info handle was invalid.");
2600 "Remove view info was invalid. The implicit view cannot be removed.");
2609 if (!embedder_engine->IsValid()) {
2620 c_callback(&result);
2623 embedder_engine->GetShell().GetPlatformView()->RemoveView(info->
view_id,
2636 "View focus event must not be null.");
2640 if (!embedder_engine->IsValid()) {
2646 "The event struct has invalid size.");
2654 embedder_engine->GetShell().GetPlatformView()->SendViewFocusEvent(
2669 embedder_engine->CollectShell();
2670 embedder_engine->CollectThreadHost();
2681 delete embedder_engine;
2688 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2694 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2696 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2700 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2706 "Viewport metrics were invalid.");
2741 switch (device_kind) {
2797 size_t events_count) {
2802 if (pointers ==
nullptr || events_count == 0) {
2806 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2810 for (
size_t i = 0;
i < events_count; ++
i) {
2812 pointer_data.
Clear();
2836 if (device_kind == 0) {
2864 packet->SetPointerData(
i, pointer_data);
2866 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2870 ->DispatchPointerDataPacket(std::move(packet))
2873 "Could not dispatch pointer events to the "
2874 "running Flutter application.");
2879 switch (event_kind) {
2892 switch (event_kind) {
2913 const uint8_t*
data,
2943 return release_result;
2955 if (event ==
nullptr) {
2973 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2975 struct MessageData {
2980 MessageData* message_data =
2986 packet->data().size(),
2988 auto message_data = std::unique_ptr<MessageData>(
2989 reinterpret_cast<MessageData*>(user_data));
2990 if (message_data->callback == nullptr) {
2993 bool handled =
false;
2995 handled = *
data != 0;
2997 message_data->callback(handled, message_data->user_data);
3009 if (flutter_message ==
nullptr) {
3018 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
3021 if (message_size != 0 && message_data ==
nullptr) {
3024 "Message size was non-zero but the message data was nullptr.");
3028 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
3031 if (response_handle && response_handle->
message) {
3032 response = response_handle->
message->response();
3035 std::unique_ptr<flutter::PlatformMessage>
message;
3036 if (message_size == 0) {
3037 message = std::make_unique<flutter::PlatformMessage>(
3038 flutter_message->
channel, response);
3040 message = std::make_unique<flutter::PlatformMessage>(
3046 ->SendPlatformMessage(std::move(
message))
3049 "Could not send a message to the running "
3050 "Flutter application.");
3062 if (data_callback ==
nullptr || response_out ==
nullptr) {
3068 [
user_data, data_callback](
const uint8_t*
data,
size_t size) {
3074 .GetPlatformTaskRunner();
3078 handle->message = std::make_unique<flutter::PlatformMessage>(
3082 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
3083 std::move(platform_task_runner), response_callback));
3084 *response_out = handle;
3095 if (response ==
nullptr) {
3106 const uint8_t*
data,
3107 size_t data_length) {
3108 if (data_length != 0 &&
data ==
nullptr) {
3111 "Data size was non zero but the pointer to the data was null.");
3114 auto response = handle->
message->response();
3117 if (data_length == 0) {
3118 response->CompleteEmpty();
3120 response->Complete(std::make_unique<fml::DataMapping>(
3121 std::vector<uint8_t>({
data,
data + data_length})));
3137 int64_t texture_identifier) {
3142 if (texture_identifier == 0) {
3144 "Texture identifier was invalid.");
3147 texture_identifier)) {
3149 "Could not register the specified texture.");
3156 int64_t texture_identifier) {
3161 if (texture_identifier == 0) {
3163 "Texture identifier was invalid.");
3167 texture_identifier)) {
3169 "Could not un-register the specified texture.");
3177 int64_t texture_identifier) {
3181 if (texture_identifier == 0) {
3185 ->MarkTextureFrameAvailable(texture_identifier)) {
3188 "Could not mark the texture frame as being available.");
3202 "Could not update semantics state.");
3214 ->SetAccessibilityFeatures(flags)) {
3216 "Could not update accessibility features.");
3225 const uint8_t*
data,
3226 size_t data_length) {
3233 .data_length = data_length};
3249 "Could not dispatch semantics action.");
3257 uint64_t frame_start_time_nanos,
3258 uint64_t frame_target_time_nanos) {
3272 baton, start_time, target_time)) {
3275 "Could not notify the running engine instance of a Vsync event.");
3287 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
3290 ->ReloadSystemFonts()) {
3292 "Could not reload system fonts.");
3322 "Render thread callback was null.");
3328 ->PostRenderThreadTask(task)
3331 "Could not post the render thread task.");
3346 reinterpret_cast<intptr_t
>(task->
runner))) {
3355 "Could not run the specified task.");
3360 const rapidjson::Document& document,
3361 const std::string& channel_name) {
3362 if (channel_name.empty()) {
3366 rapidjson::StringBuffer buffer;
3367 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3369 if (!document.Accept(writer)) {
3373 const char*
message = buffer.GetString();
3375 if (
message ==
nullptr || buffer.GetSize() == 0) {
3379 auto platform_message = std::make_unique<flutter::PlatformMessage>(
3380 channel_name.c_str(),
3387 ->SendPlatformMessage(std::move(platform_message));
3393 size_t locales_count) {
3398 if (locales_count == 0) {
3402 if (locales ==
nullptr) {
3406 rapidjson::Document document;
3407 auto&
allocator = document.GetAllocator();
3409 document.SetObject();
3410 document.AddMember(
"method",
"setLocale",
allocator);
3412 rapidjson::Value
args(rapidjson::kArrayType);
3414 for (
size_t i = 0;
i < locales_count; ++
i) {
3416 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3417 if (language_code_str ==
nullptr || ::strlen(language_code_str) == 0) {
3420 "Language code is required but not present in FlutterLocale.");
3423 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3424 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3425 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3427 rapidjson::Value language_code, country_code, script_code, variant_code;
3429 language_code.SetString(language_code_str,
allocator);
3430 country_code.SetString(country_code_str ? country_code_str :
"",
allocator);
3431 script_code.SetString(script_code_str ? script_code_str :
"",
allocator);
3432 variant_code.SetString(variant_code_str ? variant_code_str :
"",
allocator);
3445 "Could not send message to update locale of "
3446 "a running Flutter application.");
3465 if (port == ILLEGAL_PORT) {
3467 "Attempted to post to an illegal port.");
3470 if (
object ==
nullptr) {
3472 "Invalid Dart object to post.");
3475 Dart_CObject dart_object = {};
3478 switch (object->
type) {
3480 dart_object.type = Dart_CObject_kNull;
3483 dart_object.type = Dart_CObject_kBool;
3484 dart_object.value.as_bool =
object->bool_value;
3487 dart_object.type = Dart_CObject_kInt32;
3488 dart_object.value.as_int32 =
object->int32_value;
3491 dart_object.type = Dart_CObject_kInt64;
3492 dart_object.value.as_int64 =
object->int64_value;
3495 dart_object.type = Dart_CObject_kDouble;
3496 dart_object.value.as_double =
object->double_value;
3501 "kFlutterEngineDartObjectTypeString must be "
3502 "a null terminated string but was null.");
3504 dart_object.type = Dart_CObject_kString;
3505 dart_object.value.as_string =
const_cast<char*
>(
object->string_value);
3509 if (buffer ==
nullptr) {
3511 "kFlutterEngineDartObjectTypeBuffer must "
3512 "specify a buffer but found nullptr.");
3523 dart_object.type = Dart_CObject_kTypedData;
3524 dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
3525 dart_object.value.as_typed_data.length = buffer_size;
3526 dart_object.value.as_typed_data.values = buffer;
3528 struct ExternalTypedDataPeer {
3532 auto peer =
new ExternalTypedDataPeer();
3547 dart_object.type = Dart_CObject_kExternalTypedData;
3548 dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
3549 dart_object.value.as_external_typed_data.length = buffer_size;
3550 dart_object.value.as_external_typed_data.data = buffer;
3551 dart_object.value.as_external_typed_data.peer = peer;
3552 dart_object.value.as_external_typed_data.callback =
3553 +[](
void* unused_isolate_callback_data,
void* peer) {
3554 auto typed_peer =
reinterpret_cast<ExternalTypedDataPeer*
>(peer);
3555 typed_peer->trampoline(typed_peer->user_data);
3563 "Invalid FlutterEngineDartObjectType type specified.");
3566 if (!Dart_PostCObject(port, &dart_object)) {
3568 "Could not post the object to the Dart VM.");
3573 typed_data_finalizer.
Release();
3584 engine->GetShell().NotifyLowMemoryWarning();
3586 rapidjson::Document document;
3587 auto&
allocator = document.GetAllocator();
3589 document.SetObject();
3590 document.AddMember(
"type",
"memoryPressure",
allocator);
3596 "Could not dispatch the low memory notification message.");
3609 "Invalid native thread callback.");
3613 ->PostTaskOnEngineManagedNativeThreads(
3619 "Internal error while attempting to post "
3620 "tasks to all threads.");
3625 size_t display_count) {
3626 std::set<FlutterEngineDisplayId> display_ids;
3627 for (
size_t i = 0;
i < display_count;
i++) {
3628 if (
displays[
i].single_display && display_count != 1) {
3631 display_ids.insert(
displays[
i].display_id);
3634 return display_ids.size() == display_count;
3642 size_t display_count) {
3643 if (raw_engine ==
nullptr) {
3647 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3650 "Invalid FlutterEngineDisplay configuration specified.");
3655 switch (update_type) {
3657 std::vector<std::unique_ptr<flutter::Display>>
displays;
3658 const auto* display = embedder_displays;
3659 for (
size_t i = 0;
i < display_count;
i++) {
3660 displays.push_back(std::make_unique<flutter::Display>(
3667 reinterpret_cast<const uint8_t*
>(display) + display->struct_size);
3675 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3688 "Could not schedule frame.");
3701 "Next frame callback was null.");
3710 if (!weak_platform_view) {
3712 "Platform view unavailable.");
3715 weak_platform_view->SetNextFrameCallback(
3726#define SET_PROC(member, function) \
3727 if (STRUCT_HAS_MEMBER(table, member)) { \
3728 table->member = &function; \
3742 SET_PROC(PlatformMessageCreateResponseHandle,
3744 SET_PROC(PlatformMessageReleaseResponseHandle,
3746 SET_PROC(SendPlatformMessageResponse,
3750 SET_PROC(MarkExternalTextureFrameAvailable,
3753 SET_PROC(UpdateAccessibilityFeatures,
3769 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 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[]
static flutter::Shell::CreateCallback< flutter::PlatformView > InferPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller)
FlutterEngineResult 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)
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::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)
static flutter::KeyEventDeviceType MapKeyEventDeviceType(FlutterKeyEventDeviceType event_kind)
static bool IsRendererValid(const FlutterRendererConfig *config)
static std::unique_ptr< flutter::EmbedderRenderTarget > MakeRenderTargetFromBackingStoreImpeller(FlutterBackingStore backing_store, const fml::closure &on_release, const std::shared_ptr< impeller::AiksContext > &aiks_context, const FlutterBackingStoreConfig &config, const FlutterOpenGLFramebuffer *framebuffer)
std::unique_ptr< Dart_LoadedElf, LoadedElfDeleter > UniqueLoadedElf
FlutterEngineResult FlutterEngineDispatchSemanticsAction(FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t node_id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
Dispatch a semantics action to the specified semantics node 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)
static flutter::Shell::CreateCallback< flutter::PlatformView > InferOpenGLPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller)
void PopulateJITSnapshotMappingCallbacks(const FlutterProjectArgs *args, flutter::Settings &settings)
static bool IsVulkanRendererConfigValid(const FlutterRendererConfig *config)
FlutterEngineResult 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 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)
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)
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
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()
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...
std::shared_ptr< const fml::Mapping > data
#define TRACE_EVENT0(category_group, name)