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.";
1262 resolve_tex->SetLabel(
"ImpellerBackingStoreResolve");
1268 msaa_tex_desc.
format = resolve_tex->GetTextureDescriptor().format;
1269 msaa_tex_desc.
size = size;
1273 aiks_context->GetContext()->GetResourceAllocator()->CreateTexture(
1276 FML_LOG(ERROR) <<
"Could not allocate MSAA color texture.";
1279 msaa_tex->SetLabel(
"ImpellerBackingStoreColorMSAA");
1291 return std::make_unique<flutter::EmbedderRenderTargetImpeller>(
1292 backing_store, aiks_context,
1293 std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)),
1301 GrDirectContext* context,
1304#ifdef SHELL_ENABLE_VULKAN
1306 FML_LOG(ERROR) <<
"Embedder supplied null Vulkan image.";
1309 GrVkImageInfo image_info = {
1310 .fImage =
reinterpret_cast<VkImage
>(
vulkan->image->image),
1311 .fImageTiling = VK_IMAGE_TILING_OPTIMAL,
1312 .fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1313 .fFormat =
static_cast<VkFormat
>(
vulkan->image->format),
1314 .fImageUsageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
1315 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1316 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
1317 VK_IMAGE_USAGE_SAMPLED_BIT,
1321 auto backend_texture = GrBackendTextures::MakeVk(
1324 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
1326 auto surface = SkSurfaces::WrapBackendTexture(
1329 kTopLeft_GrSurfaceOrigin,
1332 static_cast<VkFormat
>(
vulkan->image->format)),
1333 SkColorSpace::MakeSRGB(),
1334 &surface_properties,
1335 static_cast<SkSurfaces::TextureReleaseProc
>(
1336 vulkan->destruction_callback),
1341 FML_LOG(ERROR) <<
"Could not wrap embedder supplied Vulkan render texture.";
1351static std::unique_ptr<flutter::EmbedderRenderTarget>
1354 sk_sp<SkSurface> skia_surface,
1359 if (!skia_surface) {
1362 return std::make_unique<flutter::EmbedderRenderTargetSkia>(
1363 backing_store, std::move(skia_surface), std::move(on_release),
1364 std::move(on_make_current), std::move(on_clear_current));
1367static std::unique_ptr<flutter::EmbedderRenderTarget>
1369 sk_sp<SkSurface> skia_surface,
1372 std::move(on_release),
nullptr,
nullptr);
1375static std::unique_ptr<flutter::EmbedderRenderTarget>
1379 GrDirectContext* context,
1380 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1381 bool enable_impeller) {
1383 backing_store.
struct_size =
sizeof(backing_store);
1391 TRACE_EVENT0(
"flutter",
"FlutterCompositorCreateBackingStore");
1392 if (!c_create_callback(&config, &backing_store, compositor->
user_data)) {
1393 FML_LOG(ERROR) <<
"Could not create the embedder backing store.";
1398 if (backing_store.
struct_size !=
sizeof(backing_store)) {
1399 FML_LOG(ERROR) <<
"Embedder modified the backing store struct size.";
1409 TRACE_EVENT0(
"flutter",
"FlutterCompositorCollectBackingStore");
1410 c_collect_callback(&backing_store, user_data);
1416 std::unique_ptr<flutter::EmbedderRenderTarget> render_target;
1418 switch (backing_store.
type) {
1425 backing_store, std::move(skia_surface),
1430 if (enable_impeller) {
1432 backing_store, collect_callback.
Release(), aiks_context, config,
1439 backing_store, std::move(skia_surface),
1446 auto on_make_current =
1450 bool invalidate_api_state =
false;
1451 bool ok =
callback(context, &invalidate_api_state);
1452 return {ok, invalidate_api_state};
1455 auto on_clear_current =
1459 bool invalidate_api_state =
false;
1460 bool ok =
callback(context, &invalidate_api_state);
1461 return {ok, invalidate_api_state};
1464 if (enable_impeller) {
1467 FML_LOG(ERROR) <<
"Unimplemented";
1474 backing_store, std::move(skia_surface),
1475 collect_callback.
Release(), on_make_current, on_clear_current);
1485 context, config, &backing_store.
software);
1487 backing_store, std::move(skia_surface), collect_callback.
Release());
1492 context, config, &backing_store.
software2);
1494 backing_store, std::move(skia_surface), collect_callback.
Release());
1498 if (enable_impeller) {
1500 backing_store, collect_callback.
Release(), aiks_context, config,
1501 &backing_store.
metal);
1504 &backing_store.
metal);
1506 backing_store, std::move(skia_surface), collect_callback.
Release());
1511 if (enable_impeller) {
1512 FML_LOG(ERROR) <<
"Unimplemented";
1516 context, config, &backing_store.
vulkan);
1518 backing_store, std::move(skia_surface), collect_callback.
Release());
1524 if (!render_target) {
1525 FML_LOG(ERROR) <<
"Could not create a surface from an embedder provided "
1528 return render_target;
1536 bool enable_impeller) {
1537 if (compositor ==
nullptr) {
1538 return std::unique_ptr<flutter::EmbedderExternalViewEmbedder>{
nullptr};
1541 auto c_create_callback =
1542 SAFE_ACCESS(compositor, create_backing_store_callback,
nullptr);
1543 auto c_collect_callback =
1544 SAFE_ACCESS(compositor, collect_backing_store_callback,
nullptr);
1545 auto c_present_callback =
1546 SAFE_ACCESS(compositor, present_layers_callback,
nullptr);
1547 auto c_present_view_callback =
1548 SAFE_ACCESS(compositor, present_view_callback,
nullptr);
1549 bool avoid_backing_store_cache =
1550 SAFE_ACCESS(compositor, avoid_backing_store_cache,
false);
1553 if (!c_create_callback || !c_collect_callback) {
1555 "Required compositor callbacks absent.");
1558 if ((!c_present_view_callback && !c_present_callback) ||
1559 (c_present_view_callback && c_present_callback)) {
1561 "Either present_layers_callback or "
1562 "present_view_callback must be provided but not both.");
1568 create_render_target_callback =
1569 [captured_compositor, enable_impeller](
1570 GrDirectContext* context,
1571 const std::shared_ptr<impeller::AiksContext>& aiks_context,
1572 const auto& config) {
1574 context, aiks_context,
1579 if (c_present_callback) {
1582 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1587 FML_DCHECK(c_present_view_callback !=
nullptr);
1588 present_callback = [c_present_view_callback,
1591 TRACE_EVENT0(
"flutter",
"FlutterCompositorPresentLayers");
1601 return c_present_view_callback(&info);
1605 return std::make_unique<flutter::EmbedderExternalViewEmbedder>(
1606 avoid_backing_store_cache, create_render_target_callback,
1611static std::variant<flutter::ViewportMetrics, std::string>
1614 if (flutter_metrics ==
nullptr) {
1615 return "Invalid metrics handle.";
1624 SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1626 SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1628 SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1630 SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1634 return "Device pixel ratio was invalid. It must be greater than zero.";
1641 return "Physical view insets are invalid. They must be non-negative.";
1648 return "Physical view insets are invalid. They cannot be greater than "
1649 "physical height or width.";
1661 std::unique_ptr<flutter::PlatformMessage>
message;
1667 ::Dart_UnloadELF(elf);
1687 "AOT data can only be created in AOT mode.");
1688 }
else if (!source) {
1690 }
else if (!data_out) {
1694 switch (source->
type) {
1698 "Invalid ELF path specified.");
1701 auto aot_data = std::make_unique<_FlutterEngineAOTData>();
1702 const char*
error =
nullptr;
1707 Dart_LoadedElf* loaded_elf =
nullptr;
1709 Dart_LoadedElf* loaded_elf = Dart_LoadELF(
1713 &aot_data->vm_snapshot_data,
1714 &aot_data->vm_snapshot_instrs,
1715 &aot_data->vm_isolate_data,
1716 &aot_data->vm_isolate_instrs
1720 if (loaded_elf ==
nullptr) {
1724 aot_data->loaded_elf.reset(loaded_elf);
1726 *data_out = aot_data.release();
1733 "Invalid FlutterEngineAOTDataSourceType type specified.");
1751 auto make_mapping_callback = [](
const char* path,
bool executable) {
1752 return [path, executable]() {
1764 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1767 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1769 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1774 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1777 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1779 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1783#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1797 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1798 return [mapping, size]() {
1799 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1805 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1808 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1811 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1814 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1822 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1824 args->vm_snapshot_instructions,
1830 make_mapping_callback(
args->isolate_snapshot_data,
1834 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1836 args->isolate_snapshot_instructions,
1848 update_semantics_custom_action_callback,
1850 return [update_semantics_node_callback,
1851 update_semantics_custom_action_callback,
user_data](
1858 if (update_semantics_node_callback !=
nullptr) {
1864 if (update_semantics_custom_action_callback !=
nullptr) {
1866 update_semantics_custom_action_callback(&update_ptr->
custom_actions[
i],
1873 if (update_semantics_node_callback !=
nullptr) {
1878 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1881 if (update_semantics_custom_action_callback !=
nullptr) {
1886 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1897 return [update_semantics_callback,
user_data](
1902 update_semantics_callback(update.get(),
user_data);
1912 return [update_semantics_callback,
user_data](
1917 update_semantics_callback(update.get(),
user_data);
1932 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1939 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1948 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1949 update_semantics_node_callback =
args->update_semantics_node_callback;
1953 update_semantics_custom_action_callback =
nullptr;
1954 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1956 update_semantics_custom_action_callback =
1957 args->update_semantics_custom_action_callback;
1960 if (update_semantics_node_callback !=
nullptr ||
1961 update_semantics_custom_action_callback !=
nullptr) {
1963 update_semantics_node_callback, update_semantics_custom_action_callback,
1997 "Flutter embedder version mismatch. There has been a breaking change. "
1998 "Please consult the changelog and update the embedder.");
2001 if (engine_out ==
nullptr) {
2003 "The engine out parameter was missing.");
2006 if (
args ==
nullptr) {
2008 "The Flutter project arguments were missing.");
2014 "The assets path in the Flutter project arguments was missing.");
2019 <<
"FlutterProjectArgs.main_path is deprecated and should be set null.";
2023 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
2024 "should be set null.";
2029 "The renderer configuration was invalid.");
2032 std::string icu_data_path;
2039 std::string persistent_cache_path =
2066 "Multiple AOT sources specified. Embedders should provide either "
2067 "*_snapshot_* buffers or aot_data, not both.");
2090 "Not running in AOT mode but could not resolve the kernel binary.");
2095 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
2107 const std::string& tag,
2116 std::cout << tag <<
": ";
2118 std::cout <<
message << std::endl;
2126 bool has_update_semantics_2_callback =
2128 bool has_update_semantics_callback =
2130 bool has_legacy_update_semantics_callback =
2131 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
2132 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
2135 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
2136 (has_update_semantics_callback ? 1 : 0) +
2137 (has_legacy_update_semantics_callback ? 1 : 0);
2139 if (semantic_callback_count > 1) {
2142 "Multiple semantics update callbacks provided. "
2143 "Embedders should provide either `update_semantics_callback2`, "
2144 "`update_semantics_callback`, or both "
2145 "`update_semantics_node_callback` and "
2146 "`update_semantics_custom_action_callback`.");
2150 update_semantics_callback =
2154 platform_message_response_callback =
nullptr;
2155 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
2156 platform_message_response_callback =
2157 [ptr =
args->platform_message_callback,
2167 handle->message = std::move(
message);
2168 return ptr(&incoming_message,
user_data);
2174 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
2180 compute_platform_resolved_locale_callback =
nullptr;
2181 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
2183 compute_platform_resolved_locale_callback =
2184 [ptr =
args->compute_platform_resolved_locale_callback](
2185 const std::vector<std::string>& supported_locales_data) {
2186 const size_t number_of_strings_per_locale = 3;
2187 size_t locale_count =
2188 supported_locales_data.size() / number_of_strings_per_locale;
2189 std::vector<FlutterLocale> supported_locales;
2190 std::vector<const FlutterLocale*> supported_locales_ptr;
2191 for (
size_t i = 0;
i < locale_count; ++
i) {
2192 supported_locales.push_back(
2195 supported_locales_data[
i * number_of_strings_per_locale +
2199 supported_locales_data[
i * number_of_strings_per_locale +
2203 supported_locales_data[
i * number_of_strings_per_locale +
2206 .variant_code =
nullptr});
2207 supported_locales_ptr.push_back(&supported_locales[
i]);
2211 ptr(supported_locales_ptr.data(), locale_count);
2213 std::unique_ptr<std::vector<std::string>> out =
2214 std::make_unique<std::vector<std::string>>();
2216 std::string language_code(
SAFE_ACCESS(result, language_code,
""));
2217 if (language_code !=
"") {
2218 out->push_back(language_code);
2219 out->emplace_back(
SAFE_ACCESS(result, country_code,
""));
2220 out->emplace_back(
SAFE_ACCESS(result, script_code,
""));
2228 on_pre_engine_restart_callback =
nullptr;
2229 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
2230 on_pre_engine_restart_callback = [ptr =
2231 args->on_pre_engine_restart_callback,
2238 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
2239 const std::string&
name,
bool listening) {
2247 view_focus_change_request_callback =
nullptr;
2250 view_focus_change_request_callback =
2251 [ptr =
args->view_focus_change_request_callback,
2266 if (!external_view_embedder_result.ok()) {
2267 FML_LOG(ERROR) << external_view_embedder_result.status().message();
2269 "Compositor arguments were invalid.");
2274 update_semantics_callback,
2275 platform_message_response_callback,
2277 compute_platform_resolved_locale_callback,
2278 on_pre_engine_restart_callback,
2279 channel_update_callback,
2280 view_focus_change_request_callback,
2284 config,
user_data, platform_dispatch_table,
2285 std::move(external_view_embedder_result.value()),
2288 if (!on_create_platform_view) {
2291 "Could not infer platform view creation callback.");
2296 return std::make_unique<flutter::Rasterizer>(shell);
2300 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2301 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2303#ifdef SHELL_ENABLE_GL
2305 external_texture_callback;
2308 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2309 nullptr) !=
nullptr) {
2310 external_texture_callback =
2312 int64_t texture_identifier,
size_t width,
2313 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2314 std::unique_ptr<FlutterOpenGLTexture>
texture =
2315 std::make_unique<FlutterOpenGLTexture>();
2321 external_texture_resolver =
2322 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2326#ifdef SHELL_ENABLE_METAL
2328 external_texture_metal_callback;
2331 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2332 external_texture_metal_callback =
2334 int64_t texture_identifier,
size_t width,
2335 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2336 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2337 std::make_unique<FlutterMetalExternalTexture>();
2344 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2345 external_texture_metal_callback);
2349 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2350 auto thread_config_callback = [&custom_task_runners](
2353 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2357 switch (config.priority) {
2371 custom_task_runners->thread_priority_setter(priority);
2375 custom_task_runners, thread_config_callback);
2377 if (!thread_host || !thread_host->IsValid()) {
2379 "Could not set up or infer thread configuration "
2380 "to run the Flutter engine on.");
2383 auto task_runners = thread_host->GetTaskRunners();
2385 if (!task_runners.IsValid()) {
2387 "Task runner configuration was invalid.");
2391 bool has_ui_thread_message_loop =
2392 task_runners.GetUITaskRunner()->GetTaskQueueId().is_valid();
2398 if (has_ui_thread_message_loop) {
2405 if (has_ui_thread_message_loop) {
2410 auto run_configuration =
2414 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2415 if (!dart_entrypoint.empty()) {
2416 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2423 "Could not determine Dart entrypoint arguments "
2424 "as dart_entrypoint_argc "
2425 "was set, but dart_entrypoint_argv was null.");
2427 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2428 for (
int i = 0;
i <
args->dart_entrypoint_argc; ++
i) {
2429 arguments[
i] = std::string{
args->dart_entrypoint_argv[
i]};
2431 run_configuration.SetEntrypointArgs(std::move(arguments));
2435 run_configuration.SetEngineId(
args->engine_id);
2438 if (!run_configuration.IsValid()) {
2441 "Could not infer the Flutter project to run from given arguments.");
2445 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2446 std::move(thread_host),
2447 std::move(task_runners),
2448 std::move(settings),
2449 std::move(run_configuration),
2450 on_create_platform_view,
2451 on_create_rasterizer,
2452 std::move(external_texture_resolver)
2457 embedder_engine.release());
2471 if (embedder_engine->IsValid()) {
2476 if (!embedder_engine->LaunchShell()) {
2478 "Could not launch the engine using supplied "
2479 "initialization arguments.");
2483 if (!embedder_engine->NotifyCreated()) {
2485 "Could not create platform view components.");
2489 if (!embedder_engine->RunRootIsolate()) {
2492 "Could not run the root isolate of the Flutter application using the "
2493 "project arguments specified.");
2508 "Add view info handle was invalid.");
2515 "Add view info was invalid. The implicit view cannot be added.");
2521 "Add view info was invalid. The info and "
2522 "window metric view IDs must match.");
2530 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2533 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2537 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2541 if (!embedder_engine->IsValid()) {
2550 result.
added = added;
2552 c_callback(&result);
2555 embedder_engine->GetShell().GetPlatformView()->AddView(
view_id, metrics,
2569 "Remove view info handle was invalid.");
2575 "Remove view info was invalid. The implicit view cannot be removed.");
2584 if (!embedder_engine->IsValid()) {
2595 c_callback(&result);
2598 embedder_engine->GetShell().GetPlatformView()->RemoveView(info->
view_id,
2611 "View focus event must not be null.");
2615 if (!embedder_engine->IsValid()) {
2621 "The event struct has invalid size.");
2629 embedder_engine->GetShell().GetPlatformView()->SendViewFocusEvent(
2644 embedder_engine->CollectShell();
2645 embedder_engine->CollectThreadHost();
2656 delete embedder_engine;
2663 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2669 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2671 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2675 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2681 "Viewport metrics were invalid.");
2716 switch (device_kind) {
2772 size_t events_count) {
2777 if (pointers ==
nullptr || events_count == 0) {
2781 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2785 for (
size_t i = 0;
i < events_count; ++
i) {
2787 pointer_data.
Clear();
2811 if (device_kind == 0) {
2839 packet->SetPointerData(
i, pointer_data);
2841 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2845 ->DispatchPointerDataPacket(std::move(packet))
2848 "Could not dispatch pointer events to the "
2849 "running Flutter application.");
2854 switch (event_kind) {
2867 switch (event_kind) {
2888 const uint8_t*
data,
2918 return release_result;
2930 if (event ==
nullptr) {
2948 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2950 struct MessageData {
2955 MessageData* message_data =
2961 packet->data().size(),
2963 auto message_data = std::unique_ptr<MessageData>(
2964 reinterpret_cast<MessageData*>(user_data));
2965 if (message_data->callback == nullptr) {
2968 bool handled =
false;
2970 handled = *
data != 0;
2972 message_data->callback(handled, message_data->user_data);
2984 if (flutter_message ==
nullptr) {
2993 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
2996 if (message_size != 0 && message_data ==
nullptr) {
2999 "Message size was non-zero but the message data was nullptr.");
3003 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
3006 if (response_handle && response_handle->
message) {
3007 response = response_handle->
message->response();
3010 std::unique_ptr<flutter::PlatformMessage>
message;
3011 if (message_size == 0) {
3012 message = std::make_unique<flutter::PlatformMessage>(
3013 flutter_message->
channel, response);
3015 message = std::make_unique<flutter::PlatformMessage>(
3021 ->SendPlatformMessage(std::move(
message))
3024 "Could not send a message to the running "
3025 "Flutter application.");
3037 if (data_callback ==
nullptr || response_out ==
nullptr) {
3043 [
user_data, data_callback](
const uint8_t*
data,
size_t size) {
3049 .GetPlatformTaskRunner();
3053 handle->message = std::make_unique<flutter::PlatformMessage>(
3057 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
3058 std::move(platform_task_runner), response_callback));
3059 *response_out = handle;
3070 if (response ==
nullptr) {
3081 const uint8_t*
data,
3082 size_t data_length) {
3083 if (data_length != 0 &&
data ==
nullptr) {
3086 "Data size was non zero but the pointer to the data was null.");
3089 auto response = handle->
message->response();
3092 if (data_length == 0) {
3093 response->CompleteEmpty();
3095 response->Complete(std::make_unique<fml::DataMapping>(
3096 std::vector<uint8_t>({
data,
data + data_length})));
3112 int64_t texture_identifier) {
3117 if (texture_identifier == 0) {
3119 "Texture identifier was invalid.");
3122 texture_identifier)) {
3124 "Could not register the specified texture.");
3131 int64_t texture_identifier) {
3136 if (texture_identifier == 0) {
3138 "Texture identifier was invalid.");
3142 texture_identifier)) {
3144 "Could not un-register the specified texture.");
3152 int64_t texture_identifier) {
3156 if (texture_identifier == 0) {
3160 ->MarkTextureFrameAvailable(texture_identifier)) {
3163 "Could not mark the texture frame as being available.");
3177 "Could not update semantics state.");
3189 ->SetAccessibilityFeatures(flags)) {
3191 "Could not update accessibility features.");
3200 const uint8_t*
data,
3201 size_t data_length) {
3208 .data_length = data_length};
3224 "Could not dispatch semantics action.");
3232 uint64_t frame_start_time_nanos,
3233 uint64_t frame_target_time_nanos) {
3247 baton, start_time, target_time)) {
3250 "Could not notify the running engine instance of a Vsync event.");
3262 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
3265 ->ReloadSystemFonts()) {
3267 "Could not reload system fonts.");
3297 "Render thread callback was null.");
3303 ->PostRenderThreadTask(task)
3306 "Could not post the render thread task.");
3321 reinterpret_cast<intptr_t
>(task->
runner))) {
3330 "Could not run the specified task.");
3335 const rapidjson::Document& document,
3336 const std::string& channel_name) {
3337 if (channel_name.empty()) {
3341 rapidjson::StringBuffer buffer;
3342 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3344 if (!document.Accept(writer)) {
3348 const char*
message = buffer.GetString();
3350 if (
message ==
nullptr || buffer.GetSize() == 0) {
3354 auto platform_message = std::make_unique<flutter::PlatformMessage>(
3355 channel_name.c_str(),
3362 ->SendPlatformMessage(std::move(platform_message));
3368 size_t locales_count) {
3373 if (locales_count == 0) {
3377 if (locales ==
nullptr) {
3381 rapidjson::Document document;
3382 auto& allocator = document.GetAllocator();
3384 document.SetObject();
3385 document.AddMember(
"method",
"setLocale", allocator);
3387 rapidjson::Value
args(rapidjson::kArrayType);
3388 args.Reserve(locales_count * 4, allocator);
3389 for (
size_t i = 0;
i < locales_count; ++
i) {
3391 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3392 if (language_code_str ==
nullptr || ::strlen(language_code_str) == 0) {
3395 "Language code is required but not present in FlutterLocale.");
3398 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3399 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3400 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3402 rapidjson::Value language_code, country_code, script_code, variant_code;
3404 language_code.SetString(language_code_str, allocator);
3405 country_code.SetString(country_code_str ? country_code_str :
"", allocator);
3406 script_code.SetString(script_code_str ? script_code_str :
"", allocator);
3407 variant_code.SetString(variant_code_str ? variant_code_str :
"", allocator);
3410 args.PushBack(language_code, allocator);
3411 args.PushBack(country_code, allocator);
3412 args.PushBack(script_code, allocator);
3413 args.PushBack(variant_code, allocator);
3415 document.AddMember(
"args",
args, allocator);
3420 "Could not send message to update locale of "
3421 "a running Flutter application.");
3440 if (port == ILLEGAL_PORT) {
3442 "Attempted to post to an illegal port.");
3445 if (
object ==
nullptr) {
3447 "Invalid Dart object to post.");
3450 Dart_CObject dart_object = {};
3453 switch (object->
type) {
3455 dart_object.type = Dart_CObject_kNull;
3458 dart_object.type = Dart_CObject_kBool;
3459 dart_object.value.as_bool =
object->bool_value;
3462 dart_object.type = Dart_CObject_kInt32;
3463 dart_object.value.as_int32 =
object->int32_value;
3466 dart_object.type = Dart_CObject_kInt64;
3467 dart_object.value.as_int64 =
object->int64_value;
3470 dart_object.type = Dart_CObject_kDouble;
3471 dart_object.value.as_double =
object->double_value;
3476 "kFlutterEngineDartObjectTypeString must be "
3477 "a null terminated string but was null.");
3479 dart_object.type = Dart_CObject_kString;
3480 dart_object.value.as_string =
const_cast<char*
>(
object->string_value);
3484 if (buffer ==
nullptr) {
3486 "kFlutterEngineDartObjectTypeBuffer must "
3487 "specify a buffer but found nullptr.");
3498 dart_object.type = Dart_CObject_kTypedData;
3499 dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
3500 dart_object.value.as_typed_data.length = buffer_size;
3501 dart_object.value.as_typed_data.values = buffer;
3503 struct ExternalTypedDataPeer {
3507 auto peer =
new ExternalTypedDataPeer();
3522 dart_object.type = Dart_CObject_kExternalTypedData;
3523 dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
3524 dart_object.value.as_external_typed_data.length = buffer_size;
3525 dart_object.value.as_external_typed_data.data = buffer;
3526 dart_object.value.as_external_typed_data.peer = peer;
3527 dart_object.value.as_external_typed_data.callback =
3528 +[](
void* unused_isolate_callback_data,
void* peer) {
3529 auto typed_peer =
reinterpret_cast<ExternalTypedDataPeer*
>(peer);
3530 typed_peer->trampoline(typed_peer->user_data);
3538 "Invalid FlutterEngineDartObjectType type specified.");
3541 if (!Dart_PostCObject(port, &dart_object)) {
3543 "Could not post the object to the Dart VM.");
3548 typed_data_finalizer.
Release();
3559 engine->GetShell().NotifyLowMemoryWarning();
3561 rapidjson::Document document;
3562 auto& allocator = document.GetAllocator();
3564 document.SetObject();
3565 document.AddMember(
"type",
"memoryPressure", allocator);
3571 "Could not dispatch the low memory notification message.");
3584 "Invalid native thread callback.");
3588 ->PostTaskOnEngineManagedNativeThreads(
3594 "Internal error while attempting to post "
3595 "tasks to all threads.");
3600 size_t display_count) {
3601 std::set<FlutterEngineDisplayId> display_ids;
3602 for (
size_t i = 0;
i < display_count;
i++) {
3603 if (
displays[
i].single_display && display_count != 1) {
3606 display_ids.insert(
displays[
i].display_id);
3609 return display_ids.size() == display_count;
3617 size_t display_count) {
3618 if (raw_engine ==
nullptr) {
3622 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3625 "Invalid FlutterEngineDisplay configuration specified.");
3630 switch (update_type) {
3632 std::vector<std::unique_ptr<flutter::Display>>
displays;
3633 const auto* display = embedder_displays;
3634 for (
size_t i = 0;
i < display_count;
i++) {
3635 displays.push_back(std::make_unique<flutter::Display>(
3642 reinterpret_cast<const uint8_t*
>(display) + display->struct_size);
3650 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3663 "Could not schedule frame.");
3676 "Next frame callback was null.");
3685 if (!weak_platform_view) {
3687 "Platform view unavailable.");
3690 weak_platform_view->SetNextFrameCallback(
3701#define SET_PROC(member, function) \
3702 if (STRUCT_HAS_MEMBER(table, member)) { \
3703 table->member = &function; \
3717 SET_PROC(PlatformMessageCreateResponseHandle,
3719 SET_PROC(PlatformMessageReleaseResponseHandle,
3721 SET_PROC(SendPlatformMessageResponse,
3725 SET_PROC(MarkExternalTextureFrameAvailable,
3728 SET_PROC(UpdateAccessibilityFeatures,
3744 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
G_BEGIN_DECLS GBytes * message
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
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)