35 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
42sk_sp<DisplayList> MakeWideStrokedRects(
Point scale,
43 const DrawRectProc& draw_rect) {
45 builder.
Scale(scale.
x, scale.
y);
85 return builder.
Build();
90 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
99 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
113 DlImageSampling::kNearestNeighbor, &paint);
114 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
127 DlImageSampling::kNearestNeighbor, &paint);
128 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
140 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
152 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
156bool GenerateMipmap(
const std::shared_ptr<Context>& context,
157 std::shared_ptr<Texture>
texture,
158 std::string_view label) {
159 auto buffer = context->CreateCommandBuffer();
163 auto pass = buffer->CreateBlitPass();
167 pass->GenerateMipmap(std::move(
texture), label);
169 pass->EncodeCommands();
170 return context->GetCommandQueue()->Submit({
buffer}).ok();
173void CanRenderTiledTexture(
AiksTest* aiks_test,
175 Matrix local_matrix = {}) {
176 auto context = aiks_test->GetContext();
177 ASSERT_TRUE(context);
178 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
180 GenerateMipmap(context,
texture,
"table_mountain_nx");
183 image, tile_mode, tile_mode, DlImageSampling::kNearestNeighbor,
191 builder.
Scale(aiks_test->GetContentScale().x, aiks_test->GetContentScale().y);
196 constexpr auto stroke_width = 64;
199 if (tile_mode == DlTileMode::kDecal) {
215 EXPECT_FALSE(
path.IsRect(
nullptr));
216 EXPECT_FALSE(
path.IsOval(
nullptr));
217 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
220 EXPECT_FALSE(
path.IsConvex());
230 constexpr float kConicWeight = 0.707106781f;
233 .ConicCurveTo({300, 300}, {300, 450}, kConicWeight)
234 .ConicCurveTo({300, 600}, {150, 600}, kConicWeight)
235 .ConicCurveTo({0, 600}, {0, 450}, kConicWeight)
236 .ConicCurveTo({0, 300}, {150, 300}, kConicWeight)
241 EXPECT_FALSE(
path.IsRect(
nullptr));
242 EXPECT_FALSE(
path.IsOval(
nullptr));
243 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
246 EXPECT_TRUE(
path.IsConvex());
252 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.
Build()));
257 CanRenderTiledTexture(
this, DlTileMode::kClamp);
261 CanRenderTiledTexture(
this, DlTileMode::kRepeat);
265 CanRenderTiledTexture(
this, DlTileMode::kMirror);
269 CanRenderTiledTexture(
this, DlTileMode::kDecal);
273 CanRenderTiledTexture(
this, DlTileMode::kClamp,
287 source_rect.Shift(image_half_size.
width, image_half_size.
height);
291 DlImageSampling::kNearestNeighbor);
292 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
301 image->GetSize().width * 0.25f,
image->GetSize().height * 0.4f,
302 image->GetSize().width,
image->GetSize().height);
311 DlImageSampling::kNearestNeighbor);
312 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
317 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
368 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
369 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
370 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
371 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
372 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
383 auto texture = CreateTextureForFixture(
"airplane.jpg",
388 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
393 DlImageSampling::kNearestNeighbor));
396 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
414 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
448 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
458 .top_right =
DlSize(25, 50),
459 .bottom_left =
DlSize(25, 50),
460 .bottom_right =
DlSize(50, 25),
467 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
471 auto medium_turquoise =
472 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
475 builder.
Scale(0.2, 0.2);
477 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
481 auto medium_turquoise =
482 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
484 DlColor::RGBA(255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f);
487 builder.
Scale(0.2, 0.2);
490 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
495 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
543 builder.
DrawRect(thin_tall_rect.
Shift({100, 100}), thin_paint);
545 builder.
DrawRect(thin_wide_rect.
Shift({100, 100}), thin_paint);
554 builder.
DrawRect(thin_tall_rect.
Shift({100, 300}), thin_paint);
556 builder.
DrawRect(thin_wide_rect.
Shift({100, 300}), thin_paint);
566 builder.
DrawRect(thin_tall_rect.
Shift({100, 500}), thin_paint);
568 builder.
DrawRect(thin_wide_rect.
Shift({100, 500}), thin_paint);
578 builder.
DrawRect(thin_tall_rect.
Shift({300, 500}), thin_paint);
580 builder.
DrawRect(thin_wide_rect.
Shift({300, 500}), thin_paint);
617 for (
int i = 0;
i < 15;
i++) {
625 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
630 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
632 const int color_count = 3;
633 DlColor colors[color_count] = {
636 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
645 paint.
setColor(colors[(c_index++) % color_count]);
657 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
658 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
659 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
660 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
661 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
672 auto texture = CreateTextureForFixture(
"airplane.jpg",
677 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
682 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
683 DlImageSampling::kNearestNeighbor, &local_matrix));
686 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
691 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
693 const int color_count = 3;
694 DlColor colors[color_count] = {
697 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
705 auto draw = [&paint, &colors, &c_index](
DlCanvas& canvas,
DlPoint center,
707 for (
int i = 0;
i < n;
i++) {
708 paint.
setColor(colors[(c_index++) % color_count]);
709 canvas.DrawCircle(center, r, paint);
716 draw(builder,
DlPoint(10, 10), 2, 2, 14);
718 draw(builder,
DlPoint(10, 10), 35, 10, 56);
723 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
724 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
725 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
726 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
727 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
738 auto texture = CreateTextureForFixture(
"airplane.jpg",
743 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
744 draw(builder,
DlPoint(500, 600), 5, 10, 10);
748 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
749 DlImageSampling::kNearestNeighbor, &local_matrix));
750 draw(builder,
DlPoint(800, 300), 5, 10, 10);
752 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
760 const Scalar k = 0.5522847498f;
779 path_builder.
Close();
783void DrawStrokedAndFilledCirclesWithZoom(
AiksTest* test,
788 builder.
Scale(test->GetContentScale().x, test->GetContentScale().y);
799 DlPath path = ManuallyConstructCirclePath(radius);
801 constexpr Scalar kLeftX = 300.0f;
802 constexpr Scalar kRightX = 680.0f;
803 constexpr Scalar kTopY = 200.0f;
804 constexpr Scalar kBottomY = 580.0f;
809 builder.
Scale(zoom, zoom);
817 builder.
Scale(zoom, zoom);
824 builder.
Scale(zoom, zoom);
832 builder.
Scale(zoom, zoom);
833 builder.
DrawCircle({}, radius + stroke_width * 0.5f, fill_paint);
836 ASSERT_TRUE(test->OpenPlaygroundHere(builder.
Build()));
841 DrawStrokedAndFilledCirclesWithZoom(
this, 80.0f, 2.0f,
846 DrawStrokedAndFilledCirclesWithZoom(
this, 1.0f, 1.0f,
852 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
854 const int color_count = 3;
855 DlColor colors[color_count] = {
858 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
865 int long_radius = 600;
866 int short_radius = 600;
867 while (long_radius > 0 && short_radius > 0) {
868 paint.
setColor(colors[(c_index++) % color_count]);
870 long_radius * 2, short_radius * 2),
873 short_radius * 2, long_radius * 2),
875 if (short_radius > 30) {
887 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
888 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
889 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
890 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
891 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
902 auto texture = CreateTextureForFixture(
"airplane.jpg",
909 DlPoint(300, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
915 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
916 DlImageSampling::kNearestNeighbor, &local_matrix));
920 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
924struct ArcFarmOptions {
933 const ArcFarmOptions& opts) {
937 const int sweep_limit = opts.sweeps_over_360 ? 420 : 360;
940 for (
int sweep = 30; sweep <= sweep_limit; sweep += 30) {
941 builder.
DrawArc(arc_bounds,
start, opts.full_circles ? 360 : sweep,
942 opts.use_center, paint);
956 for (
int stroke_width = 10; stroke_width <= 40; stroke_width += 3) {
960 for (
int sweep = 160; sweep <= 360; sweep += 20) {
961 builder.
DrawArc(arc_bounds, 0, sweep,
false, modified_paint);
973 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
979 RenderArcFarm(builder, paint,
982 .full_circles =
false,
985 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
990 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
996 RenderArcFarm(builder, paint,
999 .full_circles =
false,
1002 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1007 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1013 RenderArcFarm(builder, paint,
1016 .full_circles =
false,
1019 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1024 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1030 RenderArcFarm(builder, paint,
1032 .use_center =
false,
1033 .full_circles =
false,
1034 .vertical_scale = 0.8f,
1037 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1042 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1048 RenderArcFarm(builder, paint,
1051 .full_circles =
false,
1052 .vertical_scale = 0.8f,
1055 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1060 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1069 RenderArcFarm(builder, paint,
1071 .use_center =
false,
1072 .full_circles =
false,
1075 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1080 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1089 RenderArcFarm(builder, paint,
1091 .use_center =
false,
1092 .full_circles =
false,
1095 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1100 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1108 RenderArcFarmForOverlappingCapsTest(builder, paint);
1110 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1115 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1124 RenderArcFarm(builder, paint,
1126 .use_center =
false,
1127 .full_circles =
false,
1130 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1135 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1143 RenderArcFarmForOverlappingCapsTest(builder, paint);
1145 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1150 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1159 RenderArcFarm(builder, paint,
1162 .full_circles =
false,
1163 .sweeps_over_360 =
true,
1166 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1171 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1183 RenderArcFarm(builder, paint,
1186 .full_circles =
false,
1187 .sweeps_over_360 =
true,
1190 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1195 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1204 RenderArcFarm(builder, paint,
1207 .full_circles =
false,
1208 .sweeps_over_360 =
true,
1211 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1216 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1225 RenderArcFarm(builder, paint,
1227 .use_center =
false,
1228 .full_circles =
false,
1234 RenderArcFarm(builder, paint,
1236 .use_center =
false,
1237 .full_circles =
false,
1240 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1245 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1254 RenderArcFarm(builder, paint,
1256 .use_center =
false,
1257 .full_circles =
false,
1263 RenderArcFarm(builder, paint,
1265 .use_center =
false,
1266 .full_circles =
false,
1272 RenderArcFarm(builder, paint,
1274 .use_center =
false,
1275 .full_circles =
false,
1278 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1294 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1304 RenderArcFarm(builder, paint,
1306 .use_center =
false,
1307 .full_circles =
true,
1313 RenderArcFarm(builder, paint,
1315 .use_center =
false,
1316 .full_circles =
false,
1319 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1324 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1326 const int color_count = 3;
1327 DlColor colors[color_count] = {
1330 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
1337 for (
int i = 0;
i < 4;
i++) {
1338 for (
int j = 0; j < 4; j++) {
1339 paint.
setColor(colors[(c_index++) % color_count]);
1343 i * 5 + 10, j * 5 + 10),
1347 paint.
setColor(colors[(c_index++) % color_count]);
1351 paint.
setColor(colors[(c_index++) % color_count]);
1356 DlColor gradient_colors[7] = {
1359 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1360 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1361 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1362 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1363 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
1374 auto texture = CreateTextureForFixture(
"airplane.jpg",
1380 DlPoint(550, 550), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1381 for (
int i = 1;
i <= 10;
i++) {
1385 550 +
i * 20, 550 + j * 20),
1392 DlPoint(200, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1404 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1405 DlImageSampling::kNearestNeighbor, &local_matrix));
1406 for (
int i = 1;
i <= 10;
i++) {
1410 720 +
i * 20, 220 + j * 20),
1418 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1419 DlImageSampling::kNearestNeighbor, &local_matrix));
1427 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1432 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1439 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f));
1441 for (
int i = 0;
i < 5;
i++) {
1445 radius, 60.0f - radius),
1451 for (
int i = 0;
i < 5;
i++) {
1459 for (
int i = 0;
i < 5;
i++) {
1463 radius, 60.0f - radius),
1468 DlColor::RGBA(128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f));
1470 for (
int i = 0;
i < 5;
i++) {
1480 DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f));
1482 for (
int i = 0;
i < 5;
i++) {
1491 auto dl = builder.
Build();
1492 ASSERT_TRUE(OpenPlaygroundHere(dl));
1498 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1501 std::vector<DlColor> colors = {
DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
1503 std::vector<Scalar> stops = {
1529 builder.
SaveLayer(clip_rect, &save_paint, backdrop_filter.get());
1531 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1537 auto callback = [&]() -> sk_sp<DisplayList> {
1552 DlClipOp::kDifference);
1566 Matrix(1.0, 0.0, 0.0, 0.0,
1568 0.0, 0.0, 1.0, 0.003,
1569 0.0, 0.0, 0.0, 1.0) *
1590 return builder.
Build();
1592 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1610 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1611 DlImageSampling::kNearestNeighbor, &matrix));
1622 Matrix matrix(1, -1, 0, 0,
1627 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1628 DlImageSampling::kNearestNeighbor, &matrix));
1637 builder.
Scale(100, 100);
1642 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1643 DlImageSampling::kNearestNeighbor, &matrix));
1658 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1659 DlImageSampling::kNearestNeighbor, &matrix));
1665 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1687 builder.
SaveLayer(std::nullopt, &paint);
1693 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1699 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1707 builder.
SaveLayer(std::nullopt, &paint);
1714 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1719 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
1721 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1729 DlImageSampling::kNearestNeighbor));
1730 builder.
SaveLayer(std::nullopt, &paint);
1737 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1742 SetWindowSize({400, 400});
1745 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1752 DlImageSampling::kLinear));
1753 builder.SaveLayer(std::nullopt, &paint);
1764 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1769 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1776 builder.
SaveLayer(std::nullopt, &paint);
1779 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1784 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1791 builder.
SaveLayer(std::nullopt, &paint);
1794 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1798 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
1822 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1827 EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1833 GetContext()->GetCapabilities()->GetDefaultColorFormat();
1848 builder.
Scale(0.5, 0.5);
1850 DlImageSampling::kNearestNeighbor);
1859 builder.
SaveLayer(std::nullopt, &alpha);
1872 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1882 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1893 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1915 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1920 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1923 const int color_count = 3;
1924 DlColor colors[color_count] = {
1927 DlColor::ARGB(1.0, 220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f),
1939 for (
int i = 0;
i < 4;
i++) {
1940 for (
int j = 0; j < 4; j++) {
1941 paint.
setColor(colors[(c_index++) % color_count]);
1943 i * 5 + 10, j * 5 + 10, paint);
1946 paint.
setColor(colors[(c_index++) % color_count]);
1948 paint.
setColor(colors[(c_index++) % color_count]);
1951 std::vector<DlColor> gradient_colors = {
1954 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1955 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1956 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1957 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1958 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0)};
1959 std::vector<Scalar> stops = {
1969 CreateTextureForFixture(
"airplane.jpg",
1976 gradient_colors.size(),
1977 gradient_colors.data(),
1979 DlTileMode::kMirror));
1980 for (
int i = 1;
i <= 10;
i++) {
1983 550 +
i * 20, 550 + j * 20),
1984 i * 10, j * 10, paint);
1990 gradient_colors.size(),
1991 gradient_colors.data(),
1993 DlTileMode::kMirror));
2000 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2001 DlImageSampling::kMipmapLinear, &matrix));
2002 for (
int i = 1;
i <= 10;
i++) {
2005 720 +
i * 20, 220 + j * 20),
2006 i * 10, j * 10, paint);
2011 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2012 DlImageSampling::kMipmapLinear, &matrix));
2017 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2021 auto callback = [&]() -> sk_sp<DisplayList> {
2023 builder.
Scale(GetContentScale().x, GetContentScale().y);
2028 auto current =
Point{25, 25};
2029 const auto offset =
Point{25, 25};
2041 builder.
DrawRect(bounds, stroke_paint);
2062 return builder.
Build();
2065 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2080 builder.
SaveLayer(std::nullopt, &save_paint);
2091 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2127 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2157 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2163 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2167 auto draw_image_layer = [&builder, &
texture](
const DlPaint& paint) {
2168 builder.
SaveLayer(std::nullopt, &paint);
2175 draw_image_layer(effect_paint);
2178 builder.
Scale(3, 3);
2179 draw_image_layer(effect_paint);
2181 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2187 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2196 for (
int i = 0;
i < 5;
i++) {
2199 for (
int j = 0; j < 5; j++) {
2201 Scalar x_radius = j * 15;
2205 x_radius, y_radius),
2210 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2218 builder.
SaveLayer(std::nullopt, &paint);
2233 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2241 GTEST_SKIP() <<
"Swiftshader is running out of memory on this example.";
2250 builder.
SaveLayer(std::nullopt, &paint);
2258 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2265 auto callback = [&]() -> sk_sp<DisplayList> {
2267 ImGuiWindowFlags_AlwaysAutoResize)) {
2268 ImGui::SliderFloat(
"width", &
width, 0, 200);
2269 ImGui::SliderFloat(
"height", &
height, 0, 200);
2270 ImGui::SliderFloat(
"corner", &corner, 0, 1);
2275 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2278 background_paint.
setColor(
DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
2282 std::vector<Scalar> stops = {0.0, 1.0};
2286 2, colors.data(), stops.data(),
2287 DlTileMode::kClamp);
2296 Scalar corner_x = ((1 - corner) * 50) + 50;
2297 Scalar corner_y = corner * 50 + 50;
2302 return builder.
Build();
2304 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2326 builder.
SaveLayer(std::nullopt,
nullptr, image_filter.get());
2332 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2336 int perspective = 58;
2337 bool use_clip =
true;
2338 bool diff_clip =
false;
2340 auto callback = [&]() -> sk_sp<DisplayList> {
2342 ImGuiWindowFlags_AlwaysAutoResize)) {
2343 ImGui::SliderInt(
"perspective%", &perspective, 0, 100);
2344 ImGui::Checkbox(
"use clip", &use_clip);
2346 ImGui::Checkbox(
"diff clip", &diff_clip);
2348 ImGui::SetWindowPos(
"Controls", ImVec2(500, 100));
2354 Scalar val = perspective * -0.00005f;
2357 1.0f, 0.0f, 0.0f, 400.0f,
2358 0.0f, 1.0f, 0.0f, 400.0f,
2359 0.0f, 0.0f, 1.0f, 0.0f,
2360 0.0f, val, 0.0f, 2.2f
2366 DlClipOp clip_op = DlClipOp::kIntersect;
2368 clip = clip.Expand(-20);
2369 clip_op = DlClipOp::kDifference;
2379 DlBlendMode::kSrcOver);
2381 return builder.
Build();
2383 ASSERT_TRUE(OpenPlaygroundHere(
callback));
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 ClipRoundRect(const DlRoundRect &rrect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void Rotate(DlScalar degrees) 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 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 & 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 bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
impeller::Scalar DlScalar
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
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)
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)
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()
static constexpr DlColor kTransparent()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kOrange()
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 MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
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)