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.";
1623 if (
SAFE_ACCESS(flutter_metrics, has_constraints,
false)) {
1643 return "Window metrics are invalid. Width and height must be within the "
1644 "specified constraints.";
1649 SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1651 SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1653 SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1655 SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1659 return "Device pixel ratio was invalid. It must be greater than zero.";
1666 return "Physical view insets are invalid. They must be non-negative.";
1673 return "Physical view insets are invalid. They cannot be greater than "
1674 "physical height or width.";
1681 std::unique_ptr<flutter::PlatformMessage>
message;
1687 ::Dart_UnloadELF(elf);
1707 "AOT data can only be created in AOT mode.");
1708 }
else if (!source) {
1710 }
else if (!data_out) {
1714 switch (source->
type) {
1718 "Invalid ELF path specified.");
1721 auto aot_data = std::make_unique<_FlutterEngineAOTData>();
1722 const char*
error =
nullptr;
1727 Dart_LoadedElf* loaded_elf =
nullptr;
1729 Dart_LoadedElf* loaded_elf = Dart_LoadELF(
1733 &aot_data->vm_snapshot_data,
1734 &aot_data->vm_snapshot_instrs,
1735 &aot_data->vm_isolate_data,
1736 &aot_data->vm_isolate_instrs
1740 if (loaded_elf ==
nullptr) {
1744 aot_data->loaded_elf.reset(loaded_elf);
1746 *data_out = aot_data.release();
1753 "Invalid FlutterEngineAOTDataSourceType type specified.");
1771 auto make_mapping_callback = [](
const char* path,
bool executable) {
1772 return [path, executable]() {
1784 reinterpret_cast<const char*
>(
args->vm_snapshot_data),
false);
1787 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1789 reinterpret_cast<const char*
>(
args->vm_snapshot_instructions),
true);
1794 reinterpret_cast<const char*
>(
args->isolate_snapshot_data),
false);
1797 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1799 reinterpret_cast<const char*
>(
args->isolate_snapshot_instructions),
1803#if !OS_FUCHSIA && (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
1817 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
1818 return [mapping, size]() {
1819 return std::make_unique<fml::NonOwnedMapping>(mapping, size);
1825 make_mapping_callback(
args->aot_data->vm_snapshot_data, 0);
1828 make_mapping_callback(
args->aot_data->vm_snapshot_instrs, 0);
1831 make_mapping_callback(
args->aot_data->vm_isolate_data, 0);
1834 make_mapping_callback(
args->aot_data->vm_isolate_instrs, 0);
1842 if (
SAFE_ACCESS(
args, vm_snapshot_instructions,
nullptr) !=
nullptr) {
1844 args->vm_snapshot_instructions,
1850 make_mapping_callback(
args->isolate_snapshot_data,
1854 if (
SAFE_ACCESS(
args, isolate_snapshot_instructions,
nullptr) !=
nullptr) {
1856 args->isolate_snapshot_instructions,
1868 update_semantics_custom_action_callback,
1870 return [update_semantics_node_callback,
1871 update_semantics_custom_action_callback,
user_data](
1878 if (update_semantics_node_callback !=
nullptr) {
1884 if (update_semantics_custom_action_callback !=
nullptr) {
1886 update_semantics_custom_action_callback(&update_ptr->
custom_actions[
i],
1893 if (update_semantics_node_callback !=
nullptr) {
1898 update_semantics_node_callback(&batch_end_sentinel,
user_data);
1901 if (update_semantics_custom_action_callback !=
nullptr) {
1906 update_semantics_custom_action_callback(&batch_end_sentinel,
user_data);
1917 return [update_semantics_callback,
user_data](
1922 update_semantics_callback(update.get(),
user_data);
1932 return [update_semantics_callback,
user_data](
1937 update_semantics_callback(update.get(),
user_data);
1952 if (
SAFE_ACCESS(
args, update_semantics_callback2,
nullptr) !=
nullptr) {
1959 if (
SAFE_ACCESS(
args, update_semantics_callback,
nullptr) !=
nullptr) {
1968 if (
SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr) {
1969 update_semantics_node_callback =
args->update_semantics_node_callback;
1973 update_semantics_custom_action_callback =
nullptr;
1974 if (
SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
1976 update_semantics_custom_action_callback =
1977 args->update_semantics_custom_action_callback;
1980 if (update_semantics_node_callback !=
nullptr ||
1981 update_semantics_custom_action_callback !=
nullptr) {
1983 update_semantics_node_callback, update_semantics_custom_action_callback,
2017 "Flutter embedder version mismatch. There has been a breaking change. "
2018 "Please consult the changelog and update the embedder.");
2021 if (engine_out ==
nullptr) {
2023 "The engine out parameter was missing.");
2026 if (
args ==
nullptr) {
2028 "The Flutter project arguments were missing.");
2034 "The assets path in the Flutter project arguments was missing.");
2039 <<
"FlutterProjectArgs.main_path is deprecated and should be set null.";
2043 FML_LOG(WARNING) <<
"FlutterProjectArgs.packages_path is deprecated and "
2044 "should be set null.";
2049 "The renderer configuration was invalid.");
2052 std::string icu_data_path;
2059 std::string persistent_cache_path =
2086 "Multiple AOT sources specified. Embedders should provide either "
2087 "*_snapshot_* buffers or aot_data, not both.");
2110 "Not running in AOT mode but could not resolve the kernel binary.");
2115 if (
SAFE_ACCESS(
args, root_isolate_create_callback,
nullptr) !=
nullptr) {
2127 const std::string& tag,
2136 std::cout << tag <<
": ";
2138 std::cout <<
message << std::endl;
2146 bool has_update_semantics_2_callback =
2148 bool has_update_semantics_callback =
2150 bool has_legacy_update_semantics_callback =
2151 SAFE_ACCESS(
args, update_semantics_node_callback,
nullptr) !=
nullptr ||
2152 SAFE_ACCESS(
args, update_semantics_custom_action_callback,
nullptr) !=
2155 int semantic_callback_count = (has_update_semantics_2_callback ? 1 : 0) +
2156 (has_update_semantics_callback ? 1 : 0) +
2157 (has_legacy_update_semantics_callback ? 1 : 0);
2159 if (semantic_callback_count > 1) {
2162 "Multiple semantics update callbacks provided. "
2163 "Embedders should provide either `update_semantics_callback2`, "
2164 "`update_semantics_callback`, or both "
2165 "`update_semantics_node_callback` and "
2166 "`update_semantics_custom_action_callback`.");
2170 update_semantics_callback =
2174 platform_message_response_callback =
nullptr;
2175 if (
SAFE_ACCESS(
args, platform_message_callback,
nullptr) !=
nullptr) {
2176 platform_message_response_callback =
2177 [ptr =
args->platform_message_callback,
2187 handle->message = std::move(
message);
2188 return ptr(&incoming_message,
user_data);
2194 vsync_callback = [ptr =
args->vsync_callback,
user_data](intptr_t baton) {
2200 compute_platform_resolved_locale_callback =
nullptr;
2201 if (
SAFE_ACCESS(
args, compute_platform_resolved_locale_callback,
nullptr) !=
2203 compute_platform_resolved_locale_callback =
2204 [ptr =
args->compute_platform_resolved_locale_callback](
2205 const std::vector<std::string>& supported_locales_data) {
2206 const size_t number_of_strings_per_locale = 3;
2207 size_t locale_count =
2208 supported_locales_data.size() / number_of_strings_per_locale;
2209 std::vector<FlutterLocale> supported_locales;
2210 std::vector<const FlutterLocale*> supported_locales_ptr;
2211 for (
size_t i = 0;
i < locale_count; ++
i) {
2212 supported_locales.push_back(
2215 supported_locales_data[
i * number_of_strings_per_locale +
2219 supported_locales_data[
i * number_of_strings_per_locale +
2223 supported_locales_data[
i * number_of_strings_per_locale +
2226 .variant_code =
nullptr});
2227 supported_locales_ptr.push_back(&supported_locales[
i]);
2231 ptr(supported_locales_ptr.data(), locale_count);
2233 std::unique_ptr<std::vector<std::string>> out =
2234 std::make_unique<std::vector<std::string>>();
2236 std::string language_code(
SAFE_ACCESS(result, language_code,
""));
2237 if (language_code !=
"") {
2238 out->push_back(language_code);
2239 out->emplace_back(
SAFE_ACCESS(result, country_code,
""));
2240 out->emplace_back(
SAFE_ACCESS(result, script_code,
""));
2248 on_pre_engine_restart_callback =
nullptr;
2249 if (
SAFE_ACCESS(
args, on_pre_engine_restart_callback,
nullptr) !=
nullptr) {
2250 on_pre_engine_restart_callback = [ptr =
2251 args->on_pre_engine_restart_callback,
2258 channel_update_callback = [ptr =
args->channel_update_callback,
user_data](
2259 const std::string&
name,
bool listening) {
2267 view_focus_change_request_callback =
nullptr;
2270 view_focus_change_request_callback =
2271 [ptr =
args->view_focus_change_request_callback,
2286 if (!external_view_embedder_result.ok()) {
2287 FML_LOG(ERROR) << external_view_embedder_result.status().message();
2289 "Compositor arguments were invalid.");
2294 update_semantics_callback,
2295 platform_message_response_callback,
2297 compute_platform_resolved_locale_callback,
2298 on_pre_engine_restart_callback,
2299 channel_update_callback,
2300 view_focus_change_request_callback,
2304 config,
user_data, platform_dispatch_table,
2305 std::move(external_view_embedder_result.value()),
2308 if (!on_create_platform_view) {
2311 "Could not infer platform view creation callback.");
2316 return std::make_unique<flutter::Rasterizer>(shell);
2320 std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
2321 external_texture_resolver = std::make_unique<ExternalTextureResolver>();
2323#ifdef SHELL_ENABLE_GL
2325 external_texture_callback;
2328 if (
SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
2329 nullptr) !=
nullptr) {
2330 external_texture_callback =
2332 int64_t texture_identifier,
size_t width,
2333 size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
2334 std::unique_ptr<FlutterOpenGLTexture>
texture =
2335 std::make_unique<FlutterOpenGLTexture>();
2341 external_texture_resolver =
2342 std::make_unique<ExternalTextureResolver>(external_texture_callback);
2346#ifdef SHELL_ENABLE_METAL
2348 external_texture_metal_callback;
2351 if (
SAFE_ACCESS(metal_config, external_texture_frame_callback,
nullptr)) {
2352 external_texture_metal_callback =
2354 int64_t texture_identifier,
size_t width,
2355 size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
2356 std::unique_ptr<FlutterMetalExternalTexture>
texture =
2357 std::make_unique<FlutterMetalExternalTexture>();
2364 external_texture_resolver = std::make_unique<ExternalTextureResolver>(
2365 external_texture_metal_callback);
2369 auto custom_task_runners =
SAFE_ACCESS(
args, custom_task_runners,
nullptr);
2370 auto thread_config_callback = [&custom_task_runners](
2373 if (!custom_task_runners || !custom_task_runners->thread_priority_setter) {
2377 switch (config.priority) {
2391 custom_task_runners->thread_priority_setter(priority);
2395 custom_task_runners, thread_config_callback);
2397 if (!thread_host || !thread_host->IsValid()) {
2399 "Could not set up or infer thread configuration "
2400 "to run the Flutter engine on.");
2403 auto task_runners = thread_host->GetTaskRunners();
2405 if (!task_runners.IsValid()) {
2407 "Task runner configuration was invalid.");
2411 bool has_ui_thread_message_loop =
2412 task_runners.GetUITaskRunner()->GetTaskQueueId().is_valid();
2418 if (has_ui_thread_message_loop) {
2425 if (has_ui_thread_message_loop) {
2430 auto run_configuration =
2434 auto dart_entrypoint = std::string{
args->custom_dart_entrypoint};
2435 if (!dart_entrypoint.empty()) {
2436 run_configuration.SetEntrypoint(std::move(dart_entrypoint));
2443 "Could not determine Dart entrypoint arguments "
2444 "as dart_entrypoint_argc "
2445 "was set, but dart_entrypoint_argv was null.");
2447 std::vector<std::string> arguments(
args->dart_entrypoint_argc);
2448 for (
int i = 0;
i <
args->dart_entrypoint_argc; ++
i) {
2449 arguments[
i] = std::string{
args->dart_entrypoint_argv[
i]};
2451 run_configuration.SetEntrypointArgs(std::move(arguments));
2455 run_configuration.SetEngineId(
args->engine_id);
2458 if (!run_configuration.IsValid()) {
2461 "Could not infer the Flutter project to run from given arguments.");
2465 auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
2466 std::move(thread_host),
2467 std::move(task_runners),
2468 std::move(settings),
2469 std::move(run_configuration),
2470 on_create_platform_view,
2471 on_create_rasterizer,
2472 std::move(external_texture_resolver)
2477 embedder_engine.release());
2491 if (embedder_engine->IsValid()) {
2496 if (!embedder_engine->LaunchShell()) {
2498 "Could not launch the engine using supplied "
2499 "initialization arguments.");
2503 if (!embedder_engine->NotifyCreated()) {
2505 "Could not create platform view components.");
2509 if (!embedder_engine->RunRootIsolate()) {
2512 "Could not run the root isolate of the Flutter application using the "
2513 "project arguments specified.");
2528 "Add view info handle was invalid.");
2535 "Add view info was invalid. The implicit view cannot be added.");
2541 "Add view info was invalid. The info and "
2542 "window metric view IDs must match.");
2550 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2553 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2557 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2561 if (!embedder_engine->IsValid()) {
2570 result.
added = added;
2572 c_callback(&result);
2575 embedder_engine->GetShell().GetPlatformView()->AddView(
view_id, metrics,
2589 "Remove view info handle was invalid.");
2595 "Remove view info was invalid. The implicit view cannot be removed.");
2604 if (!embedder_engine->IsValid()) {
2615 c_callback(&result);
2618 embedder_engine->GetShell().GetPlatformView()->RemoveView(info->
view_id,
2631 "View focus event must not be null.");
2635 if (!embedder_engine->IsValid()) {
2641 "The event struct has invalid size.");
2649 embedder_engine->GetShell().GetPlatformView()->SendViewFocusEvent(
2664 embedder_engine->CollectShell();
2665 embedder_engine->CollectThreadHost();
2676 delete embedder_engine;
2683 if (
engine ==
nullptr || flutter_metrics ==
nullptr) {
2689 std::variant<flutter::ViewportMetrics, std::string> metrics_or_error =
2691 if (
const std::string*
error = std::get_if<std::string>(&metrics_or_error)) {
2695 auto metrics = std::get<flutter::ViewportMetrics>(metrics_or_error);
2701 "Viewport metrics were invalid.");
2736 switch (device_kind) {
2792 size_t events_count) {
2797 if (pointers ==
nullptr || events_count == 0) {
2801 auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
2805 for (
size_t i = 0;
i < events_count; ++
i) {
2807 pointer_data.
Clear();
2831 if (device_kind == 0) {
2859 packet->SetPointerData(
i, pointer_data);
2861 reinterpret_cast<const uint8_t*
>(current) + current->
struct_size);
2865 ->DispatchPointerDataPacket(std::move(packet))
2868 "Could not dispatch pointer events to the "
2869 "running Flutter application.");
2874 switch (event_kind) {
2887 switch (event_kind) {
2908 const uint8_t*
data,
2938 return release_result;
2950 if (event ==
nullptr) {
2968 auto packet = std::make_unique<flutter::KeyDataPacket>(key_data,
character);
2970 struct MessageData {
2975 MessageData* message_data =
2981 packet->data().size(),
2983 auto message_data = std::unique_ptr<MessageData>(
2984 reinterpret_cast<MessageData*>(user_data));
2985 if (message_data->callback == nullptr) {
2988 bool handled =
false;
2990 handled = *
data != 0;
2992 message_data->callback(handled, message_data->user_data);
3004 if (flutter_message ==
nullptr) {
3013 size_t message_size =
SAFE_ACCESS(flutter_message, message_size, 0);
3016 if (message_size != 0 && message_data ==
nullptr) {
3019 "Message size was non-zero but the message data was nullptr.");
3023 SAFE_ACCESS(flutter_message, response_handle,
nullptr);
3026 if (response_handle && response_handle->
message) {
3027 response = response_handle->
message->response();
3030 std::unique_ptr<flutter::PlatformMessage>
message;
3031 if (message_size == 0) {
3032 message = std::make_unique<flutter::PlatformMessage>(
3033 flutter_message->
channel, response);
3035 message = std::make_unique<flutter::PlatformMessage>(
3041 ->SendPlatformMessage(std::move(
message))
3044 "Could not send a message to the running "
3045 "Flutter application.");
3057 if (data_callback ==
nullptr || response_out ==
nullptr) {
3063 [
user_data, data_callback](
const uint8_t*
data,
size_t size) {
3069 .GetPlatformTaskRunner();
3073 handle->message = std::make_unique<flutter::PlatformMessage>(
3077 fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
3078 std::move(platform_task_runner), response_callback));
3079 *response_out = handle;
3090 if (response ==
nullptr) {
3101 const uint8_t*
data,
3102 size_t data_length) {
3103 if (data_length != 0 &&
data ==
nullptr) {
3106 "Data size was non zero but the pointer to the data was null.");
3109 auto response = handle->
message->response();
3112 if (data_length == 0) {
3113 response->CompleteEmpty();
3115 response->Complete(std::make_unique<fml::DataMapping>(
3116 std::vector<uint8_t>({
data,
data + data_length})));
3132 int64_t texture_identifier) {
3137 if (texture_identifier == 0) {
3139 "Texture identifier was invalid.");
3142 texture_identifier)) {
3144 "Could not register the specified texture.");
3151 int64_t texture_identifier) {
3156 if (texture_identifier == 0) {
3158 "Texture identifier was invalid.");
3162 texture_identifier)) {
3164 "Could not un-register the specified texture.");
3172 int64_t texture_identifier) {
3176 if (texture_identifier == 0) {
3180 ->MarkTextureFrameAvailable(texture_identifier)) {
3183 "Could not mark the texture frame as being available.");
3197 "Could not update semantics state.");
3209 ->SetAccessibilityFeatures(flags)) {
3211 "Could not update accessibility features.");
3220 const uint8_t*
data,
3221 size_t data_length) {
3228 .data_length = data_length};
3244 "Could not dispatch semantics action.");
3252 uint64_t frame_start_time_nanos,
3253 uint64_t frame_target_time_nanos) {
3267 baton, start_time, target_time)) {
3270 "Could not notify the running engine instance of a Vsync event.");
3282 TRACE_EVENT0(
"flutter",
"FlutterEngineReloadSystemFonts");
3285 ->ReloadSystemFonts()) {
3287 "Could not reload system fonts.");
3317 "Render thread callback was null.");
3323 ->PostRenderThreadTask(task)
3326 "Could not post the render thread task.");
3341 reinterpret_cast<intptr_t
>(task->
runner))) {
3350 "Could not run the specified task.");
3355 const rapidjson::Document& document,
3356 const std::string& channel_name) {
3357 if (channel_name.empty()) {
3361 rapidjson::StringBuffer buffer;
3362 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3364 if (!document.Accept(writer)) {
3368 const char*
message = buffer.GetString();
3370 if (
message ==
nullptr || buffer.GetSize() == 0) {
3374 auto platform_message = std::make_unique<flutter::PlatformMessage>(
3375 channel_name.c_str(),
3382 ->SendPlatformMessage(std::move(platform_message));
3388 size_t locales_count) {
3393 if (locales_count == 0) {
3397 if (locales ==
nullptr) {
3401 rapidjson::Document document;
3402 auto&
allocator = document.GetAllocator();
3404 document.SetObject();
3405 document.AddMember(
"method",
"setLocale",
allocator);
3407 rapidjson::Value
args(rapidjson::kArrayType);
3409 for (
size_t i = 0;
i < locales_count; ++
i) {
3411 const char* language_code_str =
SAFE_ACCESS(locale, language_code,
nullptr);
3412 if (language_code_str ==
nullptr || ::strlen(language_code_str) == 0) {
3415 "Language code is required but not present in FlutterLocale.");
3418 const char* country_code_str =
SAFE_ACCESS(locale, country_code,
"");
3419 const char* script_code_str =
SAFE_ACCESS(locale, script_code,
"");
3420 const char* variant_code_str =
SAFE_ACCESS(locale, variant_code,
"");
3422 rapidjson::Value language_code, country_code, script_code, variant_code;
3424 language_code.SetString(language_code_str,
allocator);
3425 country_code.SetString(country_code_str ? country_code_str :
"",
allocator);
3426 script_code.SetString(script_code_str ? script_code_str :
"",
allocator);
3427 variant_code.SetString(variant_code_str ? variant_code_str :
"",
allocator);
3440 "Could not send message to update locale of "
3441 "a running Flutter application.");
3460 if (port == ILLEGAL_PORT) {
3462 "Attempted to post to an illegal port.");
3465 if (
object ==
nullptr) {
3467 "Invalid Dart object to post.");
3470 Dart_CObject dart_object = {};
3473 switch (object->
type) {
3475 dart_object.type = Dart_CObject_kNull;
3478 dart_object.type = Dart_CObject_kBool;
3479 dart_object.value.as_bool =
object->bool_value;
3482 dart_object.type = Dart_CObject_kInt32;
3483 dart_object.value.as_int32 =
object->int32_value;
3486 dart_object.type = Dart_CObject_kInt64;
3487 dart_object.value.as_int64 =
object->int64_value;
3490 dart_object.type = Dart_CObject_kDouble;
3491 dart_object.value.as_double =
object->double_value;
3496 "kFlutterEngineDartObjectTypeString must be "
3497 "a null terminated string but was null.");
3499 dart_object.type = Dart_CObject_kString;
3500 dart_object.value.as_string =
const_cast<char*
>(
object->string_value);
3504 if (buffer ==
nullptr) {
3506 "kFlutterEngineDartObjectTypeBuffer must "
3507 "specify a buffer but found nullptr.");
3518 dart_object.type = Dart_CObject_kTypedData;
3519 dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
3520 dart_object.value.as_typed_data.length = buffer_size;
3521 dart_object.value.as_typed_data.values = buffer;
3523 struct ExternalTypedDataPeer {
3527 auto peer =
new ExternalTypedDataPeer();
3542 dart_object.type = Dart_CObject_kExternalTypedData;
3543 dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
3544 dart_object.value.as_external_typed_data.length = buffer_size;
3545 dart_object.value.as_external_typed_data.data = buffer;
3546 dart_object.value.as_external_typed_data.peer = peer;
3547 dart_object.value.as_external_typed_data.callback =
3548 +[](
void* unused_isolate_callback_data,
void* peer) {
3549 auto typed_peer =
reinterpret_cast<ExternalTypedDataPeer*
>(peer);
3550 typed_peer->trampoline(typed_peer->user_data);
3558 "Invalid FlutterEngineDartObjectType type specified.");
3561 if (!Dart_PostCObject(port, &dart_object)) {
3563 "Could not post the object to the Dart VM.");
3568 typed_data_finalizer.
Release();
3579 engine->GetShell().NotifyLowMemoryWarning();
3581 rapidjson::Document document;
3582 auto&
allocator = document.GetAllocator();
3584 document.SetObject();
3585 document.AddMember(
"type",
"memoryPressure",
allocator);
3591 "Could not dispatch the low memory notification message.");
3604 "Invalid native thread callback.");
3608 ->PostTaskOnEngineManagedNativeThreads(
3614 "Internal error while attempting to post "
3615 "tasks to all threads.");
3620 size_t display_count) {
3621 std::set<FlutterEngineDisplayId> display_ids;
3622 for (
size_t i = 0;
i < display_count;
i++) {
3623 if (
displays[
i].single_display && display_count != 1) {
3626 display_ids.insert(
displays[
i].display_id);
3629 return display_ids.size() == display_count;
3637 size_t display_count) {
3638 if (raw_engine ==
nullptr) {
3642 if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
3645 "Invalid FlutterEngineDisplay configuration specified.");
3650 switch (update_type) {
3652 std::vector<std::unique_ptr<flutter::Display>>
displays;
3653 const auto* display = embedder_displays;
3654 for (
size_t i = 0;
i < display_count;
i++) {
3655 displays.push_back(std::make_unique<flutter::Display>(
3662 reinterpret_cast<const uint8_t*
>(display) + display->struct_size);
3670 "Invalid FlutterEngineDisplaysUpdateType type specified.");
3683 "Could not schedule frame.");
3696 "Next frame callback was null.");
3705 if (!weak_platform_view) {
3707 "Platform view unavailable.");
3710 weak_platform_view->SetNextFrameCallback(
3721#define SET_PROC(member, function) \
3722 if (STRUCT_HAS_MEMBER(table, member)) { \
3723 table->member = &function; \
3737 SET_PROC(PlatformMessageCreateResponseHandle,
3739 SET_PROC(PlatformMessageReleaseResponseHandle,
3741 SET_PROC(SendPlatformMessageResponse,
3745 SET_PROC(MarkExternalTextureFrameAvailable,
3748 SET_PROC(UpdateAccessibilityFeatures,
3764 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)