6#define FML_USED_ON_EMBEDDER
36#include "third_party/skia/include/core/SkSurface.h"
47 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
51 ASSERT_TRUE(
engine.is_valid());
60 MustPreventEngineLaunchWhenRequiredCompositorArgsAreAbsent) {
61 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
65 builder.
GetCompositor().create_backing_store_callback =
nullptr;
66 builder.
GetCompositor().collect_backing_store_callback =
nullptr;
70 ASSERT_FALSE(
engine.is_valid());
79 auto& context = GetEmbedderContext<EmbedderTestContextSoftware>();
90 ASSERT_FALSE(
engine.is_valid());
98 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
109 context.GetCompositor().SetNextPresentCallback(
127 .rects = paint_region_rects,
131 .paint_region = &paint_region,
142 ASSERT_EQ(*
layers[0], layer);
157 ASSERT_EQ(*
layers[1], layer);
173 .rects = paint_region_rects,
177 .paint_region = &paint_region,
188 ASSERT_EQ(*
layers[2], layer);
194 context.AddNativeCallback(
197 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
206 event.pixel_ratio = 1.0;
209 ASSERT_TRUE(
engine.is_valid());
218 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
231 context.GetCompositor().SetNextPresentCallback(
249 .rects = paint_region_rects,
253 .paint_region = &paint_region,
264 ASSERT_EQ(*
layers[0], layer);
279 ASSERT_EQ(*
layers[1], layer);
295 .rects = paint_region_rects,
299 .paint_region = &paint_region,
310 ASSERT_EQ(*
layers[2], layer);
316 context.AddNativeCallback(
319 [&setup](Dart_NativeArguments
args) { setup.
CountDown(); }));
328 event.pixel_ratio = 1.0;
331 ASSERT_TRUE(
engine.is_valid());
351 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
364 context.GetCompositor().SetNextPresentCallback(
382 .rects = paint_region_rects,
386 .paint_region = &paint_region,
397 ASSERT_EQ(*
layers[0], layer);
403 context.AddNativeCallback(
406 [&setup](Dart_NativeArguments
args) { setup.
CountDown(); }));
415 event.pixel_ratio = 1.0;
418 ASSERT_TRUE(
engine.is_valid());
437 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
448 context.GetCompositor().SetNextPresentCallback(
466 .rects = paint_region_rects,
470 .paint_region = &paint_region,
481 ASSERT_EQ(*
layers[0], layer);
496 ASSERT_EQ(*
layers[1], layer);
512 .rects = paint_region_rects,
516 .paint_region = &paint_region,
527 ASSERT_EQ(*
layers[2], layer);
533 context.AddNativeCallback(
536 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
545 event.pixel_ratio = 1.0;
548 ASSERT_TRUE(
engine.is_valid());
558 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
569 context.GetCompositor().SetNextPresentCallback(
589 .rects = paint_region_rects,
593 .paint_region = &paint_region,
604 ASSERT_EQ(*
layers[0], layer);
619 ASSERT_EQ(*
layers[1], layer);
634 .rects = paint_region_rects,
638 .paint_region = &paint_region,
649 ASSERT_EQ(*
layers[2], layer);
655 context.AddNativeCallback(
658 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
667 event.pixel_ratio = 1.0;
670 ASSERT_TRUE(
engine.is_valid());
679 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
691 auto scene_image = context.GetNextSceneImage();
693 context.GetCompositor().SetNextPresentCallback(
711 .rects = paint_region_rects,
715 .paint_region = &paint_region,
726 ASSERT_EQ(*
layers[0], layer);
742 ASSERT_EQ(*
layers[1], layer);
758 .rects = paint_region_rects,
762 .paint_region = &paint_region,
773 ASSERT_EQ(*
layers[2], layer);
789 ASSERT_EQ(*
layers[3], layer);
805 .rects = paint_region_rects,
809 .paint_region = &paint_region,
820 ASSERT_EQ(*
layers[4], layer);
826 context.GetCompositor().SetPlatformViewRendererCallback(
828 GrDirectContext* context) -> sk_sp<SkImage> {
830 auto canvas =
surface->getCanvas();
837 paint.setColor(SK_ColorGREEN);
841 canvas->drawRect(rect, paint);
847 paint.setColor(SK_ColorMAGENTA);
851 canvas->drawRect(rect, paint);
857 <<
"Test was asked to composite an unknown platform view.";
860 return surface->makeImageSnapshot();
863 context.AddNativeCallback(
866 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
875 event.pixel_ratio = 1.0;
878 ASSERT_TRUE(
engine.is_valid());
885 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
893 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
901 auto platform_task_runner = CreateNewThread(
"test_platform_thread");
902 static std::mutex engine_mutex;
908 std::scoped_lock lock(engine_mutex);
919 context.GetCompositor().SetNextPresentCallback(
937 .rects = paint_region_rects,
941 .paint_region = &paint_region,
952 ASSERT_EQ(*
layers[0], layer);
966 .rects = paint_region_rects,
970 .paint_region = &paint_region,
981 ASSERT_EQ(*
layers[1], layer);
997 .rects = paint_region_rects,
1001 .paint_region = &paint_region,
1012 ASSERT_EQ(*
layers[2], layer);
1018 const auto task_runner_description =
1019 test_task_runner.GetFlutterTaskRunnerDescription();
1023 context.AddNativeCallback(
1026 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1028 platform_task_runner->PostTask([&]() {
1029 std::scoped_lock lock(engine_mutex);
1031 ASSERT_TRUE(
engine.is_valid());
1038 event.pixel_ratio = 1.0;
1041 ASSERT_TRUE(
engine.is_valid());
1048 platform_task_runner->PostTask([&]() {
1049 std::scoped_lock lock(engine_mutex);
1061 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1067 "can_composite_platform_views_with_root_layer_only");
1074 auto scene_image = context.GetNextSceneImage();
1076 context.GetCompositor().SetNextPresentCallback(
1094 .rects = paint_region_rects,
1098 .paint_region = &paint_region,
1109 ASSERT_EQ(*
layers[0], layer);
1115 context.AddNativeCallback(
1118 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1127 event.pixel_ratio = 1.0;
1130 ASSERT_TRUE(
engine.is_valid());
1143 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1149 "can_composite_platform_views_with_platform_layer_on_bottom");
1156 auto scene_image = context.GetNextSceneImage();
1158 context.GetCompositor().SetNextPresentCallback(
1176 .rects = paint_region_rects,
1180 .paint_region = &paint_region,
1191 ASSERT_EQ(*
layers[0], layer);
1207 ASSERT_EQ(*
layers[1], layer);
1213 context.GetCompositor().SetPlatformViewRendererCallback(
1215 GrDirectContext* context) -> sk_sp<SkImage> {
1217 auto canvas =
surface->getCanvas();
1224 paint.setColor(SK_ColorGREEN);
1225 paint.setAlpha(127);
1228 canvas->drawRect(rect, paint);
1234 <<
"Test was asked to composite an unknown platform view.";
1237 return surface->makeImageSnapshot();
1240 context.AddNativeCallback(
1243 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1252 event.pixel_ratio = 1.0;
1255 ASSERT_TRUE(
engine.is_valid());
1260 "compositor_with_platform_layer_on_bottom.png", scene_image));
1262 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 1u);
1270 CompositorMustBeAbleToRenderKnownSceneWithRootSurfaceTransformation) {
1271 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1284 const auto root_surface_transformation =
1288 context.SetRootSurfaceTransformation(root_surface_transformation);
1292 auto scene_image = context.GetNextSceneImage();
1294 context.GetCompositor().SetNextPresentCallback(
1312 .rects = paint_region_rects,
1316 .paint_region = &paint_region,
1327 ASSERT_EQ(*
layers[0], layer);
1343 ASSERT_EQ(*
layers[1], layer);
1359 .rects = paint_region_rects,
1363 .paint_region = &paint_region,
1374 ASSERT_EQ(*
layers[2], layer);
1390 ASSERT_EQ(*
layers[3], layer);
1406 .rects = paint_region_rects,
1410 .paint_region = &paint_region,
1421 ASSERT_EQ(*
layers[4], layer);
1427 context.GetCompositor().SetPlatformViewRendererCallback(
1429 GrDirectContext* context) -> sk_sp<SkImage> {
1431 auto canvas =
surface->getCanvas();
1438 paint.setColor(SK_ColorGREEN);
1439 paint.setAlpha(127);
1442 canvas->drawRect(rect, paint);
1448 paint.setColor(SK_ColorMAGENTA);
1449 paint.setAlpha(127);
1452 canvas->drawRect(rect, paint);
1458 <<
"Test was asked to composite an unknown platform view.";
1461 return surface->makeImageSnapshot();
1464 context.AddNativeCallback(
1467 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
1477 event.pixel_ratio = 1.0;
1480 ASSERT_TRUE(
engine.is_valid());
1489 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1496 auto rendered_scene = context.GetNextSceneImage();
1499 ASSERT_TRUE(
engine.is_valid());
1506 event.pixel_ratio = 1.0;
1515 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1517 const auto root_surface_transformation =
1521 context.SetRootSurfaceTransformation(root_surface_transformation);
1528 auto rendered_scene = context.GetNextSceneImage();
1531 ASSERT_TRUE(
engine.is_valid());
1540 event.pixel_ratio = 1.0;
1545 "scene_without_custom_compositor_with_xform.png", rendered_scene));
1550 auto& context = GetEmbedderContext(backend);
1555 auto rendered_scene = context.GetNextSceneImage();
1558 ASSERT_TRUE(
engine.is_valid());
1565 event.pixel_ratio = 1.0;
1574 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1576 const auto root_surface_transformation =
1580 context.SetRootSurfaceTransformation(root_surface_transformation);
1584 const auto surface_size =
DlISize(600, 800);
1589 auto rendered_scene = context.GetNextSceneImage();
1592 ASSERT_TRUE(
engine.is_valid());
1600 event.pixel_ratio = 1.0;
1609 auto& context = GetEmbedderContext(backend);
1617 auto rendered_scene = context.GetNextSceneImage();
1620 ASSERT_TRUE(
engine.is_valid());
1627 event.pixel_ratio = 1.0;
1636 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1641 const auto root_surface_transformation =
1645 context.SetRootSurfaceTransformation(root_surface_transformation);
1655 auto rendered_scene = context.GetNextSceneImage();
1658 ASSERT_TRUE(
engine.is_valid());
1666 event.pixel_ratio = 1.0;
1674 CanRenderGradientWithCompositorOnNonRootLayer) {
1676 auto& context = GetEmbedderContext(backend);
1684 context.GetCompositor().SetNextPresentCallback(
1701 .rects = paint_region_rects,
1705 .paint_region = &paint_region,
1716 ASSERT_EQ(*
layers[0], layer);
1732 ASSERT_EQ(*
layers[1], layer);
1747 .rects = paint_region_rects,
1751 .paint_region = &paint_region,
1762 ASSERT_EQ(*
layers[2], layer);
1766 context.GetCompositor().SetPlatformViewRendererCallback(
1768 GrDirectContext* context) -> sk_sp<SkImage> {
1770 auto canvas =
surface->getCanvas();
1782 <<
"Test was asked to composite an unknown platform view.";
1785 return surface->makeImageSnapshot();
1788 auto rendered_scene = context.GetNextSceneImage();
1791 ASSERT_TRUE(
engine.is_valid());
1798 event.pixel_ratio = 1.0;
1807 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1812 const auto root_surface_transformation =
1816 context.SetRootSurfaceTransformation(root_surface_transformation);
1826 context.GetCompositor().SetNextPresentCallback(
1844 .rects = paint_region_rects,
1848 .paint_region = &paint_region,
1859 ASSERT_EQ(*
layers[0], layer);
1875 ASSERT_EQ(*
layers[1], layer);
1891 .rects = paint_region_rects,
1895 .paint_region = &paint_region,
1906 ASSERT_EQ(*
layers[2], layer);
1910 context.GetCompositor().SetPlatformViewRendererCallback(
1912 GrDirectContext* context) -> sk_sp<SkImage> {
1914 auto canvas =
surface->getCanvas();
1926 <<
"Test was asked to composite an unknown platform view.";
1929 return surface->makeImageSnapshot();
1932 auto rendered_scene = context.GetNextSceneImage();
1935 ASSERT_TRUE(
engine.is_valid());
1943 event.pixel_ratio = 1.0;
1951 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
1957 const auto root_surface_transformation =
1961 const auto root_surface_rect =
1962 flutter_application_rect.TransformAndClipBounds(
1963 root_surface_transformation);
1965 ASSERT_FLOAT_EQ(root_surface_rect.GetWidth(), 600.0f);
1966 ASSERT_FLOAT_EQ(root_surface_rect.GetHeight(), 800.0f);
1969 context.SetRootSurfaceTransformation(root_surface_transformation);
1973 DlISize(root_surface_rect.GetWidth(), root_surface_rect.GetHeight()));
1984 context.GetCompositor().SetNextPresentCallback(
2002 const double unxformed_top_margin = 31.0;
2003 const double unxformed_bottom_margin = 37.0;
2006 unxformed_top_margin,
2008 600 - unxformed_top_margin - unxformed_bottom_margin
2015 const auto xformed_platform_view_rect =
2016 unxformed_platform_view_rect.TransformAndClipBounds(
2017 root_surface_transformation);
2021 ASSERT_EQ(xformed_platform_view_rect,
2030 xformed_platform_view_rect.GetY());
2032 xformed_platform_view_rect.GetHeight());
2034 ASSERT_EQ(*
layers[0], layer);
2048 event.width = flutter_application_rect.GetWidth();
2049 event.height = flutter_application_rect.GetHeight();
2050 event.pixel_ratio = 1.0;
2053 ASSERT_TRUE(
engine.is_valid());
2062 std::mutex engine_mutex;
2065 bool task_executed =
false;
2067 CreateNewThread(
"custom_render_thread"), [&](
FlutterTask task) {
2068 std::scoped_lock engine_lock(engine_mutex);
2071 task_executed =
true;
2075 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2080 &render_task_runner.GetFlutterTaskRunnerDescription());
2083 std::scoped_lock lock(engine_mutex);
2089 ASSERT_TRUE(
engine.is_valid());
2095 event.pixel_ratio = 1.0;
2099 ASSERT_TRUE(task_executed);
2103 std::scoped_lock engine_lock(engine_mutex);
2113 CanCreateEmbedderWithCustomRenderTaskRunnerTheSameAsPlatformTaskRunner) {
2117 auto platform_task_runner = CreateNewThread(
"platform_thread");
2119 static std::mutex engine_mutex;
2122 bool task_executed =
false;
2125 std::scoped_lock engine_lock(engine_mutex);
2128 task_executed =
true;
2133 platform_task_runner->PostTask([&]() {
2135 auto& context = GetEmbedderContext(backend);
2140 &common_task_runner.GetFlutterTaskRunnerDescription());
2142 &common_task_runner.GetFlutterTaskRunnerDescription());
2145 std::scoped_lock lock(engine_mutex);
2151 ASSERT_TRUE(
engine.is_valid());
2157 event.pixel_ratio = 1.0;
2168 platform_task_runner->PostTask([&]() {
2169 ASSERT_TRUE(task_executed);
2173 std::scoped_lock engine_lock(engine_mutex);
2179 shutdown_latch.
Wait();
2182 std::scoped_lock engine_lock(engine_mutex);
2184 ASSERT_FALSE(
engine.is_valid());
2189 CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurface) {
2191 auto& context = GetEmbedderContext(backend);
2202 auto rendered_scene = context.GetNextSceneImage();
2204 context.GetCompositor().SetNextPresentCallback(
2221 .rects = paint_region_rects,
2225 .paint_region = &paint_region,
2236 ASSERT_EQ(*
layers[0], layer);
2252 ASSERT_EQ(*
layers[1], layer);
2267 .rects = paint_region_rects,
2271 .paint_region = &paint_region,
2282 ASSERT_EQ(*
layers[2], layer);
2293 event.width = 400 * 2.0;
2294 event.height = 300 * 2.0;
2295 event.pixel_ratio = 2.0;
2298 ASSERT_TRUE(
engine.is_valid());
2308 CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurfaceWithRootSurfaceXformation) {
2309 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2319 const auto root_surface_transformation =
2323 context.SetRootSurfaceTransformation(root_surface_transformation);
2325 auto rendered_scene = context.GetNextSceneImage();
2328 context.GetCompositor().SetNextPresentCallback(
2346 .rects = paint_region_rects,
2350 .paint_region = &paint_region,
2361 ASSERT_EQ(*
layers[0], layer);
2377 ASSERT_EQ(*
layers[1], layer);
2393 .rects = paint_region_rects,
2397 .paint_region = &paint_region,
2408 ASSERT_EQ(*
layers[2], layer);
2419 event.width = 400 * 2.0;
2420 event.height = 300 * 2.0;
2421 event.pixel_ratio = 2.0;
2424 ASSERT_TRUE(
engine.is_valid());
2432 PushingMutlipleFramesSetsUpNewRecordingCanvasWithCustomCompositor) {
2433 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2443 const auto root_surface_transformation =
2447 context.SetRootSurfaceTransformation(root_surface_transformation);
2456 event.pixel_ratio = 1.0;
2459 ASSERT_TRUE(
engine.is_valid());
2461 constexpr size_t frames_expected = 10;
2463 std::atomic_size_t frames_seen = 0;
2464 context.AddNativeCallback(
"SignalNativeTest",
2471 ASSERT_GE(frames_seen, frames_expected);
2477 PushingMutlipleFramesSetsUpNewRecordingCanvasWithoutCustomCompositor) {
2478 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2484 const auto root_surface_transformation =
2488 context.SetRootSurfaceTransformation(root_surface_transformation);
2497 event.pixel_ratio = 1.0;
2500 ASSERT_TRUE(
engine.is_valid());
2502 constexpr size_t frames_expected = 10;
2504 std::atomic_size_t frames_seen = 0;
2505 context.AddNativeCallback(
"SignalNativeTest",
2512 ASSERT_GE(frames_seen, frames_expected);
2519 auto& context = GetEmbedderContext(backend);
2529 context.GetCompositor().SetNextPresentCallback(
2546 .rects = paint_region_rects,
2550 .paint_region = &paint_region,
2561 ASSERT_EQ(*
layers[0], layer);
2578 ASSERT_EQ(*
layers[1], layer);
2583 switch (mutation.
type) {
2587 SkRect::MakeLTRB(10.0, 10.0, 800.0 - 10.0,
2598 mutation.
opacity = 128.0 / 255.0;
2602 <<
"There should be no transformation in the test.";
2619 event.pixel_ratio = 1.0;
2622 ASSERT_TRUE(
engine.is_valid());
2628 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2639 context.GetCompositor().SetNextPresentCallback(
2657 .rects = paint_region_rects,
2661 .paint_region = &paint_region,
2672 ASSERT_EQ(*
layers[0], layer);
2689 ASSERT_EQ(*
layers[1], layer);
2694 switch (mutation.
type) {
2698 SkRect::MakeLTRB(5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0),
2708 mutation.
opacity = 128.0 / 255.0;
2730 event.pixel_ratio = 2.0;
2733 ASSERT_TRUE(
engine.is_valid());
2739 PlatformViewMutatorsAreValidWithPixelRatioAndRootSurfaceTransformation) {
2740 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2750 static const auto root_surface_transformation =
2754 context.SetRootSurfaceTransformation(root_surface_transformation);
2757 context.GetCompositor().SetNextPresentCallback(
2775 .rects = paint_region_rects,
2779 .paint_region = &paint_region,
2790 ASSERT_EQ(*
layers[0], layer);
2807 ASSERT_EQ(*
layers[1], layer);
2812 switch (mutation.
type) {
2816 SkRect::MakeLTRB(5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0),
2826 mutation.
opacity = 128.0 / 255.0;
2849 event.pixel_ratio = 2.0;
2852 ASSERT_TRUE(
engine.is_valid());
2858 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2865 context.AddNativeCallback(
2871 ASSERT_TRUE(
engine.is_valid());
2877 event.pixel_ratio = 1.0;
2884 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2893 context.AddNativeCallback(
2899 ASSERT_TRUE(
engine.is_valid());
2905 event.pixel_ratio = 1.0;
2914 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2923 const auto root_surface_transformation =
2928 context.SetRootSurfaceTransformation(root_surface_transformation);
2932 auto scene_image = context.GetNextSceneImage();
2934 ASSERT_TRUE(
engine.is_valid());
2939 event.height = 1024;
2940 event.pixel_ratio = 1.0;
2948 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
2957 const auto root_surface_transformation =
2961 context.SetRootSurfaceTransformation(root_surface_transformation);
2964 context.GetCompositor().SetNextPresentCallback(
2981 ASSERT_EQ(*
layers[0], layer);
2983 bool clip_assertions_checked =
false;
2986 const auto total_xformation =
2992 [&](
const auto& mutation) {
2997 const auto rect_to_compare =
3002 ASSERT_TRUE(total_xformation.IsAligned2D());
3006 clip_assertions_checked =
true;
3009 ASSERT_TRUE(clip_assertions_checked);
3016 ASSERT_TRUE(
engine.is_valid());
3022 event.pixel_ratio = 1.0;
3030 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3039 const auto root_surface_transformation =
3043 context.SetRootSurfaceTransformation(root_surface_transformation);
3046 context.GetCompositor().SetNextPresentCallback(
3063 ASSERT_EQ(*
layers[0], layer);
3067 ASSERT_EQ(mutations[0]->
type,
3070 root_surface_transformation);
3072 ASSERT_EQ(mutations[1]->
type,
3074 ASSERT_EQ(
SkRectMake(mutations[1]->clip_rect),
3075 SkRect::MakeLTRB(0.0, 0.0, 1024.0, 600.0));
3077 ASSERT_EQ(mutations[2]->
type,
3082 ASSERT_EQ(mutations[3]->
type,
3084 ASSERT_EQ(
SkRectMake(mutations[3]->clip_rect),
3085 SkRect::MakeLTRB(0.0, 0.0, 512.0, 600.0));
3087 ASSERT_EQ(mutations[4]->
type,
3092 ASSERT_EQ(mutations[5]->
type,
3094 ASSERT_EQ(
SkRectMake(mutations[5]->clip_rect),
3095 SkRect::MakeLTRB(0.0, 0.0, 1024.0, 600.0));
3102 ASSERT_TRUE(
engine.is_valid());
3108 event.pixel_ratio = 1.0;
3116 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3126 context.AddNativeCallback(
"SignalNativeCount",
3129 Dart_GetNativeArgument(
args, 0));
3133 ASSERT_TRUE(
engine.is_valid());
3137 using Trampoline = std::function<void(Dart_Handle
message)>;
3138 Trampoline trampoline;
3140 context.AddNativeCallback(
"SendObjectToNativeCode",
3143 auto trampoline_copy = trampoline;
3144 trampoline =
nullptr;
3145 trampoline_copy(Dart_GetNativeArgument(
args, 0));
3152 trampoline = [&](Dart_Handle handle) {
3153 ASSERT_TRUE(Dart_IsNull(handle));
3165 object.bool_value =
true;
3166 trampoline = [&](Dart_Handle handle) {
3179 object.int32_value = 1988;
3180 trampoline = [&](Dart_Handle handle) {
3193 object.int64_value = 1988;
3194 trampoline = [&](Dart_Handle handle) {
3207 object.double_value = 1988.0;
3208 trampoline = [&](Dart_Handle handle) {
3219 const char*
message =
"Hello. My name is Inigo Montoya.";
3222 object.string_value =
message;
3223 trampoline = [&](Dart_Handle handle) {
3244 buffer.user_data =
nullptr;
3245 buffer.buffer_collect_callback =
nullptr;
3251 object.buffer_value = &
buffer;
3252 trampoline = [&](Dart_Handle handle) {
3254 Dart_ListLength(handle, &
length);
3280 buffer.user_data = &buffer_released_latch;
3289 object.buffer_value = &
buffer;
3290 trampoline = [&](Dart_Handle handle) {
3292 Dart_ListLength(handle, &
length);
3311 buffer_released_latch.
Wait();
3315 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3326 context.GetCompositor().SetNextPresentCallback(
3339 event.pixel_ratio = 1.0;
3342 ASSERT_TRUE(
engine.is_valid());
3345 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3349 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3360 context.GetCompositor().SetNextPresentCallback(
3377 ASSERT_EQ(*
layers[0], layer);
3392 ASSERT_EQ(*
layers[1], layer);
3403 event.pixel_ratio = 1.0;
3406 ASSERT_TRUE(
engine.is_valid());
3409 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3413 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3424 context.AddNativeCallback(
"SignalNativeTest",
3429 context.GetCompositor().SetNextPresentCallback(
3437 ASSERT_TRUE(
engine.is_valid());
3443 event.pixel_ratio = 1.0;
3448 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 10u);
3449 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(), 10u);
3450 ASSERT_EQ(context.GetCompositor().GetBackingStoresCollectedCount(), 0u);
3453 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3454 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(), 10u);
3455 ASSERT_EQ(context.GetCompositor().GetBackingStoresCollectedCount(), 10u);
3459 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3470 context.AddNativeCallback(
"SignalNativeTest",
3475 size_t frame_count = 0;
3476 std::vector<void*> first_frame_backing_store_user_data;
3477 context.GetCompositor().SetPresentCallback(
3482 if (first_frame_backing_store_user_data.empty()) {
3485 first_frame_backing_store_user_data.push_back(
3486 layers[
i]->backing_store->user_data);
3492 ASSERT_EQ(first_frame_backing_store_user_data.size(), 10u);
3495 std::vector<void*> backing_store_user_data;
3498 backing_store_user_data.push_back(
3499 layers[
i]->backing_store->user_data);
3503 ASSERT_EQ(backing_store_user_data.size(), 10u);
3505 ASSERT_EQ(first_frame_backing_store_user_data, backing_store_user_data);
3507 if (frame_count == 20) {
3515 ASSERT_TRUE(
engine.is_valid());
3521 event.pixel_ratio = 1.0;
3529 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3530 const auto root_surface_transformation =
3533 context.SetRootSurfaceTransformation(root_surface_transformation);
3545 event.pixel_ratio = 1.0;
3548 ASSERT_TRUE(
engine.is_valid());
3552 context.AddNativeCallback(
"SignalNativeTest",
3559 ASSERT_EQ(frame_info.
size.
width, event.height);
3560 ASSERT_EQ(frame_info.
size.
height, event.width);
3569 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3570 context.SetOpenGLFBOCallBack();
3576 ASSERT_FALSE(
engine.is_valid());
3580 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3581 context.SetOpenGLPresentCallBack();
3587 ASSERT_FALSE(
engine.is_valid());
3591 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3592 context.GetRendererConfig().open_gl.populate_existing_damage =
nullptr;
3598 ASSERT_TRUE(
engine.is_valid());
3602 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3603 context.GetRendererConfig().open_gl.populate_existing_damage =
3604 [](
void* context,
const intptr_t
id,
3607 ->GLPopulateExistingDamage(
id, existing_damage);
3613 ASSERT_TRUE(
engine.is_valid());
3617 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3618 context.GetRendererConfig().open_gl.fbo_callback =
3619 [](
void* context) -> uint32_t {
return 0; };
3620 context.GetRendererConfig().open_gl.fbo_with_frame_info_callback =
nullptr;
3621 context.GetRendererConfig().open_gl.populate_existing_damage =
3622 [](
void* context,
const intptr_t
id,
3625 ->GLPopulateExistingDamage(
id, existing_damage);
3631 ASSERT_TRUE(
engine.is_valid());
3635 MustNotRunWhenPopulateExistingDamageButNoOtherFBOCallback) {
3636 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3637 context.GetRendererConfig().open_gl.fbo_callback =
nullptr;
3638 context.GetRendererConfig().open_gl.fbo_with_frame_info_callback =
nullptr;
3639 context.GetRendererConfig().open_gl.populate_existing_damage =
3640 [](
void* context,
const intptr_t
id,
3643 ->GLPopulateExistingDamage(
id, existing_damage);
3649 ASSERT_FALSE(
engine.is_valid());
3653 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3654 const auto root_surface_transformation =
3657 context.SetRootSurfaceTransformation(root_surface_transformation);
3670 event.pixel_ratio = 1.0;
3673 ASSERT_TRUE(
engine.is_valid());
3677 context.AddNativeCallback(
"SignalNativeTest",
3682 const uint32_t window_fbo_id = context.GetWindowFBOId();
3683 context.SetGLPresentCallback(
3685 ASSERT_EQ(present_info.
fbo_id, window_fbo_id);
3694 PresentInfoReceivesFullDamageWhenExistingDamageIsWholeScreen) {
3695 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3696 context.GetRendererConfig().open_gl.populate_existing_damage =
3697 [](
void* context,
const intptr_t
id,
3700 ->GLPopulateExistingDamage(
id, existing_damage);
3705 const size_t num_rects = 1;
3707 static FlutterRect existing_damage_rects[num_rects] = {
3709 existing_damage_ptr->
num_rects = num_rects;
3710 existing_damage_ptr->
damage = existing_damage_rects;
3717 ASSERT_TRUE(
engine.is_valid());
3723 const size_t num_rects = 1;
3744 event.pixel_ratio = 1.0;
3753 const size_t num_rects = 1;
3775 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3776 context.GetRendererConfig().open_gl.populate_existing_damage =
3777 [](
void* context,
const intptr_t
id,
3780 ->GLPopulateExistingDamage(
id, existing_damage);
3785 const size_t num_rects = 1;
3787 static FlutterRect existing_damage_rects[num_rects] = {
3789 existing_damage_ptr->
num_rects = num_rects;
3790 existing_damage_ptr->
damage = existing_damage_rects;
3797 ASSERT_TRUE(
engine.is_valid());
3803 const size_t num_rects = 1;
3824 event.pixel_ratio = 1.0;
3832 const size_t num_rects = 1;
3854 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3855 context.GetRendererConfig().open_gl.populate_existing_damage =
3856 [](
void* context,
const intptr_t
id,
3859 ->GLPopulateExistingDamage(
id, existing_damage);
3863 [&](
const intptr_t
id,
FlutterDamage* existing_damage_ptr) {
3864 const size_t num_rects = 1;
3866 static FlutterRect existing_damage_rects[num_rects] = {
3868 existing_damage_ptr->
num_rects = num_rects;
3869 existing_damage_ptr->
damage = existing_damage_rects;
3876 ASSERT_TRUE(
engine.is_valid());
3882 const size_t num_rects = 1;
3903 event.pixel_ratio = 1.0;
3912 const size_t num_rects = 1;
3934 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3935 context.GetRendererConfig().open_gl.populate_existing_damage =
3936 [](
void* context,
const intptr_t
id,
3939 ->GLPopulateExistingDamage(
id, existing_damage);
3946 ASSERT_TRUE(
engine.is_valid());
3948 const uint32_t window_fbo_id = context.GetWindowFBOId();
3949 context.SetGLPopulateExistingDamageCallback(
3950 [window_fbo_id = window_fbo_id](intptr_t
id,
3952 ASSERT_EQ(
id, window_fbo_id);
3954 existing_damage->
damage =
nullptr;
3962 event.pixel_ratio = 1.0;
3968 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
3969 context.GetRendererConfig().open_gl.populate_existing_damage =
3970 [](
void* context,
const intptr_t
id,
3973 ->GLPopulateExistingDamage(
id, existing_damage);
3985 ASSERT_TRUE(
engine.is_valid());
3987 context.AddNativeCallback(
"SignalNativeTest",
3992 const uint32_t window_fbo_id = context.GetWindowFBOId();
3993 context.SetGLPopulateExistingDamageCallback(
3994 [window_fbo_id = window_fbo_id](intptr_t
id,
3996 ASSERT_NE(
id, window_fbo_id);
3998 existing_damage->
damage =
nullptr;
4006 event.pixel_ratio = 1.0;
4012 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4019 context.AddNativeCallback(
4025 ASSERT_TRUE(
engine.is_valid());
4032 std::vector<FlutterEngineDisplay>
displays = {display};
4046 event.pixel_ratio = 1.0;
4054 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4061 context.AddNativeCallback(
4067 ASSERT_TRUE(
engine.is_valid());
4074 std::vector<FlutterEngineDisplay>
displays = {display};
4088 event.pixel_ratio = 1.0;
4096 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4103 context.AddNativeCallback(
4109 ASSERT_TRUE(
engine.is_valid());
4123 std::vector<FlutterEngineDisplay>
displays = {display_1, display_2};
4137 event.pixel_ratio = 1.0;
4145 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4152 context.AddNativeCallback(
4158 ASSERT_TRUE(
engine.is_valid());
4172 std::vector<FlutterEngineDisplay>
displays = {display_1, display_2};
4183 event.pixel_ratio = 1.0;
4191 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4198 context.AddNativeCallback(
4204 ASSERT_TRUE(
engine.is_valid());
4218 std::vector<FlutterEngineDisplay>
displays = {display_1, display_2};
4229 event.pixel_ratio = 1.0;
4237 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4246 const unsigned num_frames = 8;
4247 const unsigned num_engine_layers = 10;
4248 const unsigned num_backing_stores = num_frames * num_engine_layers;
4251 context.AddNativeCallback(
"SignalNativeTest",
4256 context.GetCompositor().SetPresentCallback(
4265 ASSERT_TRUE(
engine.is_valid());
4271 event.pixel_ratio = 1.0;
4277 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(),
4278 num_backing_stores);
4281 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
4285 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4291 auto max_size = context.GetCompositor().GetGrContext()->maxRenderTargetSize();
4293 context.AddIsolateCreateCallback([&]() {
4294 Dart_Handle snapshot_large_scene = Dart_GetField(
4300 context.AddNativeCallback(
4302 auto get_arg = [&
args](
int index) {
4303 Dart_Handle dart_image = Dart_GetNativeArgument(
args, index);
4304 Dart_Handle internal_image =
4311 ASSERT_EQ(big_image->
width(), max_size);
4312 ASSERT_EQ(big_image->
height(), max_size / 2);
4316 small_image->
image()->skia_image()));
4322 ASSERT_TRUE(
engine.is_valid());
4328 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4338 context.AddNativeCallback(
"SignalNativeCount",
4341 Dart_GetNativeArgument(
args, 0));
4345 ASSERT_TRUE(
engine.is_valid());
4349 using Trampoline = std::function<void(Dart_Handle
message)>;
4350 Trampoline trampoline;
4352 context.AddNativeCallback(
"SendObjectToNativeCode",
4355 auto trampoline_copy = trampoline;
4356 trampoline =
nullptr;
4357 trampoline_copy(Dart_GetNativeArgument(
args, 0));
4364 object.bool_value =
true;
4365 trampoline = [&](Dart_Handle handle) {
4378 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4386 class TestCollectOnce {
4390 ASSERT_FALSE(collected_);
4395 bool collected_ =
false;
4406 backing_store_out->user_data =
nullptr;
4408 backing_store_out->open_gl.texture.target = 0;
4409 backing_store_out->open_gl.texture.name = 0;
4410 backing_store_out->open_gl.texture.format = 0;
4411 static TestCollectOnce collect_once_user_data;
4412 collect_once_user_data = {};
4413 backing_store_out->open_gl.texture.user_data = &collect_once_user_data;
4414 backing_store_out->open_gl.texture.destruction_callback =
4416 reinterpret_cast<TestCollectOnce*
>(
user_data)->Collect();
4421 context.AddNativeCallback(
4424 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
4433 event.pixel_ratio = 1.0;
4436 ASSERT_TRUE(
engine.is_valid());
4441 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4449 class TestCollectOnce {
4453 ASSERT_FALSE(collected_);
4458 bool collected_ =
false;
4469 backing_store_out->user_data =
nullptr;
4471 backing_store_out->open_gl.framebuffer.target = 0;
4472 backing_store_out->open_gl.framebuffer.name = 0;
4473 static TestCollectOnce collect_once_user_data;
4474 collect_once_user_data = {};
4475 backing_store_out->open_gl.framebuffer.user_data =
4476 &collect_once_user_data;
4477 backing_store_out->open_gl.framebuffer.destruction_callback =
4479 reinterpret_cast<TestCollectOnce*
>(
user_data)->Collect();
4484 context.AddNativeCallback(
4487 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
4496 event.pixel_ratio = 1.0;
4499 ASSERT_TRUE(
engine.is_valid());
4504 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4520 backing_store_out->user_data =
user_data;
4522 backing_store_out->open_gl.surface.user_data =
user_data;
4524 backing_store_out->open_gl.surface.format = 0;
4525 backing_store_out->open_gl.surface.make_current_callback = [](
void*,
4527 ADD_FAILURE() <<
"make_current_callback method should not be called";
4530 backing_store_out->open_gl.surface.clear_current_callback = [](
void*,
4532 ADD_FAILURE() <<
"clear_current_callback method should not be called";
4535 backing_store_out->open_gl.surface.destruction_callback =
4537 FAIL() <<
"destruction_callback method should not be called";
4543 context.AddNativeCallback(
4546 [&latch](Dart_NativeArguments
args) { latch.
Signal(); }));
4555 event.pixel_ratio = 1.0;
4558 ASSERT_TRUE(
engine.is_valid());
4564 auto context =
surface.GetGrContext();
4566 typedef void (*glGenTexturesProc)(uint32_t n, uint32_t* textures);
4567 typedef void (*glFinishProc)();
4569 glGenTexturesProc glGenTextures;
4570 glFinishProc glFinish;
4572 glGenTextures =
reinterpret_cast<glGenTexturesProc
>(
4573 surface.GetProcAddress(
"glGenTextures"));
4574 glFinish =
reinterpret_cast<glFinishProc
>(
surface.GetProcAddress(
"glFinish"));
4577 glGenTextures(1, &
name);
4579 bool resolve_called =
false;
4582 [&](int64_t,
size_t,
size_t) {
4583 resolve_called =
true;
4584 auto res = std::make_unique<FlutterOpenGLTexture>();
4585 res->target = GL_TEXTURE_2D;
4587 res->format = GL_RGBA8;
4588 res->user_data =
nullptr;
4589 res->destruction_callback = [](
void*) {};
4590 res->width = res->height = 100;
4595 auto skia_surface =
surface.GetOnscreenSurface();
4601 .gr_context = context.get(),
4606 EXPECT_TRUE(resolve_called);
4607 resolve_called =
false;
4612 EXPECT_FALSE(resolve_called);
4618 EXPECT_TRUE(resolve_called);
4625 PresentInfoReceivesFullScreenDamageWhenPopulateExistingDamageIsNotProvided) {
4626 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4627 context.GetRendererConfig().open_gl.populate_existing_damage =
nullptr;
4633 ASSERT_TRUE(
engine.is_valid());
4639 const size_t num_rects = 1;
4660 event.pixel_ratio = 1.0;
4669 const size_t num_rects = 1;
4691 PresentInfoReceivesJoinedDamageWhenExistingDamageContainsMultipleRects) {
4692 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4693 context.GetRendererConfig().open_gl.populate_existing_damage =
4694 [](
void* context,
const intptr_t
id,
4697 ->GLPopulateExistingDamage(
id, existing_damage);
4702 const size_t num_rects = 2;
4704 static FlutterRect existing_damage_rects[num_rects] = {
4708 existing_damage_ptr->
num_rects = num_rects;
4709 existing_damage_ptr->
damage = existing_damage_rects;
4716 ASSERT_TRUE(
engine.is_valid());
4722 const size_t num_rects = 1;
4743 event.pixel_ratio = 1.0;
4752 const size_t num_rects = 1;
4774 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4777 bool present_called =
false;
4778 context.SetGLPresentCallback(
4780 present_called =
true;
4790 auto rendered_scene = context.GetNextSceneImage();
4793 ASSERT_TRUE(
engine.is_valid());
4797 typedef void (*glGenFramebuffersProc)(GLsizei n, GLuint* ids);
4798 typedef void (*glBindFramebufferProc)(GLenum
target, GLuint framebuffer);
4799 auto glGenFramebuffers =
reinterpret_cast<glGenFramebuffersProc
>(
4800 context.GLGetProcAddress(
"glGenFramebuffers"));
4801 auto glBindFramebuffer =
reinterpret_cast<glBindFramebufferProc
>(
4802 context.GLGetProcAddress(
"glBindFramebuffer"));
4807 glGenFramebuffers(1, &fbo);
4808 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
4811 raster_event.
Wait();
4818 event.pixel_ratio = 1.0;
4824 "impeller_test.png"),
4829 ASSERT_FALSE(present_called);
4833 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4835 bool result =
false;
4837 context.AddNativeCallback(
"NotifyBoolValue",
4840 Dart_GetNativeArgument(
args, 0));
4853 ASSERT_TRUE(
engine.is_valid());
4856 ASSERT_TRUE(result);
4860 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4871 context.GetCompositor().SetNextPresentCallback(
4878 backing_store.
struct_size =
sizeof(backing_store);
4889 .rects = paint_region_rects,
4893 .paint_region = &paint_region,
4903 ASSERT_EQ(*
layers[0], layer);
4918 ASSERT_EQ(*
layers[1], layer);
4923 backing_store.
struct_size =
sizeof(backing_store);
4934 .rects = paint_region_rects,
4938 .paint_region = &paint_region,
4949 ASSERT_EQ(*
layers[2], layer);
4955 context.AddNativeCallback(
4958 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
4967 event.pixel_ratio = 1.0;
4970 ASSERT_TRUE(
engine.is_valid());
4976 auto& context = GetEmbedderContext<EmbedderTestContextGL>();
4988 auto scene_image = context.GetNextSceneImage();
4990 context.GetCompositor().SetNextPresentCallback(
5008 .rects = paint_region_rects,
5012 .paint_region = &paint_region,
5023 ASSERT_EQ(*
layers[0], layer);
5039 ASSERT_EQ(*
layers[1], layer);
5055 .rects = paint_region_rects,
5059 .paint_region = &paint_region,
5070 ASSERT_EQ(*
layers[2], layer);
5086 ASSERT_EQ(*
layers[3], layer);
5102 .rects = paint_region_rects,
5106 .paint_region = &paint_region,
5117 ASSERT_EQ(*
layers[4], layer);
5123 context.GetCompositor().SetPlatformViewRendererCallback(
5125 GrDirectContext* context) -> sk_sp<SkImage> {
5127 auto canvas =
surface->getCanvas();
5134 paint.setColor(SK_ColorGREEN);
5135 paint.setAlpha(127);
5138 canvas->drawRect(rect, paint);
5144 paint.setColor(SK_ColorMAGENTA);
5145 paint.setAlpha(127);
5148 canvas->drawRect(rect, paint);
5154 <<
"Test was asked to composite an unknown platform view.";
5157 return surface->makeImageSnapshot();
5160 context.AddNativeCallback(
5163 [&latch](Dart_NativeArguments
args) { latch.
CountDown(); }));
5172 event.pixel_ratio = 1.0;
5175 ASSERT_TRUE(
engine.is_valid());
5182 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
sk_sp< DlImage > image() const
Backend implementation of |DlCanvas| for |SkCanvas|.
std::function< std::unique_ptr< FlutterOpenGLTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
size_t GetCachedEntriesCount() const
fml::TaskRunnerAffineWeakPtr< Rasterizer > GetRasterizer() const
Rasterizers may only be accessed on the raster task runner.
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
double GetMainDisplayRefreshRate()
Queries the DisplayManager for the main display refresh rate.
fml::RefPtr< fml::TaskRunner > GetRasterTaskRunner() const
virtual void MarkNewFrameAvailable()=0
virtual void Paint(PaintContext &context, const DlRect &bounds, bool freeze, const DlImageSampling sampling)=0
void SetPlatformTaskRunner(const FlutterTaskRunnerDescription *runner)
void SetSurface(DlISize surface_size)
void SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt=kFlutterSoftwarePixelFormatNative32)
void SetDartEntrypoint(std::string entrypoint)
void AddCommandLineArgument(std::string arg)
void SetRenderTaskRunner(const FlutterTaskRunnerDescription *runner)
FlutterCompositor & GetCompositor()
UniqueEngine LaunchEngine() const
void SetCompositor(bool avoid_backing_store_cache=false, bool use_present_layers_callback=false)
UniqueEngine InitializeEngine() const
void SetGLPopulateExistingDamageCallback(GLPopulateExistingDamageCallback callback)
FlutterRendererConfig & GetRendererConfig()
A task runner that we expect the embedder to provide but whose implementation is a real FML task runn...
static TaskSourceGrade GetCurrentTaskSourceGrade()
virtual void PostTask(const fml::closure &task) override
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 FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
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_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...
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 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 FlutterEngineRunInitialized(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize....
@ kFlutterLayerContentTypePlatformView
Indicates that the contents of this layer are determined by the embedder.
@ kFlutterLayerContentTypeBackingStore
@ kFlutterPlatformViewMutationTypeClipRoundedRect
@ kFlutterPlatformViewMutationTypeClipRect
@ kFlutterPlatformViewMutationTypeTransformation
@ kFlutterPlatformViewMutationTypeOpacity
@ kFlutterEngineDartObjectTypeString
@ kFlutterEngineDartObjectTypeBool
@ kFlutterEngineDartObjectTypeDouble
@ kFlutterEngineDartObjectTypeInt32
@ kFlutterEngineDartObjectTypeBuffer
@ kFlutterEngineDartObjectTypeInt64
@ kFlutterEngineDartObjectTypeNull
@ kFlutterEngineDisplaysUpdateTypeStartup
int64_t FlutterEngineDartPort
@ kFlutterOpenGLTargetTypeFramebuffer
@ kFlutterOpenGLTargetTypeSurface
@ kFlutterOpenGLTargetTypeTexture
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
@ kFlutterBackingStoreTypeOpenGL
flutter::DlMatrix DlMatrixMake(const FlutterTransformation &xformation)
FlutterSize FlutterSizeMake(double width, double height)
FlutterRect FlutterRectMake(const SkRect &rect)
FlutterRect FlutterRectMakeLTRB(double l, double t, double r, double b)
FlutterPoint FlutterPointMake(double x, double y)
FlutterTransformation FlutterTransformationMake(const flutter::DlMatrix &matrix)
SkRect SkRectMake(const FlutterRect &rect)
flutter::EmbedderEngine * ToEmbedderEngine(const FlutterEngine &engine)
FlutterRoundedRect FlutterRoundedRectMake(const SkRRect &rect)
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS GBytes * message
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
TEST_F(DisplayListTest, Defaults)
sk_sp< SkSurface > CreateRenderSurface(const FlutterLayer &layer, GrDirectContext *context)
bool MemsetPatternSetOrCheck(uint8_t *buffer, size_t size, MemsetPatternOp op)
Depending on the operation, either scribbles a known pattern into the buffer or checks if that patter...
void FilterMutationsByType(const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
@ kMemsetPatternOpSetBuffer
void ConfigureBackingStore(FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
Configures per-backend properties for a given backing store.
INSTANTIATE_TEST_SUITE_P(EmbedderTestGlVk, EmbedderTestMultiBackend, ::testing::Values(EmbedderTestContextType::kOpenGLContext, EmbedderTestContextType::kVulkanContext))
TEST_P(DlGoldenTest, TextBlurMaskFilterRespectCTM)
std::string FixtureNameForBackend(EmbedderTestContextType backend, const std::string &name)
Prepends a prefix to the name which is unique to the test context type. This is useful for tests that...
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image)
EmbedderTestBackingStoreProducer::RenderTargetType GetRenderTargetFromBackend(EmbedderTestContextType backend, bool opengl_framebuffer)
Resolves a render target type for a given backend description. This is useful for tests that use Embe...
DlMatrix GetTotalMutationTransformationMatrix(const FlutterPlatformViewMutation **mutations, size_t count)
impeller::ISize32 DlISize
impeller::Degrees DlDegrees
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
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.
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStore).
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStorePresentInfo).
A structure to represent a damage region.
size_t num_rects
The number of rectangles within the damage region.
FlutterRect * damage
The actual damage region(s) in question.
FlutterEngineDartObjectType type
size_t struct_size
The size of this struct. Must be sizeof(FlutterEngineDisplay).
FlutterEngineDisplayId display_id
FlutterUIntSize size
The size of the surface that will be backed by the fbo.
FlutterLayerContentType type
const FlutterBackingStore * backing_store
FlutterBackingStorePresentInfo * backing_store_present_info
const FlutterPlatformView * platform_view
size_t struct_size
This size of this struct. Must be sizeof(FlutterLayer).
FlutterSize size
The size of the layer (in physical pixels).
FlutterOpenGLTargetType type
UIntFrameInfoCallback fbo_with_frame_info_callback
uint32_t fbo_id
Id of the fbo backing the surface that was presented.
FlutterDamage frame_damage
Damage representing the area that the compositor needs to render.
FlutterDamage buffer_damage
Damage used to set the buffer's damage region.
A structure to represent a rectangle.
A region represented by a collection of non-overlapping rectangles.
size_t struct_size
The size of this struct. Must be sizeof(FlutterRegion).
FlutterOpenGLRendererConfig open_gl
size_t row_bytes
The number of bytes in a single row of the allocation.
size_t height
The number of rows in the allocation.
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationZ(Radians r)
static constexpr Matrix MakeScale(const Vector3 &s)
static constexpr TRect MakeWH(Type width, Type height)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
#define CREATE_NATIVE_ENTRY(native_entry)