5 #include "display_list/display_list.h"
6 #include "display_list/dl_sampling_options.h"
7 #include "display_list/dl_tile_mode.h"
8 #include "display_list/effects/dl_color_filter.h"
9 #include "display_list/effects/dl_color_source.h"
10 #include "display_list/effects/dl_image_filter.h"
11 #include "display_list/effects/dl_mask_filter.h"
14 #include "flutter/display_list/dl_blend_mode.h"
15 #include "flutter/display_list/dl_builder.h"
16 #include "flutter/display_list/dl_color.h"
17 #include "flutter/display_list/dl_paint.h"
20 #include "flutter/testing/display_list_testing.h"
21 #include "flutter/testing/testing.h"
30 DisplayListBuilder builder;
32 paint.setColor(DlColor::kBlue());
33 builder.DrawPath(DlPath::MakeRectXYWH(100.0f, 100.0f, 100.0f, 100.0f), paint);
34 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
38 DisplayListBuilder builder;
40 paint.setColor(DlColor::kRed());
42 builder.DrawImage(image,
DlPoint(100.0, 100.0),
43 DlImageSampling::kNearestNeighbor, &paint);
44 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
48 DisplayListBuilder builder;
50 paint.setColor(DlColor::kRed());
52 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
53 paint.setInvertColors(
true);
56 builder.DrawImage(image,
DlPoint(100.0, 100.0),
57 DlImageSampling::kNearestNeighbor, &paint);
58 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
62 DisplayListBuilder builder;
64 paint.setColor(DlColor::kRed());
66 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
67 paint.setInvertColors(
true);
69 builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), paint);
70 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
74 DisplayListBuilder builder;
76 paint.setColor(DlColor::kRed());
78 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
79 paint.setInvertColors(
true);
81 builder.DrawPaint(paint);
82 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
86 bool GenerateMipmap(
const std::shared_ptr<Context>& context,
87 std::shared_ptr<Texture> texture,
88 std::string_view label) {
89 auto buffer = context->CreateCommandBuffer();
93 auto pass = buffer->CreateBlitPass();
97 pass->GenerateMipmap(std::move(texture), label);
99 pass->EncodeCommands();
100 return context->GetCommandQueue()->Submit({buffer}).ok();
103 void CanRenderTiledTexture(
AiksTest* aiks_test,
104 DlTileMode tile_mode,
105 Matrix local_matrix = {}) {
106 auto context = aiks_test->GetContext();
107 ASSERT_TRUE(context);
108 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
110 GenerateMipmap(context, texture,
"table_mountain_nx");
112 auto color_source = DlColorSource::MakeImage(
113 image, tile_mode, tile_mode, DlImageSampling::kNearestNeighbor,
116 DisplayListBuilder builder;
118 paint.setColor(DlColor::kWhite());
119 paint.setColorSource(color_source);
121 builder.Scale(aiks_test->GetContentScale().x, aiks_test->GetContentScale().y);
122 builder.Translate(100.0f, 100.0f);
123 builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
127 paint.setDrawStyle(DlDrawStyle::kStroke);
129 if (tile_mode == DlTileMode::kDecal) {
133 builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
138 DlPathBuilder path_builder;
139 path_builder.AddCircle(
DlPoint(150, 150), 150);
140 path_builder.AddRoundRect(
142 DlPath path(path_builder);
145 EXPECT_FALSE(path.IsRect(
nullptr));
146 EXPECT_FALSE(path.IsOval(
nullptr));
147 EXPECT_FALSE(path.IsRoundRect(
nullptr));
150 EXPECT_FALSE(path.IsConvex());
152 paint.setDrawStyle(DlDrawStyle::kFill);
153 builder.DrawPath(path, paint);
161 EXPECT_TRUE(circle.IsOval(
nullptr));
163 EXPECT_TRUE(circle.IsConvex());
166 DlPathBuilder path_builder;
169 path_builder.MoveTo({10, 10});
170 path_builder.AddPath(circle.GetPath());
172 DlPath path(path_builder);
175 EXPECT_FALSE(path.IsRect(
nullptr));
176 EXPECT_FALSE(path.IsOval(
nullptr));
177 EXPECT_FALSE(path.IsRoundRect(
nullptr));
180 EXPECT_TRUE(path.GetPath().IsConvex());
182 paint.setDrawStyle(DlDrawStyle::kFill);
183 builder.DrawPath(path, paint);
186 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
191 CanRenderTiledTexture(
this, DlTileMode::kClamp);
195 CanRenderTiledTexture(
this, DlTileMode::kRepeat);
199 CanRenderTiledTexture(
this, DlTileMode::kMirror);
203 CanRenderTiledTexture(
this, DlTileMode::kDecal);
207 CanRenderTiledTexture(
this, DlTileMode::kClamp,
212 DisplayListBuilder builder;
215 DlISize image_half_size = DlISize(image->dimensions().fWidth * 0.5f,
216 image->dimensions().fHeight * 0.5f);
219 auto source_rect = DlRect::MakeSize(image_half_size);
221 source_rect.Shift(image_half_size.width, image_half_size.height);
223 builder.DrawImageRect(image, source_rect,
224 DlRect::MakeXYWH(100, 100, 600, 600),
225 DlImageSampling::kNearestNeighbor);
226 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
230 DisplayListBuilder builder;
234 auto source_rect = DlRect::MakeXYWH(
235 image->dimensions().fWidth * 0.25f, image->dimensions().fHeight * 0.4f,
236 image->dimensions().fWidth, image->dimensions().fHeight);
238 auto dest_rect = DlRect::MakeXYWH(100, 100, 600, 600);
241 paint.setColor(DlColor::kMidGrey());
242 builder.DrawRect(dest_rect, paint);
244 builder.DrawImageRect(image, source_rect, dest_rect,
245 DlImageSampling::kNearestNeighbor);
246 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
250 DisplayListBuilder builder;
251 builder.Scale(GetContentScale().
x, GetContentScale().y);
254 paint.setColor(DlColor::kWhite());
255 builder.DrawPaint(paint);
257 auto draw = [&builder](
const DlPaint& paint,
Scalar x,
Scalar y) {
259 builder.Translate(
x, y);
262 builder.ClipRect(DlRect::MakeLTRB(50, 50, 150, 150));
263 builder.DrawPaint(paint);
268 builder.ClipOval(DlRect::MakeLTRB(200, 50, 300, 150));
269 builder.DrawPaint(paint);
274 builder.ClipRoundRect(
275 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(50, 200, 150, 300), 20, 20));
276 builder.DrawPaint(paint);
281 builder.ClipRoundRect(DlRoundRect::MakeRectXY(
282 DlRect::MakeLTRB(200, 230, 300, 270), 20, 20));
283 builder.DrawPaint(paint);
288 builder.ClipRoundRect(DlRoundRect::MakeRectXY(
289 DlRect::MakeLTRB(230, 200, 270, 300), 20, 20));
290 builder.DrawPaint(paint);
296 paint.setColor(DlColor::kBlue());
299 DlColor gradient_colors[7] = {
300 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
301 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
302 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
303 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
304 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
305 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
306 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
317 auto texture = CreateTextureForFixture(
"airplane.jpg",
321 paint.setColorSource(DlColorSource::MakeRadial(
322 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
325 paint.setColorSource(
326 DlColorSource::MakeImage(image, DlTileMode::kRepeat, DlTileMode::kRepeat,
327 DlImageSampling::kNearestNeighbor));
330 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
334 DisplayListBuilder builder;
337 red.setColor(DlColor::kRed());
340 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
342 builder.SaveLayer(std::nullopt, &alpha);
344 builder.DrawCircle(
DlPoint(125, 125), 125, red);
348 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
352 DisplayListBuilder builder;
355 DlColor colors[2] = {
356 DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
357 DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0),
364 paint.setColorSource(DlColorSource::MakeLinear(
374 builder.Translate(100, 100);
375 builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), paint);
379 builder.Translate(100, 400);
380 builder.DrawCircle(
DlPoint(100, 100), 100, paint);
382 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
386 DisplayListBuilder builder;
388 paint.setColor(DlColor::kRed());
392 .top_right = DlSize(25, 50),
393 .bottom_left = DlSize(25, 50),
394 .bottom_right = DlSize(50, 25),
397 DlRoundRect::MakeRectRadii(DlRect::MakeXYWH(100, 100, 500, 500), radii);
399 builder.DrawRoundRect(rrect, paint);
401 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
405 auto medium_turquoise =
406 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
408 DisplayListBuilder builder;
409 builder.Scale(0.2, 0.2);
410 builder.DrawPaint(DlPaint().setColor(medium_turquoise));
411 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
415 auto medium_turquoise =
416 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
418 DlColor::RGBA(255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f);
420 DisplayListBuilder builder;
421 builder.Scale(0.2, 0.2);
422 builder.DrawPaint(DlPaint().setColor(medium_turquoise));
423 builder.DrawPaint(DlPaint().setColor(orange_red.modulateOpacity(0.5f)));
424 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
428 DisplayListBuilder builder;
429 builder.Scale(GetContentScale().
x, GetContentScale().y);
431 const int color_count = 3;
432 DlColor colors[color_count] = {
435 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
438 paint.setColor(DlColor::kWhite());
439 builder.DrawPaint(paint);
444 paint.setColor(colors[(c_index++) % color_count]);
445 builder.DrawCircle(
DlPoint(10, 10), radius, paint);
453 DlColor gradient_colors[7] = {
454 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
455 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
456 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
457 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
458 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
459 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
460 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
471 auto texture = CreateTextureForFixture(
"airplane.jpg",
475 paint.setColorSource(DlColorSource::MakeRadial(
476 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
477 builder.DrawCircle(
DlPoint(500, 600), 100, paint);
479 DlMatrix local_matrix = DlMatrix::MakeTranslation({700, 200});
480 paint.setColorSource(DlColorSource::MakeImage(
481 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
482 DlImageSampling::kNearestNeighbor, &local_matrix));
483 builder.DrawCircle(
DlPoint(800, 300), 100, paint);
485 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
489 DisplayListBuilder builder;
490 builder.Scale(GetContentScale().
x, GetContentScale().y);
492 const int color_count = 3;
493 DlColor colors[color_count] = {
496 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
499 paint.setColor(DlColor::kWhite());
500 builder.DrawPaint(paint);
504 auto draw = [&paint, &colors, &c_index](DlCanvas& canvas,
DlPoint center,
506 for (
int i = 0; i < n; i++) {
507 paint.setColor(colors[(c_index++) % color_count]);
508 canvas.DrawCircle(center, r, paint);
513 paint.setDrawStyle(DlDrawStyle::kStroke);
514 paint.setStrokeWidth(1);
515 draw(builder,
DlPoint(10, 10), 2, 2, 14);
516 paint.setStrokeWidth(5);
517 draw(builder,
DlPoint(10, 10), 35, 10, 56);
519 DlColor gradient_colors[7] = {
520 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
521 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
522 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
523 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
524 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
525 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
526 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
537 auto texture = CreateTextureForFixture(
"airplane.jpg",
541 paint.setColorSource(DlColorSource::MakeRadial(
542 DlPoint(500, 600), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
543 draw(builder,
DlPoint(500, 600), 5, 10, 10);
545 DlMatrix local_matrix = DlMatrix::MakeTranslation({700, 200});
546 paint.setColorSource(DlColorSource::MakeImage(
547 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
548 DlImageSampling::kNearestNeighbor, &local_matrix));
549 draw(builder,
DlPoint(800, 300), 5, 10, 10);
551 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
555 DisplayListBuilder builder;
556 builder.Scale(GetContentScale().
x, GetContentScale().y);
558 const int color_count = 3;
559 DlColor colors[color_count] = {
562 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
565 paint.setColor(DlColor::kWhite());
566 builder.DrawPaint(paint);
569 int long_radius = 600;
570 int short_radius = 600;
571 while (long_radius > 0 && short_radius > 0) {
572 paint.setColor(colors[(c_index++) % color_count]);
573 builder.DrawOval(DlRect::MakeXYWH(10 - long_radius, 10 - short_radius,
574 long_radius * 2, short_radius * 2),
576 builder.DrawOval(DlRect::MakeXYWH(1000 - short_radius, 750 - long_radius,
577 short_radius * 2, long_radius * 2),
579 if (short_radius > 30) {
588 DlColor gradient_colors[7] = {
589 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
590 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
591 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
592 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
593 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
594 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
595 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
606 auto texture = CreateTextureForFixture(
"airplane.jpg",
610 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
612 paint.setColorSource(DlColorSource::MakeRadial(
613 DlPoint(300, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
614 builder.DrawOval(DlRect::MakeXYWH(200, 625, 200, 50), paint);
615 builder.DrawOval(DlRect::MakeXYWH(275, 550, 50, 200), paint);
617 DlMatrix local_matrix = DlMatrix::MakeTranslation({610, 15});
618 paint.setColorSource(DlColorSource::MakeImage(
619 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
620 DlImageSampling::kNearestNeighbor, &local_matrix));
621 builder.DrawOval(DlRect::MakeXYWH(610, 90, 200, 50), paint);
622 builder.DrawOval(DlRect::MakeXYWH(685, 15, 50, 200), paint);
624 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
628 DisplayListBuilder builder;
629 builder.Scale(GetContentScale().
x, GetContentScale().y);
631 const int color_count = 3;
632 DlColor colors[color_count] = {
635 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
638 paint.setColor(DlColor::kWhite());
639 builder.DrawPaint(paint);
642 for (
int i = 0; i < 4; i++) {
643 for (
int j = 0; j < 4; j++) {
644 paint.setColor(colors[(c_index++) % color_count]);
645 builder.DrawRoundRect(
646 DlRoundRect::MakeRectXY(
647 DlRect::MakeXYWH(i * 100 + 10, j * 100 + 20, 80, 80),
648 i * 5 + 10, j * 5 + 10),
652 paint.setColor(colors[(c_index++) % color_count]);
653 builder.DrawRoundRect(
654 DlRoundRect::MakeRectXY(DlRect::MakeXYWH(10, 420, 380, 80), 40, 40),
656 paint.setColor(colors[(c_index++) % color_count]);
657 builder.DrawRoundRect(
658 DlRoundRect::MakeRectXY(DlRect::MakeXYWH(410, 20, 80, 380), 40, 40),
661 DlColor gradient_colors[7] = {
662 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
663 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
664 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
665 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
666 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
667 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
668 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
679 auto texture = CreateTextureForFixture(
"airplane.jpg",
683 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
684 paint.setColorSource(DlColorSource::MakeRadial(
685 DlPoint(550, 550), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
686 for (
int i = 1; i <= 10; i++) {
688 builder.DrawRoundRect(
689 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(550 - i * 20, 550 - j * 20,
690 550 + i * 20, 550 + j * 20),
695 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
696 paint.setColorSource(DlColorSource::MakeRadial(
697 DlPoint(200, 650), 75, 7, gradient_colors, stops, DlTileMode::kMirror));
698 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
699 builder.DrawRoundRect(
700 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(100, 610, 300, 690), 40, 40),
702 builder.DrawRoundRect(
703 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(160, 550, 240, 750), 40, 40),
706 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
707 DlMatrix local_matrix = DlMatrix::MakeTranslation({520, 20});
708 paint.setColorSource(DlColorSource::MakeImage(
709 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
710 DlImageSampling::kNearestNeighbor, &local_matrix));
711 for (
int i = 1; i <= 10; i++) {
713 builder.DrawRoundRect(
714 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(720 - i * 20, 220 - j * 20,
715 720 + i * 20, 220 + j * 20),
720 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
721 local_matrix = DlMatrix::MakeTranslation({800, 300});
722 paint.setColorSource(DlColorSource::MakeImage(
723 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
724 DlImageSampling::kNearestNeighbor, &local_matrix));
725 builder.DrawRoundRect(
726 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(800, 410, 1000, 490), 40, 40),
728 builder.DrawRoundRect(
729 DlRoundRect::MakeRectXY(DlRect::MakeLTRB(860, 350, 940, 550), 40, 40),
732 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
736 DisplayListBuilder builder;
737 builder.Scale(GetContentScale().
x, GetContentScale().y);
739 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 1.0f));
741 builder.DrawPaint(DlPaint().setColor(DlColor::kWhite()));
744 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f));
746 for (
int i = 0; i < 5; i++) {
749 builder.DrawRect(DlRect::MakeXYWH(
x + 25 - radius / 2, y + radius / 2,
750 radius, 60.0f - radius),
754 paint.setColor(DlColor::kBlue());
756 for (
int i = 0; i < 5; i++) {
759 builder.DrawCircle(
DlPoint(
x + 25, y + 25), radius, paint);
762 paint.setColor(DlColor::kGreen());
764 for (
int i = 0; i < 5; i++) {
767 builder.DrawOval(DlRect::MakeXYWH(
x + 25 - radius / 2, y + radius / 2,
768 radius, 60.0f - radius),
773 DlColor::RGBA(128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f));
775 for (
int i = 0; i < 5; i++) {
778 builder.DrawRoundRect(
779 DlRoundRect::MakeRectXY(DlRect::MakeXYWH(
x, y, 60.0f, 60.0f),
785 DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f));
787 for (
int i = 0; i < 5; i++) {
790 builder.DrawRoundRect(
791 DlRoundRect::MakeRectXY(DlRect::MakeXYWH(
x, y, 60.0f, 60.0f),
796 auto dl = builder.Build();
797 ASSERT_TRUE(OpenPlaygroundHere(dl));
801 DisplayListBuilder builder;
803 builder.Scale(GetContentScale().
x, GetContentScale().y);
806 std::vector<DlColor> colors = {DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
807 DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0)};
808 std::vector<Scalar> stops = {
813 paint.setColorSource(DlColorSource::MakeLinear(
822 builder.DrawPaint(paint);
824 DlRect clip_rect = DlRect::MakeLTRB(50, 50, 400, 300);
825 DlRoundRect clip_rrect = DlRoundRect::MakeRectXY(clip_rect, 100, 100);
829 builder.ClipRoundRect(clip_rrect, DlClipOp::kIntersect);
832 auto backdrop_filter = DlImageFilter::MakeColorFilter(
833 DlColorFilter::MakeBlend(DlColor::kRed(), DlBlendMode::kExclusion));
834 builder.SaveLayer(clip_rect, &save_paint, backdrop_filter.get());
836 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
842 auto callback = [&]() -> sk_sp<DisplayList> {
843 DisplayListBuilder builder;
847 builder.Translate(300, 300);
854 paint.setColor(DlColor::kGreen());
855 builder.DrawPaint(paint);
856 builder.ClipRect(DlRect::MakeLTRB(-180, -180, 180, 180),
857 DlClipOp::kDifference);
859 paint.setColor(DlColor::kBlack());
860 builder.DrawPaint(paint);
868 builder.ClipOval(DlRect::MakeLTRB(-200, -200, 200, 200));
871 Matrix(1.0, 0.0, 0.0, 0.0,
873 0.0, 0.0, 1.0, 0.003,
874 0.0, 0.0, 0.0, 1.0) *
883 -
DlPoint(image->dimensions().fWidth, image->dimensions().fHeight) *
885 builder.DrawImage(image, position, {});
891 paint.setColor(DlColor::kBlue().modulateOpacity(0.4));
892 builder.DrawCircle(
DlPoint(), 230, paint);
896 return builder.Build();
898 ASSERT_TRUE(OpenPlaygroundHere(callback));
904 DisplayListBuilder builder;
908 paint.setColor(DlColor::kWhite());
909 builder.DrawPaint(paint);
913 DlMatrix matrix = DlMatrix::MakeTranslation({50, 50});
915 paint.setColorSource(DlColorSource::MakeImage(
916 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
917 DlImageSampling::kNearestNeighbor, &matrix));
919 builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), paint);
928 Matrix matrix(1, -1, 0, 0,
932 paint.setColorSource(DlColorSource::MakeImage(
933 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
934 DlImageSampling::kNearestNeighbor, &matrix));
935 builder.DrawRect(DlRect::MakeLTRB(100, 0, 200, 100), paint);
942 builder.Translate(100, 0);
943 builder.Scale(100, 100);
946 DlMatrix matrix = DlMatrix::MakeScale({0.005, 0.005, 1});
947 paint.setColorSource(DlColorSource::MakeImage(
948 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
949 DlImageSampling::kNearestNeighbor, &matrix));
951 builder.DrawRect(DlRect::MakeLTRB(0, 0, 1, 1), paint);
958 builder.Translate(150, 150);
962 DlMatrix::MakePerspective(
Radians{0.5},
ISize{200, 200}, 0.05, 1);
963 paint.setColorSource(DlColorSource::MakeImage(
964 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
965 DlImageSampling::kNearestNeighbor, &matrix));
967 builder.DrawRect(DlRect::MakeLTRB(0, 0, 200, 200), paint);
971 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
975 DisplayListBuilder builder;
980 paint.setColor(DlColor::kBlue().modulateOpacity(0.5));
981 paint.setBlendMode(DlBlendMode::kSrc);
983 DlRect bounds = DlRect::MakeLTRB(0, 0, 200, 200);
984 builder.SaveLayer(bounds, &paint);
986 paint.setColor(DlColor::kTransparent());
987 paint.setBlendMode(DlBlendMode::kSrc);
988 builder.DrawPaint(paint);
991 paint.setColor(DlColor::kBlue());
992 paint.setBlendMode(DlBlendMode::kDstOver);
993 builder.SaveLayer(std::nullopt, &paint);
999 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1004 DisplayListBuilder builder;
1005 builder.Scale(GetContentScale().
x, GetContentScale().y);
1006 builder.Translate(100, 100);
1010 DlMatrix translate = DlMatrix::MakeTranslation({300, 0});
1011 paint.setImageFilter(
1012 DlImageFilter::MakeMatrix(translate, DlImageSampling::kLinear));
1013 builder.SaveLayer(std::nullopt, &paint);
1015 DlPaint circle_paint;
1016 circle_paint.setColor(DlColor::kGreen());
1017 builder.DrawCircle(
DlPoint(-300, 0), 100, circle_paint);
1020 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1025 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
1026 DisplayListBuilder builder;
1027 builder.Scale(GetContentScale().
x, GetContentScale().y);
1028 builder.Translate(100, 100);
1033 paint.setImageFilter(DlImageFilter::MakeMatrix(
1034 DlMatrix::MakeTranslation({300, 0}) * DlMatrix::MakeScale({2, 2, 1}),
1035 DlImageSampling::kNearestNeighbor));
1036 builder.SaveLayer(std::nullopt, &paint);
1038 DlPaint circle_paint;
1039 circle_paint.setColor(DlColor::kGreen());
1040 builder.DrawCircle(
DlPoint(-150, 0), 50, circle_paint);
1043 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1048 SetWindowSize({400, 400});
1049 DisplayListBuilder builder;
1051 builder.Scale(GetContentScale().
x, GetContentScale().y);
1054 paint.setColor(DlColor::kRed());
1055 builder.DrawRect(DlRect::MakeLTRB(200, 200, 300, 300), paint);
1057 paint.setImageFilter(DlImageFilter::MakeMatrix(DlMatrix::MakeScale({2, 2, 1}),
1058 DlImageSampling::kLinear));
1059 builder.SaveLayer(std::nullopt, &paint);
1062 paint.setColor(DlColor::kGreen());
1063 builder.DrawRect(DlRect::MakeLTRB(0, 0, 400, 400), paint);
1066 paint.setColor(DlColor::kRed());
1067 builder.DrawRect(DlRect::MakeLTRB(0, 0, 800, 800), paint);
1070 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1074 DisplayListBuilder builder;
1075 builder.Scale(GetContentScale().
x, GetContentScale().y);
1078 paint.setColor(DlColor::kRed());
1079 builder.DrawPaint(paint);
1080 builder.ClipRect(DlRect::MakeXYWH(100, 100, 200, 200));
1081 paint.setColor(DlColor::kBlue());
1082 builder.SaveLayer(std::nullopt, &paint);
1085 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1089 DisplayListBuilder builder;
1090 builder.Scale(GetContentScale().
x, GetContentScale().y);
1092 builder.DrawImage(image,
DlPoint(10, 10), {});
1093 builder.ClipRect(DlRect::MakeXYWH(100, 100, 200, 200));
1096 paint.setBlendMode(DlBlendMode::kClear);
1097 builder.SaveLayer(std::nullopt, &paint);
1100 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1104 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
1105 DisplayListBuilder builder;
1108 red.setColor(DlColor::kRed());
1111 green.setColor(DlColor::kGreen());
1114 blue.setColor(DlColor::kBlue());
1117 save.setColor(DlColor::kBlack().modulateOpacity(0.5));
1119 DlRect huge_bounds = DlRect::MakeXYWH(0, 0, 100000, 100000);
1120 builder.SaveLayer(huge_bounds, &save);
1122 builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), red);
1123 builder.DrawRect(DlRect::MakeXYWH(10, 10, 100, 100), green);
1124 builder.DrawRect(DlRect::MakeXYWH(20, 20, 100, 100), blue);
1128 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1133 EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1139 GetContext()->GetCapabilities()->GetDefaultColorFormat();
1146 DisplayListBuilder builder;
1153 builder.Translate(100, 200);
1154 builder.Scale(0.5, 0.5);
1155 builder.DrawImage(image,
DlPoint(100.0, 100.0),
1156 DlImageSampling::kNearestNeighbor);
1163 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
1165 builder.SaveLayer(std::nullopt, &alpha);
1168 paint.setColor(DlColor::kRed());
1169 builder.DrawRect(DlRect::MakeXYWH(000, 000, 100, 100), paint);
1170 paint.setColor(DlColor::kGreen());
1171 builder.DrawRect(DlRect::MakeXYWH(020, 020, 100, 100), paint);
1172 paint.setColor(DlColor::kBlue());
1173 builder.DrawRect(DlRect::MakeXYWH(040, 040, 100, 100), paint);
1178 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1182 DisplayListBuilder builder;
1185 paint.setColor(DlColor::kRed());
1186 builder.DrawCircle(
DlPoint(250, 250), 125, paint);
1188 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1192 DisplayListBuilder builder;
1195 red.setColor(DlColor::kRed());
1197 builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), red);
1199 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1203 DisplayListBuilder builder;
1206 save.setColor(DlColor::kBlack());
1208 DlRect save_bounds = DlRect::MakeXYWH(0, 0, 50, 50);
1209 builder.SaveLayer(save_bounds, &save);
1212 paint.setColor(DlColor::kRed());
1213 builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), paint);
1214 paint.setColor(DlColor::kGreen());
1215 builder.DrawRect(DlRect::MakeXYWH(10, 10, 100, 100), paint);
1216 paint.setColor(DlColor::kBlue());
1217 builder.DrawRect(DlRect::MakeXYWH(20, 20, 100, 100), paint);
1221 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1225 DisplayListBuilder builder;
1226 builder.Scale(GetContentScale().
x, GetContentScale().y);
1229 const int color_count = 3;
1230 DlColor colors[color_count] = {
1233 DlColor::ARGB(1.0, 220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f),
1236 paint.setColor(DlColor::kWhite());
1237 builder.DrawPaint(paint);
1240 const DlPaint& paint) {
1241 builder.DrawPath(DlPath::MakeRoundRectXY(rect,
x, y), paint);
1245 for (
int i = 0; i < 4; i++) {
1246 for (
int j = 0; j < 4; j++) {
1247 paint.setColor(colors[(c_index++) % color_count]);
1248 draw_rrect_as_path(DlRect::MakeXYWH(i * 100 + 10, j * 100 + 20, 80, 80),
1249 i * 5 + 10, j * 5 + 10, paint);
1252 paint.setColor(colors[(c_index++) % color_count]);
1253 draw_rrect_as_path(DlRect::MakeXYWH(10, 420, 380, 80), 40, 40, paint);
1254 paint.setColor(colors[(c_index++) % color_count]);
1255 draw_rrect_as_path(DlRect::MakeXYWH(410, 20, 80, 380), 40, 40, paint);
1257 std::vector<DlColor> gradient_colors = {
1258 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
1259 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
1260 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1261 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1262 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1263 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1264 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0)};
1265 std::vector<Scalar> stops = {
1275 CreateTextureForFixture(
"airplane.jpg",
1278 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
1279 paint.setColorSource(DlColorSource::MakeRadial(
1282 gradient_colors.size(),
1283 gradient_colors.data(),
1285 DlTileMode::kMirror));
1286 for (
int i = 1; i <= 10; i++) {
1288 draw_rrect_as_path(DlRect::MakeLTRB(550 - i * 20, 550 - j * 20,
1289 550 + i * 20, 550 + j * 20),
1290 i * 10, j * 10, paint);
1292 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
1293 paint.setColorSource(DlColorSource::MakeRadial(
1296 gradient_colors.size(),
1297 gradient_colors.data(),
1299 DlTileMode::kMirror));
1300 draw_rrect_as_path(DlRect::MakeLTRB(100, 610, 300, 690), 40, 40, paint);
1301 draw_rrect_as_path(DlRect::MakeLTRB(160, 550, 240, 750), 40, 40, paint);
1303 auto matrix = DlMatrix::MakeTranslation({520, 20});
1304 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
1305 paint.setColorSource(DlColorSource::MakeImage(
1306 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1307 DlImageSampling::kMipmapLinear, &matrix));
1308 for (
int i = 1; i <= 10; i++) {
1310 draw_rrect_as_path(DlRect::MakeLTRB(720 - i * 20, 220 - j * 20,
1311 720 + i * 20, 220 + j * 20),
1312 i * 10, j * 10, paint);
1314 matrix = DlMatrix::MakeTranslation({800, 300});
1315 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
1316 paint.setColorSource(DlColorSource::MakeImage(
1317 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1318 DlImageSampling::kMipmapLinear, &matrix));
1320 draw_rrect_as_path(DlRect::MakeLTRB(800, 410, 1000, 490), 40, 40, paint);
1321 draw_rrect_as_path(DlRect::MakeLTRB(860, 350, 940, 550), 40, 40, paint);
1323 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1327 auto callback = [&]() -> sk_sp<DisplayList> {
1328 DisplayListBuilder builder;
1329 builder.Scale(GetContentScale().x, GetContentScale().y);
1332 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
1334 auto current =
Point{25, 25};
1336 const auto size =
Size(100, 100);
1341 DlRect bounds = DlRect::MakeLTRB(b0.x, b0.y, b1.x, b1.y);
1343 DlPaint stroke_paint;
1344 stroke_paint.setColor(DlColor::kYellow());
1345 stroke_paint.setStrokeWidth(5);
1346 stroke_paint.setDrawStyle(DlDrawStyle::kStroke);
1347 builder.DrawRect(bounds, stroke_paint);
1349 builder.SaveLayer(bounds, &alpha);
1352 paint.setColor(DlColor::kRed());
1354 DlRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1356 paint.setColor(DlColor::kGreen());
1359 DlRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1361 paint.setColor(DlColor::kBlue());
1364 DlRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1368 return builder.Build();
1371 ASSERT_TRUE(OpenPlaygroundHere(callback));
1376 DisplayListBuilder builder;
1379 paint.setColor(DlColor::kBlack());
1380 DlRect rect = DlRect::MakeXYWH(25, 25, 25, 25);
1381 builder.DrawRect(rect, paint);
1383 builder.Translate(10, 10);
1386 builder.SaveLayer(std::nullopt, &save_paint);
1388 paint.setColor(DlColor::kGreen());
1389 builder.DrawRect(rect, paint);
1393 builder.Translate(10, 10);
1394 paint.setColor(DlColor::kRed());
1395 builder.DrawRect(rect, paint);
1397 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1401 DisplayListBuilder builder;
1403 DlRect rect = DlRect::MakeXYWH(0, 0, 1000, 1000);
1408 DlRect bounds = DlRect::MakeXYWH(25, 25, 25, 25);
1409 builder.SaveLayer(bounds, &save_paint);
1410 paint.setColor(DlColor::kBlack());
1411 builder.DrawRect(rect, paint);
1417 DlRect bounds = DlRect::MakeXYWH(35, 35, 25, 25);
1418 builder.SaveLayer(bounds, &save_paint);
1419 paint.setColor(DlColor::kGreen());
1420 builder.DrawRect(rect, paint);
1426 DlRect bounds = DlRect::MakeXYWH(45, 45, 25, 25);
1427 builder.SaveLayer(bounds, &save_paint);
1428 paint.setColor(DlColor::kRed());
1429 builder.DrawRect(rect, paint);
1433 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1437 DisplayListBuilder builder;
1440 paint.setColor(DlColor::kWhite());
1441 builder.DrawPaint(paint);
1447 builder.ClipPath(path);
1449 DlRect bounds = DlRect::MakeXYWH(50, 50, 100, 100);
1451 builder.SaveLayer(bounds, &save_paint);
1454 paint.setColor(DlColor::kWhite());
1455 builder.DrawRect(DlRect::MakeSize(DlSize(400, 400)), paint);
1458 paint.setColor(DlColor::kGreen());
1459 paint.setBlendMode(DlBlendMode::kHardLight);
1460 builder.DrawRect(DlRect::MakeSize(DlSize(400, 400)), paint);
1463 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1467 DisplayListBuilder builder;
1469 builder.Scale(GetContentScale().
x, GetContentScale().y);
1470 builder.Translate(100, 100);
1473 auto draw_image_layer = [&builder, &texture](
const DlPaint& paint) {
1474 builder.SaveLayer(std::nullopt, &paint);
1475 builder.DrawImage(texture,
DlPoint(), DlImageSampling::kLinear);
1479 DlPaint effect_paint;
1480 effect_paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 6));
1481 draw_image_layer(effect_paint);
1483 builder.Translate(300, 300);
1484 builder.Scale(3, 3);
1485 draw_image_layer(effect_paint);
1487 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1491 DisplayListBuilder builder;
1493 builder.Scale(GetContentScale().
x, GetContentScale().y);
1495 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 1));
1498 save_paint.setColor(DlColor::kWhite());
1499 builder.DrawPaint(save_paint);
1501 paint.setColor(DlColor::kBlue());
1502 for (
int i = 0; i < 5; i++) {
1504 Scalar y_radius = i * 15;
1505 for (
int j = 0; j < 5; j++) {
1507 Scalar x_radius = j * 15;
1508 builder.DrawRoundRect(
1509 DlRoundRect::MakeRectXY(
1510 DlRect::MakeXYWH(
x + 50, y + 50, 100.0f, 100.0f),
1511 x_radius, y_radius),
1516 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1520 DisplayListBuilder builder;
1524 builder.SaveLayer(std::nullopt, &paint);
1526 builder.Translate(100, 100);
1527 paint.setColor(DlColor::kBlue());
1528 builder.DrawCircle(
DlPoint(200, 200), 200, paint);
1529 builder.ClipRect(DlRect::MakeXYWH(100, 100, 200, 200));
1531 paint.setColor(DlColor::kGreen());
1532 paint.setBlendMode(DlBlendMode::kSrcOver);
1533 paint.setImageFilter(DlImageFilter::MakeColorFilter(
1534 DlColorFilter::MakeBlend(DlColor::kWhite(), DlBlendMode::kDst)));
1535 builder.DrawCircle(
DlPoint(200, 200), 200, paint);
1539 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1547 GTEST_SKIP() <<
"Swiftshader is running out of memory on this example.";
1549 DisplayListBuilder builder(DlRect::MakeSize(DlSize(1000, 1000)));
1551 auto filter = DlImageFilter::MakeMatrix(
1552 DlMatrix::MakeScale({0.001, 0.001, 1}), DlImageSampling::kLinear);
1555 paint.setImageFilter(filter);
1556 builder.SaveLayer(std::nullopt, &paint);
1559 paint.setColor(DlColor::kRed());
1560 builder.DrawRect(DlRect::MakeLTRB(0, 0, 100000, 100000), paint);
1564 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1571 auto callback = [&]() -> sk_sp<DisplayList> {
1573 ImGuiWindowFlags_AlwaysAutoResize)) {
1574 ImGui::SliderFloat(
"width", &width, 0, 200);
1575 ImGui::SliderFloat(
"height", &height, 0, 200);
1576 ImGui::SliderFloat(
"corner", &corner, 0, 1);
1580 DisplayListBuilder builder;
1581 builder.Scale(GetContentScale().
x, GetContentScale().y);
1583 DlPaint background_paint;
1584 background_paint.setColor(DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
1585 builder.DrawPaint(background_paint);
1587 std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kBlue()};
1588 std::vector<Scalar> stops = {0.0, 1.0};
1591 auto gradient = DlColorSource::MakeLinear(
DlPoint(0, 0),
DlPoint(200, 200),
1592 2, colors.data(), stops.data(),
1593 DlTileMode::kClamp);
1594 paint.setColorSource(gradient);
1595 paint.setColor(DlColor::kWhite());
1596 paint.setDrawStyle(DlDrawStyle::kStroke);
1597 paint.setStrokeWidth(20);
1600 builder.Translate(100, 100);
1602 Scalar corner_x = ((1 - corner) * 50) + 50;
1603 Scalar corner_y = corner * 50 + 50;
1605 DlRect::MakeXYWH(0, 0, width, height), corner_x, corner_y);
1606 builder.DrawRoundRect(rrect, paint);
1608 return builder.Build();
1610 ASSERT_TRUE(OpenPlaygroundHere(callback));
1614 DisplayListBuilder builder;
1616 builder.DrawPaint(DlPaint().setColor(DlColor::kWhite()));
1619 builder.ClipRect(DlRect::MakeLTRB(100, 100, 800, 800));
1623 builder.ClipRect(DlRect::MakeLTRB(600, 600, 800, 800));
1624 builder.DrawPaint(DlPaint().setColor(DlColor::kRed()));
1625 builder.DrawPaint(DlPaint().setColor(DlColor::kBlue().withAlphaF(0.5)));
1626 builder.ClipRect(DlRect::MakeLTRB(700, 700, 750, 800));
1627 builder.DrawPaint(DlPaint().setColor(DlColor::kRed().withAlphaF(0.5)));
1631 auto image_filter = DlImageFilter::MakeBlur(10, 10, DlTileMode::kDecal);
1632 builder.SaveLayer(std::nullopt,
nullptr, image_filter.get());
1635 builder.DrawCircle(
DlPoint(100, 100), 100,
1636 DlPaint().setColor(DlColor::kAqua()));
1638 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
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)
TEST_P(AiksTest, DrawAtlasNoColor)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
flutter::DlRoundRect DlRoundRect
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
constexpr const char * PixelFormatToString(PixelFormat format)
flutter::DlScalar DlScalar
const Scalar stroke_width
static constexpr Color White()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationY(Radians r)
constexpr Quad Transform(const Quad &quad) const
constexpr static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)