5#include "flutter/impeller/aiks/aiks_unittests.h"
15#include "flutter/testing/testing.h"
16#include "gtest/gtest.h"
39#include "third_party/imgui/imgui.h"
52 canvas.Translate(
Size{100, 100});
59 ASSERT_EQ(canvas.GetSaveCount(), 1u);
60 ASSERT_EQ(canvas.Restore(),
false);
62 canvas.Translate(
Size{100, 100});
64 ASSERT_EQ(canvas.GetSaveCount(), 2u);
67 ASSERT_TRUE(canvas.Restore());
68 ASSERT_EQ(canvas.GetSaveCount(), 1u);
81 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
87 auto image = std::make_shared<Image>(CreateTextureForFixture(
"kalimba.jpg"));
90 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
96 auto image = std::make_shared<Image>(CreateTextureForFixture(
"kalimba.jpg"));
100 paint.invert_colors =
true;
103 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
112 paint.invert_colors =
true;
115 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
124 paint.invert_colors =
true;
126 canvas.DrawPaint(
paint);
127 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
131bool GenerateMipmap(
const std::shared_ptr<Context>& context,
132 std::shared_ptr<Texture>
texture,
134 auto buffer = context->CreateCommandBuffer();
138 auto pass =
buffer->CreateBlitPass();
142 pass->GenerateMipmap(std::move(
texture), std::move(label));
144 pass->EncodeCommands(context->GetResourceAllocator());
145 return context->GetCommandQueue()->Submit({
buffer}).
ok();
148void CanRenderTiledTexture(
AiksTest* aiks_test,
150 Matrix local_matrix = {}) {
151 auto context = aiks_test->GetContext();
152 ASSERT_TRUE(context);
153 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
155 GenerateMipmap(context,
texture,
"table_mountain_nx");
157 canvas.Scale(aiks_test->GetContentScale());
158 canvas.Translate({100.0f, 100.0f, 0});
178 PathBuilder path_builder;
179 path_builder.AddCircle({150, 150}, 150);
180 path_builder.AddRoundedRect(
Rect::MakeLTRB(300, 300, 600, 600), 10);
182 canvas.DrawPath(path_builder.TakePath(),
paint);
187 PathBuilder path_builder;
188 path_builder.AddCircle({150, 450}, 150);
191 canvas.DrawPath(path_builder.TakePath(),
paint);
194 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
222 auto image = std::make_shared<Image>(CreateTextureForFixture(
"kalimba.jpg"));
227 source_rect = source_rect.Shift(
Point(image_half_size));
231 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
236 canvas.Scale(GetContentScale());
240 canvas.DrawPaint(
paint);
244 canvas.Translate({
x,
y});
248 canvas.DrawPaint(
paint);
254 canvas.DrawPaint(
paint);
260 canvas.DrawPaint(
paint);
266 canvas.DrawPaint(
paint);
272 canvas.DrawPaint(
paint);
281 std::vector<Color> gradient_colors = {
282 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
283 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
284 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
285 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
286 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
287 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
288 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
289 std::vector<Scalar> stops = {
298 auto texture = CreateTextureForFixture(
"airplane.jpg",
302 {500, 600}, 75, std::move(gradient_colors), std::move(stops),
311 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
323 canvas.SaveLayer(alpha);
325 canvas.DrawCircle({125, 125}, 125, red);
329 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
336 std::vector<Color>
colors = {
Color{0.9568, 0.2627, 0.2118, 1.0},
337 Color{0.1294, 0.5882, 0.9529, 1.0}};
338 std::vector<Scalar> stops = {
344 {0, 0}, {100, 100}, std::move(
colors), std::move(stops),
348 canvas.Translate({100, 100, 0});
353 canvas.Translate({100, 400, 0});
354 canvas.DrawCircle({100, 100}, 100,
paint);
356 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
362 paint.color =
Color{0.9568, 0.2627, 0.2118, 1.0};
364 paint.color =
Color{0.1294, 0.5882, 0.9529, 1.0};
370 canvas.DrawPaint(
paint);
379 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
392 canvas.DrawPaint(
paint);
401 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
411 std::make_shared<Image>(CreateTextureForFixture(
"kalimba.jpg"));
415 canvas.Translate({100, 200, 0});
416 canvas.Scale(
Vector2{0.5, 0.5});
433 canvas.SaveLayer(alpha);
442 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
451 canvas.DrawCircle({250, 250}, 125, red);
453 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
465 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
491 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
495 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
518 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
539 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
552 const std::string&
text,
553 const std::string_view& font_fixture,
558 Paint{.color = Color::Aqua().WithAlpha(0.25)});
561 canvas.DrawCircle(
options.position, 5.0,
562 Paint{.color = Color::Red().WithAlpha(0.25)});
565 auto c_font_fixture = std::string(font_fixture);
581 text_paint.color =
options.color;
582 text_paint.mask_blur_descriptor =
options.mask_blur_descriptor;
583 text_paint.stroke_width = 1;
586 canvas.DrawTextFrame(
frame,
options.position, text_paint);
592 const std::string&
text,
593 const std::string& font_fixture,
598 Paint{.color = Color::Aqua().WithAlpha(0.25)});
601 canvas.DrawCircle(
options.position, 5.0,
602 Paint{.color = Color::Red().WithAlpha(0.25)});
609 auto typeface_stb = std::make_shared<TypefaceSTB>(std::move(mapping));
612 typeface_stb, Font::Metrics{.point_size =
options.font_size},
text);
615 text_paint.color =
options.color;
616 canvas.DrawTextFrame(
frame,
options.position, text_paint);
622 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
624 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
625 "Roboto-Regular.ttf"));
626 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
631 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
633 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
634 "Roboto-Regular.ttf",
638 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
643 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
644 canvas.Scale({0.5, 0.5, 1});
646 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
647 "Roboto-Regular.ttf"));
648 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
653 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
654 canvas.Scale({2.625, 2.625, 1});
656 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
657 "Roboto-Regular.ttf"));
658 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
663 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
665 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
666 "Roboto-Regular.ttf"));
669 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
674 std::array<Scalar, 20> phase_offsets = {
675 7.82637e-06, 0.131538, 0.755605, 0.45865, 0.532767,
676 0.218959, 0.0470446, 0.678865, 0.679296, 0.934693,
677 0.383502, 0.519416, 0.830965, 0.0345721, 0.0534616,
678 0.5297, 0.671149, 0.00769819, 0.383416, 0.0668422};
681 static float phase_variation = 0.2;
682 static float speed = 0.5;
685 ImGuiWindowFlags_AlwaysAutoResize)) {
686 ImGui::SliderFloat(
"Font size", &
font_size, 5, 50);
687 ImGui::SliderFloat(
"Phase variation", &phase_variation, 0, 1);
688 ImGui::SliderFloat(
"Oscillation speed", &speed, 0, 2);
689 ImGui::SliderFloat(
"Oscillation magnitude", &
magnitude, 0, 300);
694 canvas.Scale(GetContentScale());
696 for (
size_t i = 0;
i < phase_offsets.size();
i++) {
699 std::sin((-phase_offsets[
i] *
k2Pi * phase_variation +
700 GetSecondsElapsed() * speed)),
705 "the quick brown fox jumped over "
707 "Roboto-Regular.ttf",
708 {.font_size =
font_size, .position = position})) {
712 return canvas.EndRecordingAsPicture();
715 ASSERT_TRUE(OpenPlaygroundHere(
callback));
720 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
723 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
724 "HomemadeApple.ttf"));
725 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
730 "Apple Color Emoji.ttc";
732 "NotoColorEmoji.ttf";
737 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
741 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
746 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
753 .sigma =
Sigma(4)}}));
754 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
759 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
764 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
769 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
771 canvas.Translate({100, 100});
772 canvas.Scale(
Vector2{0.5, 0.5});
777 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
778 "Roboto-Regular.ttf"));
783 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
784 "Roboto-Regular.ttf"));
786 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
791 canvas.Translate({200, 150});
795 ASSERT_NE(mapping,
nullptr);
808 {
Point(1, 2),
"789"},
809 {
Point(1, 3),
"456"},
810 {
Point(1, 4),
"123"},
811 {
Point(0, 6),
"0F0F0F0"}};
812 for (
auto& t :
text) {
817 ASSERT_NE(blob,
nullptr);
819 canvas.DrawTextFrame(
frame,
Point(), text_paint);
824 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
829 canvas.Scale(GetContentScale());
830 canvas.DrawPaint({.color =
Color(0.1, 0.1, 0.1, 1.0)});
832 canvas.Transform(
Matrix(0.25, -0.3, 0, -0.002,
837 GetContext(), canvas,
"the quick brown fox jumped over the lazy dog!.?",
838 "Roboto-Regular.ttf"));
840 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
845 canvas.Scale(
Vector2(0.2, 0.2));
847 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
852 canvas.Scale(
Vector2(0.2, 0.2));
854 canvas.DrawPaint({.color = Color::Color::OrangeRed().WithAlpha(0.5)});
855 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
860 EXPECT_EQ(
GetContext()->GetCapabilities()->GetDefaultColorFormat(),
866 GetContext()->GetCapabilities()->GetDefaultColorFormat();
877 canvas.Translate(
Vector3(100, 200));
879 canvas.GetCurrentTransform(),
887 canvas.GetCurrentTransform(),
895 canvas.GetCurrentTransform(),
901 canvas.Translate(
Vector3(100, 200));
903 canvas.GetCurrentTransform(),
913 canvas.Scale(GetContentScale());
915 const int color_count = 3;
923 canvas.DrawPaint(
paint);
929 canvas.DrawCircle({10, 10}, radius,
paint);
937 std::vector<Color> gradient_colors = {
938 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
939 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
940 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
941 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
942 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
943 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
944 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
945 std::vector<Scalar> stops = {
954 auto texture = CreateTextureForFixture(
"airplane.jpg",
958 {500, 600}, 75, std::move(gradient_colors), std::move(stops),
960 canvas.DrawCircle({500, 600}, 100,
paint);
965 canvas.DrawCircle({800, 300}, 100,
paint);
967 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
972 canvas.Scale(GetContentScale());
974 const int color_count = 3;
982 canvas.DrawPaint(
paint);
988 for (
int i = 0;
i < n;
i++) {
990 canvas.DrawCircle(center, r,
paint);
996 paint.stroke_width = 1;
997 draw(canvas, {10, 10}, 2, 2, 14);
998 paint.stroke_width = 5;
999 draw(canvas, {10, 10}, 35, 10, 56);
1001 std::vector<Color> gradient_colors = {
1002 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
1003 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
1004 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
1005 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
1006 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
1007 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
1008 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
1009 std::vector<Scalar> stops = {
1018 auto texture = CreateTextureForFixture(
"airplane.jpg",
1022 {500, 600}, 75, std::move(gradient_colors), std::move(stops),
1024 draw(canvas, {500, 600}, 5, 10, 10);
1029 draw(canvas, {800, 300}, 5, 10, 10);
1031 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1036 canvas.Scale(GetContentScale());
1038 const int color_count = 3;
1046 canvas.DrawPaint(
paint);
1049 int long_radius = 600;
1050 int short_radius = 600;
1051 while (long_radius > 0 && short_radius > 0) {
1053 canvas.DrawOval(
Rect::MakeXYWH(10 - long_radius, 10 - short_radius,
1054 long_radius * 2, short_radius * 2),
1056 canvas.DrawOval(
Rect::MakeXYWH(1000 - short_radius, 750 - long_radius,
1057 short_radius * 2, long_radius * 2),
1059 if (short_radius > 30) {
1068 std::vector<Color> gradient_colors = {
1069 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
1070 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
1071 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
1072 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
1073 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
1074 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
1075 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
1076 std::vector<Scalar> stops = {
1085 auto texture = CreateTextureForFixture(
"airplane.jpg",
1091 {300, 650}, 75, std::move(gradient_colors), std::move(stops),
1102 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1107 canvas.Scale(GetContentScale());
1109 const int color_count = 3;
1117 canvas.DrawPaint(
paint);
1120 for (
int i = 0;
i < 4;
i++) {
1121 for (
int j = 0; j < 4; j++) {
1132 std::vector<Color> gradient_colors = {
1133 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
1134 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
1135 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
1136 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
1137 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
1138 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
1139 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
1140 std::vector<Scalar> stops = {
1149 auto texture = CreateTextureForFixture(
"airplane.jpg",
1155 for (
int i = 1;
i <= 10;
i++) {
1158 550 +
i * 20, 550 + j * 20),
1163 {200, 650}, 75, std::move(gradient_colors), std::move(stops),
1172 for (
int i = 1;
i <= 10;
i++) {
1175 720 +
i * 20, 220 + j * 20),
1185 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1190 canvas.Scale(GetContentScale());
1201 for (
int i = 0;
i < 5;
i++) {
1205 radius, 60.0f - radius),
1211 for (
int i = 0;
i < 5;
i++) {
1214 canvas.DrawCircle({
x + 25,
y + 25}, radius,
paint);
1219 for (
int i = 0;
i < 5;
i++) {
1223 radius, 60.0f - radius),
1229 for (
int i = 0;
i < 5;
i++) {
1239 for (
int i = 0;
i < 5;
i++) {
1243 {radius, 5.0f},
paint);
1246 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1251 canvas.Scale(GetContentScale());
1253 const int color_count = 3;
1261 canvas.DrawPaint(
paint);
1263 auto draw_rrect_as_path = [&canvas](
const Rect&
rect,
const Size& radii,
1271 for (
int i = 0;
i < 4;
i++) {
1272 for (
int j = 0; j < 4; j++) {
1274 draw_rrect_as_path(
Rect::MakeXYWH(
i * 100 + 10, j * 100 + 20, 80, 80),
1283 std::vector<Color> gradient_colors = {
1284 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
1285 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
1286 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
1287 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
1288 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
1289 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
1290 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
1291 std::vector<Scalar> stops = {
1300 auto texture = CreateTextureForFixture(
"airplane.jpg",
1306 for (
int i = 1;
i <= 10;
i++) {
1309 550 +
i * 20, 550 + j * 20),
1314 {200, 650}, 75, std::move(gradient_colors), std::move(stops),
1323 for (
int i = 1;
i <= 10;
i++) {
1326 720 +
i * 20, 220 + j * 20),
1336 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1342 canvas.Scale(GetContentScale());
1347 auto current =
Point{25, 25};
1357 .stroke_width = 5.0f,
1360 canvas.SaveLayer(alpha,
bounds);
1371 return canvas.EndRecordingAsPicture();
1374 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1386 canvas.Translate({10, 10});
1387 canvas.SaveLayer({});
1394 canvas.Translate({10, 10});
1398 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1428 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1455 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1460 canvas.Scale(GetContentScale());
1461 canvas.Translate(
Vector2(100, 100));
1463 auto texture = std::make_shared<Image>(CreateTextureForFixture(
"boston.jpg"));
1465 canvas.SaveLayer(
paint);
1475 draw_image_layer(effect_paint);
1477 canvas.Translate(
Vector2(300, 300));
1479 draw_image_layer(effect_paint);
1481 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1484#if IMPELLER_ENABLE_3D
1489 ASSERT_NE(mapping,
nullptr);
1492 *mapping, *
GetContext()->GetResourceAllocator());
1493 ASSERT_NE(gltf_scene,
nullptr);
1502 ImGuiWindowFlags_AlwaysAutoResize)) {
1503 ImGui::SliderFloat(
"Distance", &
distance, 0, 4);
1504 ImGui::SliderFloat(
"Y", &y_pos, -3, 3);
1505 ImGui::SliderFloat(
"FOV", &fov, 1, 180);
1509 Scalar angle = GetSecondsElapsed();
1510 auto camera_position =
1513 paint.color_source = ColorSource::MakeScene(
1520 canvas.Scale(GetContentScale());
1521 canvas.DrawPaint(
paint);
1522 return canvas.EndRecordingAsPicture();
1525 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1534 ASSERT_FALSE(
paint.HasColorFilter());
1536 paint.color_filter =
1539 ASSERT_TRUE(
paint.HasColorFilter());
1545 ASSERT_TRUE(
paint.HasColorFilter());
1547 paint.mask_blur_descriptor = {};
1549 ASSERT_TRUE(
paint.HasColorFilter());
1551 paint.color_filter =
nullptr;
1553 ASSERT_FALSE(
paint.HasColorFilter());
1565 ASSERT_EQ(
picture.pass->GetClearColor(), expected);
1568 std::shared_ptr<Context> real_context =
GetContext();
1569 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1573 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1574 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1575 ASSERT_EQ(render_pass->GetCommands().size(), 0llu);
1581 ParentSaveLayerCreatesRenderPassWhenChildBackdropFilterIsPresent) {
1592 std::shared_ptr<Context> real_context =
GetContext();
1593 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1597 ASSERT_EQ(spy->render_passes_.size(),
1599 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1600 ASSERT_EQ(render_pass->GetCommands().size(), 0llu);
1613 std::shared_ptr<Context> real_context =
GetContext();
1614 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1618 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1619 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1620 ASSERT_EQ(render_pass->GetCommands().size(), 0llu);
1633 std::shared_ptr<Context> real_context =
GetContext();
1634 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1638 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1639 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1640 ASSERT_EQ(render_pass->GetCommands().size(), 2llu);
1645 canvas.Translate(
Vector3(150.0, 150.0, 0.0));
1647 canvas.Translate(
Vector3(-150.0, -150.0, 0.0));
1653 std::shared_ptr<Context> real_context =
GetContext();
1654 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1658 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1659 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1660 ASSERT_EQ(render_pass->GetCommands().size(), 1llu);
1673 std::shared_ptr<Context> real_context =
GetContext();
1674 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1678 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1679 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1680 ASSERT_EQ(render_pass->GetCommands().size(), 2llu);
1694 ASSERT_EQ(
picture.pass->GetClearColor(), expected);
1697 std::shared_ptr<Context> real_context =
GetContext();
1698 std::shared_ptr<ContextMock>
mock_context = spy->MakeContext(real_context);
1702 ASSERT_EQ(spy->render_passes_.size(), 1llu);
1703 std::shared_ptr<RenderPass> render_pass = spy->render_passes_[0];
1704 ASSERT_EQ(render_pass->GetCommands().size(), 0llu);
1709 canvas.SaveLayer({}, std::nullopt,
1720 std::optional<Color> actual_color;
1721 bool found_subpass =
false;
1723 if (
auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
1724 actual_color = subpass->get()->GetClearColor();
1725 found_subpass =
true;
1732 EXPECT_FALSE(actual_color.has_value());
1743 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1751 canvas.SaveLayer({}, {},
1758 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1771 1.0, 1.0, 1.0, 1.0, 0
1775 canvas.Translate({500, 300, 0});
1779 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1789 canvas.Translate({500, 300, 0});
1793 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1803 canvas.Translate({500, 300, 0});
1807 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1819 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1835 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1852 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1869 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1874 canvas.Scale(GetContentScale());
1876 auto test = [&canvas](
const std::shared_ptr<ImageFilter>& filter) {
1877 auto DrawLine = [&canvas](
const Point& p0,
const Point& p1,
1893 canvas.SaveLayer({.image_filter = filter},
1910 canvas.Translate({200.0, 0.0});
1914 canvas.Translate({200.0, 0.0});
1918 canvas.Translate({-400.0, 200.0});
1920 auto rotate_filter =
1925 test(rotate_filter);
1927 canvas.Translate({200.0, 0.0});
1936 test(rgb_swap_filter);
1938 canvas.Translate({200.0, 0.0});
1942 canvas.Translate({-400.0, 200.0});
1947 canvas.Translate({200.0, 0.0});
1952 canvas.Translate({200.0, 0.0});
1958 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1963 canvas.Scale(GetContentScale());
1969 canvas.SaveLayer({.image_filter = blur_filter}, std::nullopt);
1980 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1986 auto image = std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
1987 canvas.DrawImage(
image, {100, 100}, {});
1990 canvas.DrawImage(
image, {100, 500}, {});
1993 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
1999 auto image = std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2000 canvas.DrawImage(
image, {100, 100}, {});
2012 canvas.DrawImage(
image, {100, 500}, {});
2015 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2021 auto image = std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2022 canvas.DrawImage(
image, {100, 100}, {});
2035 canvas.DrawImage(
image, {100, 500}, {});
2038 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2042 TranslucentSaveLayerWithColorFilterAndImageFilterDrawsCorrectly) {
2045 auto image = std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2046 canvas.DrawImage(
image, {100, 100}, {});
2061 canvas.DrawImage(
image, {100, 500}, {});
2064 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2074 canvas.DrawCircle({200, 200}, 100, {.color =
Color::Green()});
2076 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2087 canvas.SaveLayer({});
2088 canvas.DrawCircle({100, 100}, 0.1, {.color =
Color::Yellow()});
2090 canvas.SaveLayer({});
2091 canvas.DrawCircle({100, 100}, 0.1, {.color =
Color::Yellow()});
2096 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2101 canvas.Scale(
Vector2(1.618, 1.618));
2102 canvas.DrawCircle(
Point(), 10,
2111 std::vector<Entity> entity;
2112 std::shared_ptr<SolidColorContents> contents;
2113 picture.pass->IterateAllEntities([
e = &entity, &contents](
Entity& entity) {
2116 std::static_pointer_cast<SolidColorContents>(entity.GetContents());
2117 e->emplace_back(entity.Clone());
2123 ASSERT_TRUE(entity.size() >= 1);
2124 ASSERT_TRUE(contents->IsOpaque());
2136 canvas.DrawCircle({300, 300}, 100, {.color =
Color::Green()});
2139 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2144 auto runtime_stages =
2145 OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
2147 auto runtime_stage =
2149 ASSERT_TRUE(runtime_stage);
2150 ASSERT_TRUE(runtime_stage->IsDirty());
2152 struct FragUniforms {
2155 } frag_uniforms = {.iResolution =
Vector2(400, 400), .iTime = 100.0};
2156 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
2157 uniform_data->resize(
sizeof(FragUniforms));
2158 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
2160 std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
2164 runtime_stage, uniform_data, texture_inputs);
2173 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2177 auto runtime_stages = OpenAssetAsRuntimeStage(
"gradient.frag.iplr");
2178 auto runtime_stage =
2180 ASSERT_TRUE(runtime_stage);
2181 ASSERT_TRUE(runtime_stage->IsDirty());
2183 struct FragUniforms {
2186 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
2187 uniform_data->resize(
sizeof(FragUniforms));
2188 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
2190 std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
2194 runtime_stage, uniform_data, texture_inputs);
2198 canvas.Scale(GetContentScale());
2199 canvas.DrawPaint(
paint);
2202 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2206 std::vector<Point>
points = {
2215 std::vector<PointStyle> caps = {
2226 canvas.DrawPaint(background);
2227 canvas.Translate({200, 200});
2229 canvas.Translate({150, 0});
2232 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2236 auto texture = CreateTextureForFixture(
"table_mountain_nx.png",
2239 std::vector<Point>
points = {
2248 std::vector<PointStyle> caps = {
2257 canvas.Translate({200, 200});
2259 canvas.Translate({150, 0});
2262 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2270 ASSERT_NE(mapping,
nullptr);
2279 std::vector<Color>
colors = {
Color{0.9568, 0.2627, 0.2118, 1.0},
2280 Color{0.1294, 0.5882, 0.9529, 1.0}};
2281 std::vector<Scalar> stops = {
2286 {0, 0}, {100, 100}, std::move(
colors), std::move(stops),
2290 canvas.Translate({100, 100});
2294 ASSERT_NE(blob,
nullptr);
2296 canvas.DrawTextFrame(
frame,
Point(), text_paint);
2298 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2304 canvas.SaveLayer({}, std::nullopt);
2306 canvas.DrawCircle(
Point(200, 200), 100,
2318 canvas.DrawCircle(
Point(200, 200), 100,
2325 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2331 canvas.SaveLayer({}, std::nullopt);
2333 canvas.DrawCircle(
Point(200, 200), 100,
2349 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2360 Color(0.424452, 0.828743, 0.79105, 0.9375));
2365 canvas.Transform(
Matrix(1.0, 0.0, 0.0, 0.0,
2367 0.0, 0.0, 1.0, 0.01,
2368 0.0, 0.0, 0.0, 1.0) *
2372 "Roboto-Regular.ttf"));
2374 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2380 canvas.SaveLayer(save_paint);
2381 canvas.Transform(
Matrix(1.0, 0.0, 0.0, 0.0,
2383 0.0, 0.0, 1.0, 0.01,
2384 0.0, 0.0, 0.0, 1.0) *
2388 "Roboto-Regular.ttf"));
2389 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2396 canvas.SaveLayer({});
2398 canvas.Translate(
Point(100, 100));
2401 canvas.DrawCircle(
Point(200, 200), 200,
2412 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2417 auto context = MakeContext();
2418 std::weak_ptr<Texture> weak_texture;
2421 auto texture = CreateTextureForFixture(
"table_mountain_nx.png");
2424 canvas.Scale(GetContentScale());
2425 canvas.Translate({100.0f, 100.0f, 0});
2432 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2440 context->Shutdown();
2443 ASSERT_TRUE(weak_texture.expired()) <<
"When the texture is no longer in use "
2444 "by the backend, it should be "
2452 ImGuiWindowFlags_AlwaysAutoResize)) {
2453 ImGui::SliderFloat(
"Scale", &
scale, 1, 2);
2457 canvas.Scale(GetContentScale());
2459 std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2460 canvas.Translate({600, -200});
2462 .image_filter = std::make_shared<MatrixImageFilter>(
2465 canvas.DrawImage(
image, {0, 0},
2468 return canvas.EndRecordingAsPicture();
2471 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2477 canvas.Scale(GetContentScale());
2478 canvas.Translate({100, 100});
2482 .image_filter = std::make_shared<MatrixImageFilter>(
2485 canvas.DrawCircle({-300, 0}, 100, {.color =
Color::Green()});
2488 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2493 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
2495 canvas.Scale(GetContentScale());
2496 canvas.Translate({100, 100});
2500 .image_filter = std::make_shared<MatrixImageFilter>(
2504 canvas.DrawCircle({-150, 0}, 50, {.color =
Color::Green()});
2507 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2512 SetWindowSize({400, 400});
2514 canvas.Scale(GetContentScale());
2517 .image_filter = std::make_shared<MatrixImageFilter>(
2527 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2532 canvas.Scale(GetContentScale());
2537 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2542 canvas.Scale(GetContentScale());
2543 auto image = std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2544 canvas.DrawImage(
image, {10, 10}, {});
2548 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2570 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2577 auto texture = CreateTextureForFixture(
"monkey.png");
2608 canvas.Translate(
Vector2(100, 0));
2609 canvas.Scale(
Vector2(100, 100));
2617 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2626 canvas.SaveLayer({});
2635 auto picture = canvas.EndRecordingAsPicture();
2637 std::vector<uint32_t> expected = {
2649 std::vector<uint32_t> actual;
2652 if (
auto* subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
2653 actual.push_back(subpass->get()->GetClipDepth());
2655 if (
Entity* entity = std::get_if<Entity>(&element)) {
2656 actual.push_back(entity->GetClipDepth());
2661 ASSERT_EQ(actual.size(), expected.size());
2662 for (
size_t i = 0;
i < expected.size();
i++) {
2663 EXPECT_EQ(expected[
i], actual[
i]) <<
"Index: " <<
i;
2675 canvas.Translate({300, 300});
2696 Matrix(1.0, 0.0, 0.0, 0.0,
2698 0.0, 0.0, 1.0, 0.003,
2699 0.0, 0.0, 0.0, 1.0) *
2702 std::make_shared<Image>(CreateTextureForFixture(
"airplane.jpg"));
2712 return canvas.EndRecordingAsPicture();
2714 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2721 canvas.Scale(GetContentScale());
2724 std::vector<Color>
colors = {
Color{0.9568, 0.2627, 0.2118, 1.0},
2725 Color{0.1294, 0.5882, 0.9529, 1.0}};
2726 std::vector<Scalar> stops = {
2731 {0, 0}, {100, 100}, std::move(
colors), std::move(stops),
2733 canvas.DrawPaint(
paint);
2739 canvas.ClipRRect(clip_rect,
Size(100, 100),
2741 canvas.SaveLayer({}, clip_rect,
2744 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2749 texture_descriptor.
size =
ISize{1024, 1024};
2754 std::vector<uint8_t> bytes(4194304);
2755 bool alternate =
false;
2756 for (
auto i = 0u;
i < 4194304;
i += 4) {
2768 alternate = !alternate;
2772 auto mapping = std::make_shared<fml::NonOwnedMapping>(
2777 GetContext()->GetResourceAllocator()->CreateTexture(texture_descriptor);
2779 auto device_buffer =
2780 GetContext()->GetResourceAllocator()->CreateBufferWithCopy(*mapping);
2781 auto command_buffer =
GetContext()->CreateCommandBuffer();
2782 auto blit_pass = command_buffer->CreateBlitPass();
2786 blit_pass->GenerateMipmap(
texture);
2796 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2812 canvas.Translate({50, 50, 0});
2813 canvas.DrawPath(
path, {
2819 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2828 canvas.SaveLayer(save_paint);
2829 canvas.Transform(
Matrix(2000, 0, 0, 0,
2836 "Roboto-Regular.ttf"));
2837 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2841 auto bridge = CreateTextureForFixture(
"bay_bridge.jpg");
2844 std::vector<uint8_t> bytes(100 * 100 * 4);
2845 for (
auto i = 0u;
i < bytes.size();
i += 4) {
2852 std::make_shared<fml::NonOwnedMapping>(bytes.data(), bytes.size());
2853 auto device_buffer =
2854 GetContext()->GetResourceAllocator()->CreateBufferWithCopy(*mapping);
2855 auto cmd_buffer =
GetContext()->CreateCommandBuffer();
2856 auto blit_pass = cmd_buffer->CreateBlitPass();
2861 blit_pass->EncodeCommands(
GetContext()->GetResourceAllocator()) &&
2862 GetContext()->GetCommandQueue()->Submit({std::move(cmd_buffer)}).
ok();
2863 ASSERT_TRUE(did_submit);
2865 auto image = std::make_shared<Image>(bridge);
2868 canvas.DrawImage(
image, {0, 0}, {});
2870 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
static const int points[]
static double magnitude(double a)
static bool ok(int result)
static SkBlendMode GetBlendMode(SkSVGFeBlend::Mode mode)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static std::shared_ptr< ColorFilter > MakeMatrix(ColorMatrix color_matrix)
static std::shared_ptr< ColorFilter > MakeBlend(BlendMode blend_mode, Color color)
static std::shared_ptr< ColorFilter > MakeLinearToSrgb()
static std::shared_ptr< ColorFilter > MakeSrgbToLinear()
static ColorSource MakeLinearGradient(Point start_point, Point end_point, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeRadialGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeImage(std::shared_ptr< Texture > texture, Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode, SamplerDescriptor sampler_descriptor, Matrix effect_transform)
static ColorSource MakeRuntimeEffect(std::shared_ptr< RuntimeStage > runtime_stage, std::shared_ptr< std::vector< uint8_t > > uniform_data, std::vector< RuntimeEffectContents::TextureInput > texture_inputs)
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
std::variant< Entity, std::unique_ptr< EntityPass > > Element
@ kNormal
Blurred inside and outside.
static std::shared_ptr< ImageFilter > MakeMatrix(const Matrix &matrix, SamplerDescriptor sampler_descriptor)
static std::shared_ptr< ImageFilter > MakeLocalMatrix(const Matrix &matrix, const ImageFilter &internal_filter)
static std::shared_ptr< ImageFilter > MakeErode(Radius radius_x, Radius radius_y)
static std::shared_ptr< ImageFilter > MakeBlur(Sigma sigma_x, Sigma sigma_y, FilterContents::BlurStyle blur_style, Entity::TileMode tile_mode)
static std::shared_ptr< ImageFilter > MakeDilate(Radius radius_x, Radius radius_y)
static std::shared_ptr< ImageFilter > MakeFromColorFilter(const ColorFilter &color_filter)
static std::shared_ptr< ImageFilter > MakeCompose(const ImageFilter &inner, const ImageFilter &outer)
PathBuilder & AddRect(Rect rect)
Path TakePath(FillType fill=FillType::kNonZero)
PathBuilder & MoveTo(Point point, bool relative=false)
PathBuilder & AddCircle(const Point ¢er, Scalar radius)
PathBuilder & AddLine(const Point &p1, const Point &p2)
Move to point p1, then insert a line from p1 to p2.
PathBuilder & AddRoundedRect(Rect rect, RoundingRadii radii)
PathBuilder & SetConvexity(Convexity value)
static std::unique_ptr< TypographerContext > Make()
static std::shared_ptr< Node > MakeFromFlatbuffer(const fml::Mapping &ipscene_mapping, Allocator &allocator)
static std::shared_ptr< ContextSpy > Make()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define ASSERT_MATRIX_NEAR(a, b)
#define ASSERT_COLOR_NEAR(a, b)
static MockContext mock_context
SK_API GrDirectContext * GetContext(const SkImage *src)
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< const SkPicture > picture
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
SK_API sk_sp< SkShader > Color(SkColor)
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
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
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
bool RenderTextInCanvasSTB(const std::shared_ptr< Context > &context, Canvas &canvas, const std::string &text, const std::string &font_fixture, TextRenderOptions options={})
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
static constexpr std::string_view kFontFixture
bool RenderTextInCanvasSkia(const std::shared_ptr< Context > &context, Canvas &canvas, const std::string &text, const std::string_view &font_fixture, TextRenderOptions options={})
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
std::shared_ptr< TextFrame > MakeTextFrameSTB(const std::shared_ptr< TypefaceSTB > &typeface_stb, Font::Metrics metrics, const std::string &text)
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
@ kRound
Points are drawn as squares.
@ kSquare
Points are drawn as circles.
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
constexpr float k1OverSqrt2
void Close(PathBuilder *builder)
constexpr const char * PixelFormatToString(PixelFormat format)
SK_API sk_sp< PrecompileColorFilter > Matrix()
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
static double time(int loops, Benchmark *bench, Target *target)
const Scalar stroke_width
static constexpr Color Crimson()
static constexpr Color LimeGreen()
static constexpr Color BlackTransparent()
static constexpr Color Black()
static constexpr Color CornflowerBlue()
static constexpr Color MediumTurquoise()
static constexpr Color White()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color Orange()
static constexpr Color Purple()
static constexpr Color Red()
static constexpr Color MakeRGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
static constexpr Color Yellow()
Color Blend(Color source, BlendMode blend_mode) const
Blends an unpremultiplied destination color into a given unpremultiplied source color to form a new u...
static constexpr Color Blue()
static constexpr Color Green()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr Matrix MakePerspective(Radians fov_y, Scalar aspect_ratio, Scalar z_near, Scalar z_far)
static Matrix MakeRotationY(Radians r)
static constexpr Matrix MakeLookAt(Vector3 position, Vector3 target, Vector3 up)
static Matrix MakeRotationZ(Radians r)
static constexpr Matrix MakeScale(const Vector3 &s)
FilterContents::BlurStyle style
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
static constexpr TPoint< Type > MakeXY(Type x, Type y)
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
constexpr size_t MipCount() const
static constexpr TSize MakeWH(Type width, Type height)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
constexpr size_t GetByteSizeOfBaseMipLevel() const
std::optional< Paint::MaskBlurDescriptor > mask_blur_descriptor
#define EXPECT_TRUE(handle)