36 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
44 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
51sk_sp<DisplayList> MakeWideStrokedRects(
Point scale,
52 const DrawRectProc& draw_rect) {
54 builder.
Scale(scale.
x, scale.
y);
94 return builder.
Build();
99 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
108 ASSERT_TRUE(OpenPlaygroundHere(MakeWideStrokedRects(
122 DlImageSampling::kNearestNeighbor, &paint);
123 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
136 DlImageSampling::kNearestNeighbor, &paint);
137 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
149 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
161 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
165bool GenerateMipmap(
const std::shared_ptr<Context>& context,
166 std::shared_ptr<Texture>
texture,
167 std::string_view label) {
168 auto buffer = context->CreateCommandBuffer();
172 auto pass = buffer->CreateBlitPass();
176 pass->GenerateMipmap(std::move(
texture), label);
178 pass->EncodeCommands();
179 return context->GetCommandQueue()->Submit({
buffer}).ok();
182void CanRenderTiledTexture(
AiksTest* aiks_test,
184 Matrix local_matrix = {}) {
185 auto context = aiks_test->GetContext();
186 ASSERT_TRUE(context);
187 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
189 GenerateMipmap(context,
texture,
"table_mountain_nx");
192 image, tile_mode, tile_mode, DlImageSampling::kNearestNeighbor,
200 builder.
Scale(aiks_test->GetContentScale().x, aiks_test->GetContentScale().y);
205 constexpr auto stroke_width = 64;
208 if (tile_mode == DlTileMode::kDecal) {
224 EXPECT_FALSE(
path.IsRect(
nullptr));
225 EXPECT_FALSE(
path.IsOval(
nullptr));
226 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
229 EXPECT_FALSE(
path.IsConvex());
239 constexpr float kConicWeight = 0.707106781f;
242 .ConicCurveTo({300, 300}, {300, 450}, kConicWeight)
243 .ConicCurveTo({300, 600}, {150, 600}, kConicWeight)
244 .ConicCurveTo({0, 600}, {0, 450}, kConicWeight)
245 .ConicCurveTo({0, 300}, {150, 300}, kConicWeight)
250 EXPECT_FALSE(
path.IsRect(
nullptr));
251 EXPECT_FALSE(
path.IsOval(
nullptr));
252 EXPECT_FALSE(
path.IsRoundRect(
nullptr));
255 EXPECT_TRUE(
path.IsConvex());
261 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.
Build()));
266 CanRenderTiledTexture(
this, DlTileMode::kClamp);
270 CanRenderTiledTexture(
this, DlTileMode::kRepeat);
274 CanRenderTiledTexture(
this, DlTileMode::kMirror);
278 CanRenderTiledTexture(
this, DlTileMode::kDecal);
282 CanRenderTiledTexture(
this, DlTileMode::kClamp,
296 source_rect.Shift(image_half_size.
width, image_half_size.
height);
300 DlImageSampling::kNearestNeighbor);
301 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
310 image->GetSize().width * 0.25f,
image->GetSize().height * 0.4f,
311 image->GetSize().width,
image->GetSize().height);
320 DlImageSampling::kNearestNeighbor);
321 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
326 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
377 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
378 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
379 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
380 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
381 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
392 auto texture = CreateTextureForFixture(
"airplane.jpg",
397 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
402 DlImageSampling::kNearestNeighbor));
405 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
423 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
457 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
467 .top_right =
DlSize(25, 50),
468 .bottom_left =
DlSize(25, 50),
469 .bottom_right =
DlSize(50, 25),
476 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
482 Scalar bottom_left = 60.f;
483 Scalar bottom_right = 80.f;
484 auto callback = [&]() -> sk_sp<DisplayList> {
486 ImGuiWindowFlags_AlwaysAutoResize)) {
487 ImGui::SliderFloat(
"top_left", &top_left, 0, 250);
488 ImGui::SliderFloat(
"top_right", &top_right, 0, 250);
489 ImGui::SliderFloat(
"bottom_left", &bottom_left, 0, 250);
490 ImGui::SliderFloat(
"bottom_right", &bottom_right, 0, 250);
500 .top_right =
DlSize(top_right, top_right),
501 .bottom_left =
DlSize(bottom_left, bottom_left),
502 .bottom_right =
DlSize(bottom_right, bottom_right),
508 return builder.
Build();
511 ASSERT_TRUE(OpenPlaygroundHere(
callback));
515 auto medium_turquoise =
516 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
519 builder.
Scale(0.2, 0.2);
521 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
525 auto medium_turquoise =
526 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
528 DlColor::RGBA(255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f);
531 builder.
Scale(0.2, 0.2);
534 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
539 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
587 builder.
DrawRect(thin_tall_rect.
Shift({100, 100}), thin_paint);
589 builder.
DrawRect(thin_wide_rect.
Shift({100, 100}), thin_paint);
598 builder.
DrawRect(thin_tall_rect.
Shift({100, 300}), thin_paint);
600 builder.
DrawRect(thin_wide_rect.
Shift({100, 300}), thin_paint);
610 builder.
DrawRect(thin_tall_rect.
Shift({100, 500}), thin_paint);
612 builder.
DrawRect(thin_wide_rect.
Shift({100, 500}), thin_paint);
622 builder.
DrawRect(thin_tall_rect.
Shift({300, 500}), thin_paint);
624 builder.
DrawRect(thin_wide_rect.
Shift({300, 500}), thin_paint);
661 for (
int i = 0;
i < 15;
i++) {
669 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
674 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
676 const int color_count = 3;
677 DlColor colors[color_count] = {
680 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
689 paint.
setColor(colors[(c_index++) % color_count]);
701 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
702 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
703 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
704 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
705 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
716 auto texture = CreateTextureForFixture(
"airplane.jpg",
721 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
726 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
727 DlImageSampling::kNearestNeighbor, &local_matrix));
730 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
735 static float stroked_radius = 100.0;
736 static float stroke_width = 0.0;
737 static float stroke_width_fine = 2.0;
738 static float stroked_alpha = 255.0;
739 static float stroked_scale[2] = {1.0, 1.0};
742 ImGuiWindowFlags_AlwaysAutoResize)) {
743 ImGui::SliderFloat(
"Stroked Radius", &stroked_radius, 0, 500);
744 ImGui::SliderFloat(
"Stroked Width", &stroke_width, 0, 500);
745 ImGui::SliderFloat(
"Stroked Width Fine", &stroke_width_fine, 0, 5);
746 ImGui::SliderFloat(
"Stroked Alpha", &stroked_alpha, 0, 10.0);
747 ImGui::SliderFloat2(
"Stroked Scale", stroked_scale, 0, 10.0);
754 background_paint.
setColor(
DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
764 builder.
Scale(stroked_scale[0], stroked_scale[1]);
768 return builder.
Build();
771 ASSERT_TRUE(OpenPlaygroundHere(
callback));
776 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
778 const int color_count = 3;
779 DlColor colors[color_count] = {
782 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
790 auto draw = [&paint, &colors, &c_index](
DlCanvas& canvas,
DlPoint center,
792 for (
int i = 0;
i < n;
i++) {
793 paint.
setColor(colors[(c_index++) % color_count]);
794 canvas.DrawCircle(center, r, paint);
801 draw(builder,
DlPoint(10, 10), 2, 2, 14);
803 draw(builder,
DlPoint(10, 10), 35, 10, 56);
808 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
809 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
810 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
811 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
812 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
823 auto texture = CreateTextureForFixture(
"airplane.jpg",
828 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
829 draw(builder,
DlPoint(500, 600), 5, 10, 10);
833 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
834 DlImageSampling::kNearestNeighbor, &local_matrix));
835 draw(builder,
DlPoint(800, 300), 5, 10, 10);
837 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
845 const Scalar k = 0.5522847498f;
864 path_builder.
Close();
868void DrawStrokedAndFilledCirclesWithZoom(
AiksTest* test,
873 builder.
Scale(test->GetContentScale().x, test->GetContentScale().y);
884 DlPath path = ManuallyConstructCirclePath(radius);
886 constexpr Scalar kLeftX = 300.0f;
887 constexpr Scalar kRightX = 680.0f;
888 constexpr Scalar kTopY = 200.0f;
889 constexpr Scalar kBottomY = 580.0f;
894 builder.
Scale(zoom, zoom);
902 builder.
Scale(zoom, zoom);
909 builder.
Scale(zoom, zoom);
917 builder.
Scale(zoom, zoom);
918 builder.
DrawCircle({}, radius + stroke_width * 0.5f, fill_paint);
921 ASSERT_TRUE(test->OpenPlaygroundHere(builder.
Build()));
926 DrawStrokedAndFilledCirclesWithZoom(
this, 80.0f, 2.0f,
931 DrawStrokedAndFilledCirclesWithZoom(
this, 1.0f, 1.0f,
937 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
939 const int color_count = 3;
940 DlColor colors[color_count] = {
943 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
950 int long_radius = 600;
951 int short_radius = 600;
952 while (long_radius > 0 && short_radius > 0) {
953 paint.
setColor(colors[(c_index++) % color_count]);
960 if (short_radius > 30) {
972 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
973 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
974 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
975 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
976 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
987 auto texture = CreateTextureForFixture(
"airplane.jpg",
994 DlPoint(300, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1000 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1001 DlImageSampling::kNearestNeighbor, &local_matrix));
1005 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1009struct ArcFarmOptions {
1018 const ArcFarmOptions& opts) {
1022 const int sweep_limit = opts.sweeps_over_360 ? 420 : 360;
1025 for (
int sweep = 30; sweep <= sweep_limit; sweep += 30) {
1026 builder.
DrawArc(arc_bounds,
start, opts.full_circles ? 360 : sweep,
1027 opts.use_center, paint);
1041 for (
int stroke_width = 10; stroke_width <= 40; stroke_width += 3) {
1045 for (
int sweep = 160; sweep <= 360; sweep += 20) {
1046 builder.
DrawArc(arc_bounds, 0, sweep,
false, modified_paint);
1050 builder.
Translate(0, 44 + stroke_width);
1058 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1064 RenderArcFarm(builder, paint,
1066 .use_center =
false,
1067 .full_circles =
false,
1070 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1075 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1081 RenderArcFarm(builder, paint,
1083 .use_center =
false,
1084 .full_circles =
false,
1087 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1092 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1098 RenderArcFarm(builder, paint,
1101 .full_circles =
false,
1104 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1109 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1115 RenderArcFarm(builder, paint,
1117 .use_center =
false,
1118 .full_circles =
false,
1119 .vertical_scale = 0.8f,
1122 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1127 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1133 RenderArcFarm(builder, paint,
1136 .full_circles =
false,
1137 .vertical_scale = 0.8f,
1140 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1145 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1154 RenderArcFarm(builder, paint,
1156 .use_center =
false,
1157 .full_circles =
false,
1160 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1165 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1174 RenderArcFarm(builder, paint,
1176 .use_center =
false,
1177 .full_circles =
false,
1180 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1185 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1193 RenderArcFarmForOverlappingCapsTest(builder, paint);
1195 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1200 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1209 RenderArcFarm(builder, paint,
1211 .use_center =
false,
1212 .full_circles =
false,
1215 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1220 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1228 RenderArcFarmForOverlappingCapsTest(builder, paint);
1230 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1235 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1244 RenderArcFarm(builder, paint,
1247 .full_circles =
false,
1248 .sweeps_over_360 =
true,
1251 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1256 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1268 RenderArcFarm(builder, paint,
1271 .full_circles =
false,
1272 .sweeps_over_360 =
true,
1275 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1280 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1289 RenderArcFarm(builder, paint,
1292 .full_circles =
false,
1293 .sweeps_over_360 =
true,
1296 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1301 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1310 RenderArcFarm(builder, paint,
1312 .use_center =
false,
1313 .full_circles =
false,
1319 RenderArcFarm(builder, paint,
1321 .use_center =
false,
1322 .full_circles =
false,
1325 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1330 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1339 RenderArcFarm(builder, paint,
1341 .use_center =
false,
1342 .full_circles =
false,
1348 RenderArcFarm(builder, paint,
1350 .use_center =
false,
1351 .full_circles =
false,
1357 RenderArcFarm(builder, paint,
1359 .use_center =
false,
1360 .full_circles =
false,
1363 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1379 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1389 RenderArcFarm(builder, paint,
1391 .use_center =
false,
1392 .full_circles =
true,
1398 RenderArcFarm(builder, paint,
1400 .use_center =
false,
1401 .full_circles =
false,
1404 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1409 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1411 const int color_count = 3;
1412 DlColor colors[color_count] = {
1415 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
1422 for (
int i = 0;
i < 4;
i++) {
1423 for (
int j = 0; j < 4; j++) {
1424 paint.
setColor(colors[(c_index++) % color_count]);
1428 i * 5 + 10, j * 5 + 10),
1432 paint.
setColor(colors[(c_index++) % color_count]);
1436 paint.
setColor(colors[(c_index++) % color_count]);
1441 DlColor gradient_colors[7] = {
1444 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1445 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1446 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1447 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1448 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
1459 auto texture = CreateTextureForFixture(
"airplane.jpg",
1465 DlPoint(550, 550), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1466 for (
int i = 1;
i <= 10;
i++) {
1470 550 +
i * 20, 550 + j * 20),
1477 DlPoint(200, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
1489 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1490 DlImageSampling::kNearestNeighbor, &local_matrix));
1491 for (
int i = 1;
i <= 10;
i++) {
1495 720 +
i * 20, 220 + j * 20),
1503 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
1504 DlImageSampling::kNearestNeighbor, &local_matrix));
1512 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1517 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1524 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f));
1526 for (
int i = 0;
i < 5;
i++) {
1530 radius, 60.0f - radius),
1536 for (
int i = 0;
i < 5;
i++) {
1544 for (
int i = 0;
i < 5;
i++) {
1548 radius, 60.0f - radius),
1553 DlColor::RGBA(128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f));
1555 for (
int i = 0;
i < 5;
i++) {
1565 DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f));
1567 for (
int i = 0;
i < 5;
i++) {
1576 auto dl = builder.
Build();
1577 ASSERT_TRUE(OpenPlaygroundHere(dl));
1583 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1586 std::vector<DlColor> colors = {
DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
1588 std::vector<Scalar> stops = {
1614 builder.
SaveLayer(clip_rect, &save_paint, backdrop_filter.get());
1616 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1622 auto callback = [&]() -> sk_sp<DisplayList> {
1637 DlClipOp::kDifference);
1651 Matrix(1.0, 0.0, 0.0, 0.0,
1653 0.0, 0.0, 1.0, 0.003,
1654 0.0, 0.0, 0.0, 1.0) *
1675 return builder.
Build();
1677 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1695 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1696 DlImageSampling::kNearestNeighbor, &matrix));
1707 Matrix matrix(1, -1, 0, 0,
1712 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1713 DlImageSampling::kNearestNeighbor, &matrix));
1722 builder.
Scale(100, 100);
1727 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1728 DlImageSampling::kNearestNeighbor, &matrix));
1743 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1744 DlImageSampling::kNearestNeighbor, &matrix));
1750 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1772 builder.
SaveLayer(std::nullopt, &paint);
1778 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1784 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1792 builder.
SaveLayer(std::nullopt, &paint);
1799 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1804 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
1806 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1814 DlImageSampling::kNearestNeighbor));
1815 builder.
SaveLayer(std::nullopt, &paint);
1822 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1827 SetWindowSize({400, 400});
1830 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1837 DlImageSampling::kLinear));
1838 builder.SaveLayer(std::nullopt, &paint);
1849 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1854 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1861 builder.
SaveLayer(std::nullopt, &paint);
1864 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1869 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1876 builder.
SaveLayer(std::nullopt, &paint);
1879 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1883 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
1907 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1912 EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1918 GetContext()->GetCapabilities()->GetDefaultColorFormat();
1933 builder.
Scale(0.5, 0.5);
1935 DlImageSampling::kNearestNeighbor);
1944 builder.
SaveLayer(std::nullopt, &alpha);
1957 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1967 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1978 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2000 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2005 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2008 const int color_count = 3;
2009 DlColor colors[color_count] = {
2012 DlColor::ARGB(1.0, 220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f),
2024 for (
int i = 0;
i < 4;
i++) {
2025 for (
int j = 0; j < 4; j++) {
2026 paint.
setColor(colors[(c_index++) % color_count]);
2028 i * 5 + 10, j * 5 + 10, paint);
2031 paint.
setColor(colors[(c_index++) % color_count]);
2033 paint.
setColor(colors[(c_index++) % color_count]);
2036 std::vector<DlColor> gradient_colors = {
2039 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
2040 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
2041 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
2042 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
2043 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0)};
2044 std::vector<Scalar> stops = {
2054 CreateTextureForFixture(
"airplane.jpg",
2061 gradient_colors.size(),
2062 gradient_colors.data(),
2064 DlTileMode::kMirror));
2065 for (
int i = 1;
i <= 10;
i++) {
2068 550 +
i * 20, 550 + j * 20),
2069 i * 10, j * 10, paint);
2075 gradient_colors.size(),
2076 gradient_colors.data(),
2078 DlTileMode::kMirror));
2085 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2086 DlImageSampling::kMipmapLinear, &matrix));
2087 for (
int i = 1;
i <= 10;
i++) {
2090 720 +
i * 20, 220 + j * 20),
2091 i * 10, j * 10, paint);
2096 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
2097 DlImageSampling::kMipmapLinear, &matrix));
2102 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2106 auto callback = [&]() -> sk_sp<DisplayList> {
2108 builder.
Scale(GetContentScale().x, GetContentScale().y);
2113 auto current =
Point{25, 25};
2114 const auto offset =
Point{25, 25};
2126 builder.
DrawRect(bounds, stroke_paint);
2147 return builder.
Build();
2150 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2165 builder.
SaveLayer(std::nullopt, &save_paint);
2176 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2212 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2242 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2248 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2252 auto draw_image_layer = [&builder, &
texture](
const DlPaint& paint) {
2253 builder.
SaveLayer(std::nullopt, &paint);
2260 draw_image_layer(effect_paint);
2263 builder.
Scale(3, 3);
2264 draw_image_layer(effect_paint);
2266 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2272 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2281 for (
int i = 0;
i < 5;
i++) {
2284 for (
int j = 0; j < 5; j++) {
2286 Scalar x_radius = j * 15;
2290 x_radius, y_radius),
2295 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2303 builder.
SaveLayer(std::nullopt, &paint);
2318 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2326 GTEST_SKIP() <<
"Swiftshader is running out of memory on this example.";
2335 builder.
SaveLayer(std::nullopt, &paint);
2343 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2350 bool stroked =
true;
2351 auto callback = [&]() -> sk_sp<DisplayList> {
2353 ImGuiWindowFlags_AlwaysAutoResize)) {
2354 ImGui::SliderFloat(
"width", &
width, 0, 200);
2355 ImGui::SliderFloat(
"height", &
height, 0, 200);
2356 ImGui::SliderFloat(
"corner", &corner, 0, 1);
2357 ImGui::Checkbox(
"stroked", &stroked);
2362 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
2365 background_paint.
setColor(
DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
2369 std::vector<Scalar> stops = {0.0, 1.0};
2373 2, colors.data(), stops.data(),
2374 DlTileMode::kClamp);
2387 Scalar corner_x = ((1 - corner) * 50) + 50;
2388 Scalar corner_y = corner * 50 + 50;
2393 return builder.
Build();
2395 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2417 builder.
SaveLayer(std::nullopt,
nullptr, image_filter.get());
2423 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2427 int perspective = 58;
2428 bool use_clip =
true;
2429 bool diff_clip =
false;
2431 auto callback = [&]() -> sk_sp<DisplayList> {
2433 ImGuiWindowFlags_AlwaysAutoResize)) {
2434 ImGui::SliderInt(
"perspective%", &perspective, 0, 100);
2435 ImGui::Checkbox(
"use clip", &use_clip);
2437 ImGui::Checkbox(
"diff clip", &diff_clip);
2439 ImGui::SetWindowPos(
"Controls", ImVec2(500, 100));
2445 Scalar val = perspective * -0.00005f;
2448 1.0f, 0.0f, 0.0f, 400.0f,
2449 0.0f, 1.0f, 0.0f, 400.0f,
2450 0.0f, 0.0f, 1.0f, 0.0f,
2451 0.0f, val, 0.0f, 2.2f
2457 DlClipOp clip_op = DlClipOp::kIntersect;
2459 clip = clip.Expand(-20);
2460 clip_op = DlClipOp::kDifference;
2470 DlBlendMode::kSrcOver);
2472 return builder.
Build();
2474 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2499 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2526 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2551 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2578 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2587 DlScalar radii[] = {10.0f, 30.0f, 50.0f};
2589 for (
int row = 0; row < 3; row++) {
2610 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2620 builder.
Scale(1.5f, 0.8f);
2630 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2647 DlImageSampling::kNearestNeighbor));
2648 builder.
SaveLayer(bounds, &layer_paint_left);
2661 DlImageSampling::kNearestNeighbor));
2662 builder.
SaveLayer(bounds, &layer_paint_right);
2670 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
2679 .top_right =
DlSize(10.0f),
2680 .bottom_left =
DlSize(20.0f),
2681 .bottom_right =
DlSize(50.0f)};
2704 DlPaint().setBlendMode(DlBlendMode::kClear));
2706 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 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 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
@ 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)
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()
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 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)