37 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
45 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
52sk_sp<DisplayList> MakeWideStrokedRects(
Point scale,
53 const DrawRectProc& draw_rect) {
55 builder.
Scale(scale.
x, scale.
y);
95 return builder.
Build();
100 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
109 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
123 DlImageSampling::kNearestNeighbor, &paint);
124 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
137 DlImageSampling::kNearestNeighbor, &paint);
138 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
150 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
162 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
166bool GenerateMipmap(
const std::shared_ptr<Context>&
context,
167 std::shared_ptr<Texture>
texture,
168 std::string_view label) {
169 auto buffer =
context->CreateCommandBuffer();
173 auto pass = buffer->CreateBlitPass();
177 pass->GenerateMipmap(std::move(
texture), label);
179 pass->EncodeCommands();
183void CanRenderTiledTexture(
AiksTest* aiks_test,
185 Matrix local_matrix = {}) {
186 auto context = aiks_test->GetContext();
188 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
193 image, tile_mode, tile_mode, DlImageSampling::kNearestNeighbor,
201 builder.
Scale(aiks_test->GetContentScale().x, aiks_test->GetContentScale().y);
206 constexpr auto stroke_width = 64;
209 if (tile_mode == DlTileMode::kDecal) {
225 EXPECT_FALSE(
path.IsRect(
nullptr));
226 EXPECT_FALSE(
path.IsOval(
nullptr));
227 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
230 EXPECT_FALSE(
path.IsConvex());
240 constexpr float kConicWeight = 0.707106781f;
243 .ConicCurveTo({300, 300}, {300, 450}, kConicWeight)
244 .ConicCurveTo({300, 600}, {150, 600}, kConicWeight)
245 .ConicCurveTo({0, 600}, {0, 450}, kConicWeight)
246 .ConicCurveTo({0, 300}, {150, 300}, kConicWeight)
251 EXPECT_FALSE(
path.IsRect(
nullptr));
252 EXPECT_FALSE(
path.IsOval(
nullptr));
253 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
256 EXPECT_TRUE(
path.IsConvex());
262 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.
Build()));
267 CanRenderTiledTexture(
this, DlTileMode::kClamp);
271 CanRenderTiledTexture(
this, DlTileMode::kRepeat);
275 CanRenderTiledTexture(
this, DlTileMode::kMirror);
279 CanRenderTiledTexture(
this, DlTileMode::kDecal);
283 CanRenderTiledTexture(
this, DlTileMode::kClamp,
297 source_rect.Shift(image_half_size.
width, image_half_size.
height);
301 DlImageSampling::kNearestNeighbor);
302 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
311 image->GetSize().width * 0.25f,
image->GetSize().height * 0.4f,
312 image->GetSize().width,
image->GetSize().height);
321 DlImageSampling::kNearestNeighbor);
322 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
327 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
378 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
379 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
380 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
381 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
382 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
393 auto texture = CreateTextureForFixture(
"airplane.jpg",
398 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
403 DlImageSampling::kNearestNeighbor));
406 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
424 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
458 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
468 .top_right =
DlSize(25, 50),
469 .bottom_left =
DlSize(25, 50),
470 .bottom_right =
DlSize(50, 25),
477 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
483 Scalar bottom_left = 60.f;
484 Scalar bottom_right = 80.f;
485 auto callback = [&]() -> sk_sp<DisplayList> {
486 if (IsPlaygroundEnabled()) {
487 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
488 ImGui::SliderFloat(
"top_left", &top_left, 0, 250);
489 ImGui::SliderFloat(
"top_right", &top_right, 0, 250);
490 ImGui::SliderFloat(
"bottom_left", &bottom_left, 0, 250);
491 ImGui::SliderFloat(
"bottom_right", &bottom_right, 0, 250);
501 .top_right =
DlSize(top_right, top_right),
502 .bottom_left =
DlSize(bottom_left, bottom_left),
503 .bottom_right =
DlSize(bottom_right, bottom_right),
509 return builder.
Build();
512 ASSERT_TRUE(OpenPlaygroundHere(
callback));
516 auto medium_turquoise =
517 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
520 builder.
Scale(0.2, 0.2);
522 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
526 auto medium_turquoise =
527 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
529 DlColor::RGBA(255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f);
532 builder.
Scale(0.2, 0.2);
535 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
540 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
588 builder.
DrawRect(thin_tall_rect.
Shift({100, 100}), thin_paint);
590 builder.
DrawRect(thin_wide_rect.
Shift({100, 100}), thin_paint);
599 builder.
DrawRect(thin_tall_rect.
Shift({100, 300}), thin_paint);
601 builder.
DrawRect(thin_wide_rect.
Shift({100, 300}), thin_paint);
611 builder.
DrawRect(thin_tall_rect.
Shift({100, 500}), thin_paint);
613 builder.
DrawRect(thin_wide_rect.
Shift({100, 500}), thin_paint);
623 builder.
DrawRect(thin_tall_rect.
Shift({300, 500}), thin_paint);
625 builder.
DrawRect(thin_wide_rect.
Shift({300, 500}), thin_paint);
662 for (
int i = 0;
i < 15;
i++) {
670 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
675 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
677 const int color_count = 3;
678 DlColor colors[color_count] = {
681 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
690 paint.
setColor(colors[(c_index++) % color_count]);
702 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
703 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
704 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
705 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
706 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
717 auto texture = CreateTextureForFixture(
"airplane.jpg",
722 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
727 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
728 DlImageSampling::kNearestNeighbor, &local_matrix));
731 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
736 static float stroked_radius = 100.0;
737 static float stroke_width = 0.0;
738 static float stroke_width_fine = 2.0;
739 static float stroked_alpha = 255.0;
740 static float stroked_scale[2] = {1.0, 1.0};
742 if (IsPlaygroundEnabled()) {
743 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
744 ImGui::SliderFloat(
"Stroked Radius", &stroked_radius, 0, 500);
745 ImGui::SliderFloat(
"Stroked Width", &stroke_width, 0, 500);
746 ImGui::SliderFloat(
"Stroked Width Fine", &stroke_width_fine, 0, 5);
747 ImGui::SliderFloat(
"Stroked Alpha", &stroked_alpha, 0, 10.0);
748 ImGui::SliderFloat2(
"Stroked Scale", stroked_scale, 0, 10.0);
755 background_paint.
setColor(
DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
765 builder.
Scale(stroked_scale[0], stroked_scale[1]);
769 return builder.
Build();
772 ASSERT_TRUE(OpenPlaygroundHere(
callback));
777 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
779 const int color_count = 3;
780 DlColor colors[color_count] = {
783 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
791 auto draw = [&paint, &colors, &c_index](
DlCanvas& canvas,
DlPoint center,
793 for (
int i = 0;
i < n;
i++) {
794 paint.
setColor(colors[(c_index++) % color_count]);
795 canvas.DrawCircle(center, r, paint);
802 draw(builder,
DlPoint(10, 10), 2, 2, 14);
804 draw(builder,
DlPoint(10, 10), 35, 10, 56);
809 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
810 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
811 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
812 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
813 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
824 auto texture = CreateTextureForFixture(
"airplane.jpg",
829 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
830 draw(builder,
DlPoint(500, 600), 5, 10, 10);
834 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
835 DlImageSampling::kNearestNeighbor, &local_matrix));
836 draw(builder,
DlPoint(800, 300), 5, 10, 10);
838 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
846 const Scalar k = 0.5522847498f;
865 path_builder.
Close();
869void DrawStrokedAndFilledCirclesWithZoom(
AiksTest* test,
874 builder.
Scale(test->GetContentScale().x, test->GetContentScale().y);
885 DlPath path = ManuallyConstructCirclePath(radius);
887 constexpr Scalar kLeftX = 300.0f;
888 constexpr Scalar kRightX = 680.0f;
889 constexpr Scalar kTopY = 200.0f;
890 constexpr Scalar kBottomY = 580.0f;
895 builder.
Scale(zoom, zoom);
903 builder.
Scale(zoom, zoom);
910 builder.
Scale(zoom, zoom);
918 builder.
Scale(zoom, zoom);
919 builder.
DrawCircle({}, radius + stroke_width * 0.5f, fill_paint);
922 ASSERT_TRUE(test->OpenPlaygroundHere(builder.
Build()));
927 DrawStrokedAndFilledCirclesWithZoom(
this, 80.0f, 2.0f,
932 DrawStrokedAndFilledCirclesWithZoom(
this, 1.0f, 1.0f,
938 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
940 const int color_count = 3;
941 DlColor colors[color_count] = {
944 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
951 int long_radius = 600;
952 int short_radius = 600;
953 while (long_radius > 0 && short_radius > 0) {
954 paint.
setColor(colors[(c_index++) % color_count]);
961 if (short_radius > 30) {
973 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
974 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
975 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
976 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
977 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
988 auto texture = CreateTextureForFixture(
"airplane.jpg",
995 DlPoint(300, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1001 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1002 DlImageSampling::kNearestNeighbor, &local_matrix));
1006 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1010struct ArcFarmOptions {
1019 const ArcFarmOptions& opts) {
1023 const int sweep_limit = opts.sweeps_over_360 ? 420 : 360;
1026 for (
int sweep = 30; sweep <= sweep_limit; sweep += 30) {
1027 builder.
DrawArc(arc_bounds,
start, opts.full_circles ? 360 : sweep,
1028 opts.use_center, paint);
1042 for (
int stroke_width = 10; stroke_width <= 40; stroke_width += 3) {
1046 for (
int sweep = 160; sweep <= 360; sweep += 20) {
1047 builder.
DrawArc(arc_bounds, 0, sweep,
false, modified_paint);
1051 builder.
Translate(0, 44 + stroke_width);
1059 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1065 RenderArcFarm(builder, paint,
1067 .use_center =
false,
1068 .full_circles =
false,
1071 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1076 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1082 RenderArcFarm(builder, paint,
1084 .use_center =
false,
1085 .full_circles =
false,
1088 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1093 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1099 RenderArcFarm(builder, paint,
1102 .full_circles =
false,
1105 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1110 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1116 RenderArcFarm(builder, paint,
1118 .use_center =
false,
1119 .full_circles =
false,
1120 .vertical_scale = 0.8f,
1123 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1128 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1134 RenderArcFarm(builder, paint,
1137 .full_circles =
false,
1138 .vertical_scale = 0.8f,
1141 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1146 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1155 RenderArcFarm(builder, paint,
1157 .use_center =
false,
1158 .full_circles =
false,
1161 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1166 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1175 RenderArcFarm(builder, paint,
1177 .use_center =
false,
1178 .full_circles =
false,
1181 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1186 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1194 RenderArcFarmForOverlappingCapsTest(builder, paint);
1196 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1201 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1210 RenderArcFarm(builder, paint,
1212 .use_center =
false,
1213 .full_circles =
false,
1216 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1221 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1229 RenderArcFarmForOverlappingCapsTest(builder, paint);
1231 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1236 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1245 RenderArcFarm(builder, paint,
1248 .full_circles =
false,
1249 .sweeps_over_360 =
true,
1252 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1257 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1269 RenderArcFarm(builder, paint,
1272 .full_circles =
false,
1273 .sweeps_over_360 =
true,
1276 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1281 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1290 RenderArcFarm(builder, paint,
1293 .full_circles =
false,
1294 .sweeps_over_360 =
true,
1297 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1302 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1311 RenderArcFarm(builder, paint,
1313 .use_center =
false,
1314 .full_circles =
false,
1320 RenderArcFarm(builder, paint,
1322 .use_center =
false,
1323 .full_circles =
false,
1326 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1331 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1340 RenderArcFarm(builder, paint,
1342 .use_center =
false,
1343 .full_circles =
false,
1349 RenderArcFarm(builder, paint,
1351 .use_center =
false,
1352 .full_circles =
false,
1358 RenderArcFarm(builder, paint,
1360 .use_center =
false,
1361 .full_circles =
false,
1364 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1380 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1390 RenderArcFarm(builder, paint,
1392 .use_center =
false,
1393 .full_circles =
true,
1399 RenderArcFarm(builder, paint,
1401 .use_center =
false,
1402 .full_circles =
false,
1405 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1410 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1412 const int color_count = 3;
1413 DlColor colors[color_count] = {
1416 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
1423 for (
int i = 0;
i < 4;
i++) {
1424 for (
int j = 0; j < 4; j++) {
1425 paint.
setColor(colors[(c_index++) % color_count]);
1429 i * 5 + 10, j * 5 + 10),
1433 paint.
setColor(colors[(c_index++) % color_count]);
1437 paint.
setColor(colors[(c_index++) % color_count]);
1442 DlColor gradient_colors[7] = {
1445 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1446 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1447 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1448 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1449 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
1460 auto texture = CreateTextureForFixture(
"airplane.jpg",
1466 DlPoint(550, 550), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1467 for (
int i = 1;
i <= 10;
i++) {
1471 550 +
i * 20, 550 + j * 20),
1478 DlPoint(200, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1490 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1491 DlImageSampling::kNearestNeighbor, &local_matrix));
1492 for (
int i = 1;
i <= 10;
i++) {
1496 720 +
i * 20, 220 + j * 20),
1504 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1505 DlImageSampling::kNearestNeighbor, &local_matrix));
1513 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1518 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1525 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f));
1527 for (
int i = 0;
i < 5;
i++) {
1531 radius, 60.0f - radius),
1537 for (
int i = 0;
i < 5;
i++) {
1545 for (
int i = 0;
i < 5;
i++) {
1549 radius, 60.0f - radius),
1554 DlColor::RGBA(128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f));
1556 for (
int i = 0;
i < 5;
i++) {
1566 DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f));
1568 for (
int i = 0;
i < 5;
i++) {
1577 auto dl = builder.
Build();
1578 ASSERT_TRUE(OpenPlaygroundHere(dl));
1584 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1587 std::vector<DlColor> colors = {
DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
1589 std::vector<Scalar> stops = {
1615 builder.
SaveLayer(clip_rect, &save_paint, backdrop_filter.get());
1617 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1623 auto callback = [&]() -> sk_sp<DisplayList> {
1638 DlClipOp::kDifference);
1652 Matrix(1.0, 0.0, 0.0, 0.0,
1654 0.0, 0.0, 1.0, 0.003,
1655 0.0, 0.0, 0.0, 1.0) *
1676 return builder.
Build();
1678 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1696 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1697 DlImageSampling::kNearestNeighbor, &matrix));
1708 Matrix matrix(1, -1, 0, 0,
1713 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1714 DlImageSampling::kNearestNeighbor, &matrix));
1723 builder.
Scale(100, 100);
1728 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1729 DlImageSampling::kNearestNeighbor, &matrix));
1744 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1745 DlImageSampling::kNearestNeighbor, &matrix));
1751 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1773 builder.
SaveLayer(std::nullopt, &paint);
1779 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1785 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1793 builder.
SaveLayer(std::nullopt, &paint);
1800 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1805 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
1807 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1815 DlImageSampling::kNearestNeighbor));
1816 builder.
SaveLayer(std::nullopt, &paint);
1823 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1828 SetWindowSize({400, 400});
1831 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1838 DlImageSampling::kLinear));
1839 builder.SaveLayer(std::nullopt, &paint);
1850 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1855 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1862 builder.
SaveLayer(std::nullopt, &paint);
1865 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1870 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1877 builder.
SaveLayer(std::nullopt, &paint);
1880 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1884 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
1908 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1915 if (!EnsureContextSupportsWideGamut()) {
1916 GTEST_SKIP() <<
"This backend doesn't yet support wide gamut.";
1919 EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1925 GetContext()->GetCapabilities()->GetDefaultColorFormat();
1940 builder.
Scale(0.5, 0.5);
1942 DlImageSampling::kNearestNeighbor);
1951 builder.
SaveLayer(std::nullopt, &alpha);
1964 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1974 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1985 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2007 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2012 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2015 const int color_count = 3;
2016 DlColor colors[color_count] = {
2019 DlColor::ARGB(1.0, 220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f),
2031 for (
int i = 0;
i < 4;
i++) {
2032 for (
int j = 0; j < 4; j++) {
2033 paint.
setColor(colors[(c_index++) % color_count]);
2035 i * 5 + 10, j * 5 + 10, paint);
2038 paint.
setColor(colors[(c_index++) % color_count]);
2040 paint.
setColor(colors[(c_index++) % color_count]);
2043 std::vector<DlColor> gradient_colors = {
2046 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
2047 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
2048 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
2049 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
2050 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0)};
2051 std::vector<Scalar> stops = {
2061 CreateTextureForFixture(
"airplane.jpg",
2068 gradient_colors.size(),
2069 gradient_colors.data(),
2071 DlTileMode::kMirror));
2072 for (
int i = 1;
i <= 10;
i++) {
2075 550 +
i * 20, 550 + j * 20),
2076 i * 10, j * 10, paint);
2082 gradient_colors.size(),
2083 gradient_colors.data(),
2085 DlTileMode::kMirror));
2092 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2093 DlImageSampling::kMipmapLinear, &matrix));
2094 for (
int i = 1;
i <= 10;
i++) {
2097 720 +
i * 20, 220 + j * 20),
2098 i * 10, j * 10, paint);
2103 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2104 DlImageSampling::kMipmapLinear, &matrix));
2109 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2113 auto callback = [&]() -> sk_sp<DisplayList> {
2115 builder.
Scale(GetContentScale().x, GetContentScale().y);
2120 auto current =
Point{25, 25};
2121 const auto offset =
Point{25, 25};
2133 builder.
DrawRect(bounds, stroke_paint);
2154 return builder.
Build();
2157 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2172 builder.
SaveLayer(std::nullopt, &save_paint);
2183 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2219 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2249 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2255 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2259 auto draw_image_layer = [&builder, &
texture](
const DlPaint& paint) {
2260 builder.
SaveLayer(std::nullopt, &paint);
2267 draw_image_layer(effect_paint);
2270 builder.
Scale(3, 3);
2271 draw_image_layer(effect_paint);
2273 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2279 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2288 for (
int i = 0;
i < 5;
i++) {
2291 for (
int j = 0; j < 5; j++) {
2293 Scalar x_radius = j * 15;
2297 x_radius, y_radius),
2302 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2310 builder.
SaveLayer(std::nullopt, &paint);
2325 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2332 switch (GetBackend()) {
2339 GTEST_SKIP() <<
"Platform is running out of memory on this example "
2340 <<
"(see https://github.com/flutter/flutter/issues/189286).";
2350 builder.
SaveLayer(std::nullopt, &paint);
2358 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2365 bool stroked =
true;
2366 auto callback = [&]() -> sk_sp<DisplayList> {
2367 if (IsPlaygroundEnabled()) {
2368 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
2369 ImGui::SliderFloat(
"width", &
width, 0, 200);
2370 ImGui::SliderFloat(
"height", &
height, 0, 200);
2371 ImGui::SliderFloat(
"corner", &corner, 0, 1);
2372 ImGui::Checkbox(
"stroked", &stroked);
2377 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2380 background_paint.
setColor(
DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
2384 std::vector<Scalar> stops = {0.0, 1.0};
2388 2, colors.data(), stops.data(),
2389 DlTileMode::kClamp);
2402 Scalar corner_x = ((1 - corner) * 50) + 50;
2403 Scalar corner_y = corner * 50 + 50;
2408 return builder.
Build();
2410 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2432 builder.
SaveLayer(std::nullopt,
nullptr, image_filter.get());
2438 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2442 int perspective = 58;
2443 bool use_clip =
true;
2444 bool diff_clip =
false;
2446 auto callback = [&]() -> sk_sp<DisplayList> {
2447 if (IsPlaygroundEnabled()) {
2448 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
2449 ImGui::SliderInt(
"perspective%", &perspective, 0, 100);
2450 ImGui::Checkbox(
"use clip", &use_clip);
2452 ImGui::Checkbox(
"diff clip", &diff_clip);
2454 ImGui::SetWindowPos(
"Controls", ImVec2(500, 100));
2460 Scalar val = perspective * -0.00005f;
2463 1.0f, 0.0f, 0.0f, 400.0f,
2464 0.0f, 1.0f, 0.0f, 400.0f,
2465 0.0f, 0.0f, 1.0f, 0.0f,
2466 0.0f, val, 0.0f, 2.2f
2472 DlClipOp clip_op = DlClipOp::kIntersect;
2474 clip = clip.Expand(-20);
2475 clip_op = DlClipOp::kDifference;
2485 DlBlendMode::kSrcOver);
2487 return builder.
Build();
2489 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2514 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2527 .top_left =
Size(60.0f, 240.0f),
2528 .top_right =
Size(200.0f, 40.0f),
2529 .bottom_left =
Size(180.0f, 20.0f),
2530 .bottom_right =
Size(40.0f, 200.0f),
2538 .top_left =
Size(240.0f, 40.0f),
2539 .top_right =
Size(40.0f, 240.0f),
2540 .bottom_left =
Size(40.0f, 240.0f),
2541 .bottom_right =
Size(240.0f, 40.0f),
2549 .top_left =
Size(240.0f, 240.0f),
2550 .top_right =
Size(40.0f, 40.0f),
2551 .bottom_left =
Size(40.0f, 40.0f),
2552 .bottom_right =
Size(40.0f, 40.0f),
2560 .top_left =
Size(240.0f, 240.0f),
2561 .top_right =
Size(40.0f, 40.0f),
2562 .bottom_left =
Size(40.0f, 40.0f),
2563 .bottom_right =
Size(240.0f, 240.0f),
2567 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2594 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2619 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2646 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2655 DlScalar radii[] = {10.0f, 30.0f, 50.0f};
2657 for (
int row = 0; row < 3; row++) {
2678 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2688 builder.
Scale(1.5f, 0.8f);
2698 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2715 DlImageSampling::kNearestNeighbor));
2716 builder.
SaveLayer(bounds, &layer_paint_left);
2729 DlImageSampling::kNearestNeighbor));
2730 builder.
SaveLayer(bounds, &layer_paint_right);
2738 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2747 .top_right =
DlSize(10.0f),
2748 .bottom_left =
DlSize(20.0f),
2749 .bottom_right =
DlSize(50.0f)};
2772 DlPaint().setBlendMode(DlBlendMode::kClear));
2774 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2779 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2782 const float line_length = 30.0f;
2783 const float stroke_width = 10.0f;
2784 const float spacing = 50.0f;
2786 const std::vector<flutter::DlStrokeCap> caps = {
2791 const std::vector<float> alphas = {1.0f, 0.75f, 0.5f, 0.25f};
2792 const std::vector<Radians> angles = {
2805 for (
const float alpha : alphas) {
2810 for (
const Radians angle : angles) {
2813 DlPoint(cos(angle.radians) * line_length,
2814 sin(angle.radians) * line_length),
2821 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawOval(const DlRect &bounds, const DlPaint &paint) override
void ClipRect(const DlRect &rect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void DrawImageRect(const sk_sp< DlImage > &image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast) override
void DrawRoundRect(const DlRoundRect &rrect, const DlPaint &paint) override
void DrawArc(const DlRect &bounds, DlScalar start, DlScalar sweep, bool useCenter, const DlPaint &paint) override
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
void DrawColor(DlColor color, DlBlendMode mode) override
void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint) override
void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) override
void DrawLine(const DlPoint &p0, const DlPoint &p1, const DlPaint &paint) override
void ClipRoundRect(const DlRoundRect &rrect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void Rotate(DlScalar degrees) override
void DrawRoundSuperellipse(const DlRoundSuperellipse &rse, const DlPaint &paint) override
void Scale(DlScalar sx, DlScalar sy) override
void Skew(DlScalar sx, DlScalar sy) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void ClipPath(const DlPath &path, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void ClipOval(const DlRect &bounds, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void TransformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
void DrawDiffRoundRect(const DlRoundRect &outer, const DlRoundRect &inner, const DlPaint &paint) override
void Transform(const DlMatrix &matrix) override
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
Developer-facing API for rendering anything within the engine.
static std::shared_ptr< const DlColorFilter > MakeBlend(DlColor color, DlBlendMode mode)
static std::shared_ptr< DlColorSource > MakeImage(const sk_sp< const DlImage > &image, DlTileMode horizontal_tile_mode, DlTileMode vertical_tile_mode, DlImageSampling sampling=DlImageSampling::kLinear, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeLinear(const DlPoint start_point, const DlPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRadial(DlPoint center, DlScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlImageFilter > MakeBlur(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
static std::shared_ptr< DlImageFilter > MakeColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
static std::shared_ptr< DlImageFilter > MakeMatrix(const DlMatrix &matrix, DlImageSampling sampling)
DlPaint & setColor(DlColor color)
DlPaint & setAntiAlias(bool isAntiAlias)
DlPaint & setInvertColors(bool isInvertColors)
DlPaint & setStrokeCap(DlStrokeCap cap)
DlPaint & setStrokeWidth(float width)
DlPaint & setStrokeMiter(float miter)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setImageFilter(std::nullptr_t filter)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setStrokeJoin(DlStrokeJoin join)
DlPaint & setColorFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & AddCircle(DlPoint center, DlScalar radius)
Append a closed circular contour to the path centered on the provided point at the provided radius.
DlPathBuilder & AddRoundRect(const DlRoundRect &round_rect)
Append a closed rounded rect contour to the path.
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
static DlPath MakeCircle(const DlPoint center, DlScalar radius)
static DlPath MakeRectXYWH(DlScalar x, DlScalar y, DlScalar width, DlScalar height)
static DlPath MakeRect(const DlRect &rect)
static DlPath MakeRoundRectXY(const DlRect &rect, DlScalar x_radius, DlScalar y_radius, bool counter_clock_wise=false)
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
impeller::Scalar DlScalar
@ kButt
no stroke extension
impeller::ISize32 DlISize
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
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
@ kStroke
strokes boundary of shapes
static constexpr DlScalar kEhCloseEnough
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
TEST_P(AiksTest, DrawAtlasNoColor)
AiksPlaygroundWithGoldens AiksTest
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
void Close(PathBuilder *builder)
constexpr const char * PixelFormatToString(PixelFormat format)
std::shared_ptr< ContextGLES > context
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor ARGB(DlScalar a, DlScalar r, DlScalar g, DlScalar b)
Construct a 32 bit color from floating point A, R, G, and B color channels.
static constexpr DlColor kAqua()
static constexpr DlColor kYellow()
static constexpr DlColor kPurple()
static constexpr DlColor kMidGrey()
constexpr DlColor withAlphaF(float alpha) const
static constexpr DlColor kTransparent()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kOrange()
static constexpr DlColor kSkyBlue()
constexpr DlColor modulateOpacity(DlScalar opacity) const
static constexpr Color White()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationY(Radians r)
static Matrix MakePerspective(Radians fov_y, Scalar aspect_ratio, Scalar z_near, Scalar z_far)
static constexpr Matrix MakeScale(const Vector3 &s)
static RoundRect MakeRectRadius(const Rect &rect, Scalar radius)
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
static RoundSuperellipse MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static RoundSuperellipse MakeRectRadius(const Rect &rect, Scalar radius)
static constexpr TRect MakeEllipseBounds(const TPoint< Type > ¢er, const TSize< Type > &radii)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)