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"
23 #include "include/core/SkMatrix.h"
29 SkM44 FromImpellerMatrix(
const Matrix& matrix) {
30 return SkM44::ColMajor(matrix.m);
37 DisplayListBuilder builder;
39 paint.setColor(DlColor::kBlue());
40 SkPath path = SkPath();
41 path.addRect(SkRect::MakeXYWH(100.0, 100.0, 100.0, 100.0));
42 builder.DrawPath(path, paint);
43 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
47 DisplayListBuilder builder;
49 paint.setColor(DlColor::kRed());
51 builder.DrawImage(image, SkPoint::Make(100.0, 100.0),
52 DlImageSampling::kNearestNeighbor, &paint);
53 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
57 DisplayListBuilder builder;
59 paint.setColor(DlColor::kRed());
61 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
62 paint.setInvertColors(
true);
65 builder.DrawImage(image, SkPoint::Make(100.0, 100.0),
66 DlImageSampling::kNearestNeighbor, &paint);
67 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
71 DisplayListBuilder builder;
73 paint.setColor(DlColor::kRed());
75 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
76 paint.setInvertColors(
true);
78 builder.DrawRect(SkRect::MakeLTRB(0, 0, 100, 100), paint);
79 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
83 DisplayListBuilder builder;
85 paint.setColor(DlColor::kRed());
87 DlColorFilter::MakeBlend(DlColor::kYellow(), DlBlendMode::kSrcOver));
88 paint.setInvertColors(
true);
90 builder.DrawPaint(paint);
91 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
95 bool GenerateMipmap(
const std::shared_ptr<Context>& context,
96 std::shared_ptr<Texture> texture,
97 std::string_view label) {
98 auto buffer = context->CreateCommandBuffer();
102 auto pass = buffer->CreateBlitPass();
106 pass->GenerateMipmap(std::move(texture), label);
108 pass->EncodeCommands();
109 return context->GetCommandQueue()->Submit({buffer}).ok();
112 void CanRenderTiledTexture(
AiksTest* aiks_test,
113 DlTileMode tile_mode,
114 Matrix local_matrix = {}) {
115 auto context = aiks_test->GetContext();
116 ASSERT_TRUE(context);
117 auto texture = aiks_test->CreateTextureForFixture(
"table_mountain_nx.png",
119 GenerateMipmap(context, texture,
"table_mountain_nx");
121 auto color_source = DlColorSource::MakeImage(
122 image, tile_mode, tile_mode, DlImageSampling::kNearestNeighbor,
125 DisplayListBuilder builder;
127 paint.setColor(DlColor::kWhite());
128 paint.setColorSource(color_source);
130 builder.Scale(aiks_test->GetContentScale().x, aiks_test->GetContentScale().y);
131 builder.Translate(100.0f, 100.0f);
132 builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
136 paint.setDrawStyle(DlDrawStyle::kStroke);
138 if (tile_mode == DlTileMode::kDecal) {
142 builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
148 path.addCircle(150, 150, 150);
149 path.addRoundRect(SkRect::MakeLTRB(300, 300, 600, 600), 10, 10);
152 EXPECT_FALSE(path.isRect(
nullptr));
153 EXPECT_FALSE(path.isOval(
nullptr));
154 EXPECT_FALSE(path.isRRect(
nullptr));
157 EXPECT_FALSE(path.isConvex());
159 paint.setDrawStyle(DlDrawStyle::kFill);
160 builder.DrawPath(path, paint);
166 circle.addCircle(150, 450, 150);
169 EXPECT_TRUE(circle.isOval(
nullptr));
171 EXPECT_TRUE(circle.isConvex());
178 path.addPath(circle);
181 EXPECT_FALSE(path.isRect(
nullptr));
182 EXPECT_FALSE(path.isOval(
nullptr));
183 EXPECT_FALSE(path.isRRect(
nullptr));
186 EXPECT_TRUE(path.isConvex());
188 paint.setDrawStyle(DlDrawStyle::kFill);
189 builder.DrawPath(path, paint);
192 ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
197 CanRenderTiledTexture(
this, DlTileMode::kClamp);
201 CanRenderTiledTexture(
this, DlTileMode::kRepeat);
205 CanRenderTiledTexture(
this, DlTileMode::kMirror);
209 CanRenderTiledTexture(
this, DlTileMode::kDecal);
213 CanRenderTiledTexture(
this, DlTileMode::kClamp,
218 DisplayListBuilder builder;
221 SkSize image_half_size = SkSize::Make(image->dimensions().fWidth * 0.5f,
222 image->dimensions().fHeight * 0.5f);
225 auto source_rect = SkRect::MakeSize(image_half_size);
227 source_rect.makeOffset(image_half_size.fWidth, image_half_size.fHeight);
229 builder.DrawImageRect(image, source_rect,
230 SkRect::MakeXYWH(100, 100, 600, 600),
231 DlImageSampling::kNearestNeighbor);
232 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
236 DisplayListBuilder builder;
240 auto source_rect = SkRect::MakeXYWH(
241 image->dimensions().fWidth * 0.25f, image->dimensions().fHeight * 0.4f,
242 image->dimensions().fWidth, image->dimensions().fHeight);
244 auto dest_rect = SkRect::MakeXYWH(100, 100, 600, 600);
247 paint.setColor(DlColor::kMidGrey());
248 builder.DrawRect(dest_rect, paint);
250 builder.DrawImageRect(image, source_rect, dest_rect,
251 DlImageSampling::kNearestNeighbor);
252 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
256 DisplayListBuilder builder;
257 builder.Scale(GetContentScale().
x, GetContentScale().y);
260 paint.setColor(DlColor::kWhite());
261 builder.DrawPaint(paint);
263 auto draw = [&builder](
const DlPaint& paint,
Scalar x,
Scalar y) {
265 builder.Translate(
x, y);
268 builder.ClipRect(SkRect::MakeLTRB(50, 50, 150, 150));
269 builder.DrawPaint(paint);
274 builder.ClipOval(SkRect::MakeLTRB(200, 50, 300, 150));
275 builder.DrawPaint(paint);
281 SkRRect::MakeRectXY(SkRect::MakeLTRB(50, 200, 150, 300), 20, 20));
282 builder.DrawPaint(paint);
288 SkRRect::MakeRectXY(SkRect::MakeLTRB(200, 230, 300, 270), 20, 20));
289 builder.DrawPaint(paint);
295 SkRRect::MakeRectXY(SkRect::MakeLTRB(230, 200, 270, 300), 20, 20));
296 builder.DrawPaint(paint);
302 paint.setColor(DlColor::kBlue());
305 DlColor gradient_colors[7] = {
306 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
307 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
308 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
309 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
310 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
311 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
312 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
323 auto texture = CreateTextureForFixture(
"airplane.jpg",
327 paint.setColorSource(DlColorSource::MakeRadial(
328 {500, 600}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
331 paint.setColorSource(
332 DlColorSource::MakeImage(image, DlTileMode::kRepeat, DlTileMode::kRepeat,
333 DlImageSampling::kNearestNeighbor));
336 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
340 DisplayListBuilder builder;
343 red.setColor(DlColor::kRed());
346 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
348 builder.SaveLayer(
nullptr, &alpha);
350 builder.DrawCircle(SkPoint{125, 125}, 125, red);
354 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
358 DisplayListBuilder builder;
361 DlColor colors[2] = {
362 DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
363 DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0),
370 paint.setColorSource(DlColorSource::MakeLinear(
380 builder.Translate(100, 100);
381 builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), paint);
385 builder.Translate(100, 400);
386 builder.DrawCircle(SkPoint{100, 100}, 100, paint);
388 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
392 DisplayListBuilder builder;
394 paint.setColor(DlColor::kRed());
397 SkVector radii[4] = {
403 rrect.setRectRadii(SkRect::MakeXYWH(100, 100, 500, 500), radii);
405 builder.DrawRRect(rrect, paint);
407 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
411 auto medium_turquoise =
412 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
414 DisplayListBuilder builder;
415 builder.Scale(0.2, 0.2);
416 builder.DrawPaint(DlPaint().setColor(medium_turquoise));
417 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
421 auto medium_turquoise =
422 DlColor::RGBA(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f);
424 DlColor::RGBA(255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f);
426 DisplayListBuilder builder;
427 builder.Scale(0.2, 0.2);
428 builder.DrawPaint(DlPaint().setColor(medium_turquoise));
429 builder.DrawPaint(DlPaint().setColor(orange_red.modulateOpacity(0.5f)));
430 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
434 DisplayListBuilder builder;
435 builder.Scale(GetContentScale().
x, GetContentScale().y);
437 const int color_count = 3;
438 DlColor colors[color_count] = {
441 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
444 paint.setColor(DlColor::kWhite());
445 builder.DrawPaint(paint);
450 paint.setColor(colors[(c_index++) % color_count]);
451 builder.DrawCircle(SkPoint{10, 10}, radius, paint);
459 DlColor gradient_colors[7] = {
460 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
461 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
462 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
463 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
464 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
465 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
466 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
477 auto texture = CreateTextureForFixture(
"airplane.jpg",
481 paint.setColorSource(DlColorSource::MakeRadial(
482 {500, 600}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
483 builder.DrawCircle(SkPoint{500, 600}, 100, paint);
485 DlMatrix local_matrix = DlMatrix::MakeTranslation({700, 200});
486 paint.setColorSource(DlColorSource::MakeImage(
487 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
488 DlImageSampling::kNearestNeighbor, &local_matrix));
489 builder.DrawCircle(SkPoint{800, 300}, 100, paint);
491 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
495 DisplayListBuilder builder;
496 builder.Scale(GetContentScale().
x, GetContentScale().y);
498 const int color_count = 3;
499 DlColor colors[color_count] = {
502 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
505 paint.setColor(DlColor::kWhite());
506 builder.DrawPaint(paint);
510 auto draw = [&paint, &colors, &c_index](DlCanvas& canvas, SkPoint center,
512 for (
int i = 0; i < n; i++) {
513 paint.setColor(colors[(c_index++) % color_count]);
514 canvas.DrawCircle(center, r, paint);
519 paint.setDrawStyle(DlDrawStyle::kStroke);
520 paint.setStrokeWidth(1);
521 draw(builder, {10, 10}, 2, 2, 14);
522 paint.setStrokeWidth(5);
523 draw(builder, {10, 10}, 35, 10, 56);
525 DlColor gradient_colors[7] = {
526 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
527 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
528 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
529 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
530 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
531 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
532 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
543 auto texture = CreateTextureForFixture(
"airplane.jpg",
547 paint.setColorSource(DlColorSource::MakeRadial(
548 {500, 600}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
549 draw(builder, {500, 600}, 5, 10, 10);
551 DlMatrix local_matrix = DlMatrix::MakeTranslation({700, 200});
552 paint.setColorSource(DlColorSource::MakeImage(
553 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
554 DlImageSampling::kNearestNeighbor, &local_matrix));
555 draw(builder, {800, 300}, 5, 10, 10);
557 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
561 DisplayListBuilder builder;
562 builder.Scale(GetContentScale().
x, GetContentScale().y);
564 const int color_count = 3;
565 DlColor colors[color_count] = {
568 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
571 paint.setColor(DlColor::kWhite());
572 builder.DrawPaint(paint);
575 int long_radius = 600;
576 int short_radius = 600;
577 while (long_radius > 0 && short_radius > 0) {
578 paint.setColor(colors[(c_index++) % color_count]);
579 builder.DrawOval(SkRect::MakeXYWH(10 - long_radius, 10 - short_radius,
580 long_radius * 2, short_radius * 2),
582 builder.DrawOval(SkRect::MakeXYWH(1000 - short_radius, 750 - long_radius,
583 short_radius * 2, long_radius * 2),
585 if (short_radius > 30) {
594 DlColor gradient_colors[7] = {
595 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
596 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
597 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
598 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
599 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
600 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
601 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
612 auto texture = CreateTextureForFixture(
"airplane.jpg",
616 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
618 paint.setColorSource(DlColorSource::MakeRadial(
619 {300, 650}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
620 builder.DrawOval(SkRect::MakeXYWH(200, 625, 200, 50), paint);
621 builder.DrawOval(SkRect::MakeXYWH(275, 550, 50, 200), paint);
623 DlMatrix local_matrix = DlMatrix::MakeTranslation({610, 15});
624 paint.setColorSource(DlColorSource::MakeImage(
625 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
626 DlImageSampling::kNearestNeighbor, &local_matrix));
627 builder.DrawOval(SkRect::MakeXYWH(610, 90, 200, 50), paint);
628 builder.DrawOval(SkRect::MakeXYWH(685, 15, 50, 200), paint);
630 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
634 DisplayListBuilder builder;
635 builder.Scale(GetContentScale().
x, GetContentScale().y);
637 const int color_count = 3;
638 DlColor colors[color_count] = {
641 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f),
644 paint.setColor(DlColor::kWhite());
645 builder.DrawPaint(paint);
648 for (
int i = 0; i < 4; i++) {
649 for (
int j = 0; j < 4; j++) {
650 paint.setColor(colors[(c_index++) % color_count]);
653 SkRect::MakeXYWH(i * 100 + 10, j * 100 + 20, 80, 80),
654 i * 5 + 10, j * 5 + 10),
658 paint.setColor(colors[(c_index++) % color_count]);
660 SkRRect::MakeRectXY(SkRect::MakeXYWH(10, 420, 380, 80), 40, 40), paint);
661 paint.setColor(colors[(c_index++) % color_count]);
663 SkRRect::MakeRectXY(SkRect::MakeXYWH(410, 20, 80, 380), 40, 40), paint);
665 DlColor gradient_colors[7] = {
666 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
667 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
668 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
669 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
670 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
671 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
672 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0),
683 auto texture = CreateTextureForFixture(
"airplane.jpg",
687 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
688 paint.setColorSource(DlColorSource::MakeRadial(
689 {550, 550}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
690 for (
int i = 1; i <= 10; i++) {
693 SkRRect::MakeRectXY(SkRect::MakeLTRB(550 - i * 20, 550 - j * 20,
694 550 + i * 20, 550 + j * 20),
699 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
700 paint.setColorSource(DlColorSource::MakeRadial(
701 {200, 650}, 75, 7, gradient_colors, stops, DlTileMode::kMirror));
702 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
704 SkRRect::MakeRectXY(SkRect::MakeLTRB(100, 610, 300, 690), 40, 40), paint);
706 SkRRect::MakeRectXY(SkRect::MakeLTRB(160, 550, 240, 750), 40, 40), paint);
708 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
709 DlMatrix local_matrix = DlMatrix::MakeTranslation({520, 20});
710 paint.setColorSource(DlColorSource::MakeImage(
711 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
712 DlImageSampling::kNearestNeighbor, &local_matrix));
713 for (
int i = 1; i <= 10; i++) {
716 SkRRect::MakeRectXY(SkRect::MakeLTRB(720 - i * 20, 220 - j * 20,
717 720 + i * 20, 220 + j * 20),
722 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
723 local_matrix = DlMatrix::MakeTranslation({800, 300});
724 paint.setColorSource(DlColorSource::MakeImage(
725 image, DlTileMode::kRepeat, DlTileMode::kRepeat,
726 DlImageSampling::kNearestNeighbor, &local_matrix));
728 SkRRect::MakeRectXY(SkRect::MakeLTRB(800, 410, 1000, 490), 40, 40),
731 SkRRect::MakeRectXY(SkRect::MakeLTRB(860, 350, 940, 550), 40, 40), paint);
733 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
737 DisplayListBuilder builder;
738 builder.Scale(GetContentScale().
x, GetContentScale().y);
740 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 1.0f));
742 builder.DrawPaint(DlPaint().setColor(DlColor::kWhite()));
745 DlColor::RGBA(220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f));
747 for (
int i = 0; i < 5; i++) {
750 builder.DrawRect(SkRect::MakeXYWH(
x + 25 - radius / 2, y + radius / 2,
751 radius, 60.0f - radius),
755 paint.setColor(DlColor::kBlue());
757 for (
int i = 0; i < 5; i++) {
760 builder.DrawCircle(SkPoint{
x + 25, y + 25}, radius, paint);
763 paint.setColor(DlColor::kGreen());
765 for (
int i = 0; i < 5; i++) {
768 builder.DrawOval(SkRect::MakeXYWH(
x + 25 - radius / 2, y + radius / 2,
769 radius, 60.0f - radius),
774 DlColor::RGBA(128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f));
776 for (
int i = 0; i < 5; i++) {
779 builder.DrawRRect(SkRRect::MakeRectXY(SkRect::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++) {
791 SkRRect::MakeRectXY(SkRect::MakeXYWH(
x, y, 60.0f, 60.0f), radius, 5.0f),
795 auto dl = builder.Build();
796 ASSERT_TRUE(OpenPlaygroundHere(dl));
800 DisplayListBuilder builder;
802 builder.Scale(GetContentScale().
x, GetContentScale().y);
805 std::vector<DlColor> colors = {DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
806 DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0)};
807 std::vector<Scalar> stops = {
812 paint.setColorSource(DlColorSource::MakeLinear(
821 builder.DrawPaint(paint);
823 SkRect clip_rect = SkRect::MakeLTRB(50, 50, 400, 300);
824 SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 100, 100);
828 builder.ClipRRect(clip_rrect, DlCanvas::ClipOp::kIntersect);
831 auto backdrop_filter = DlImageFilter::MakeColorFilter(
832 DlColorFilter::MakeBlend(DlColor::kRed(), DlBlendMode::kExclusion));
833 builder.SaveLayer(&clip_rect, &save_paint, backdrop_filter.get());
835 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
841 auto callback = [&]() -> sk_sp<DisplayList> {
842 DisplayListBuilder builder;
846 builder.Translate(300, 300);
853 paint.setColor(DlColor::kGreen());
854 builder.DrawPaint(paint);
855 builder.ClipRect(SkRect::MakeLTRB(-180, -180, 180, 180),
856 DlCanvas::ClipOp::kDifference);
858 paint.setColor(DlColor::kBlack());
859 builder.DrawPaint(paint);
867 builder.ClipOval(SkRect::MakeLTRB(-200, -200, 200, 200));
870 Matrix(1.0, 0.0, 0.0, 0.0,
872 0.0, 0.0, 1.0, 0.003,
873 0.0, 0.0, 0.0, 1.0) *
877 builder.
Transform(FromImpellerMatrix(result));
881 auto position = -SkPoint::Make(image->dimensions().fWidth,
882 image->dimensions().fHeight) *
884 builder.DrawImage(image, position, {});
890 paint.setColor(DlColor::kBlue().modulateOpacity(0.4));
891 builder.DrawCircle(SkPoint{}, 230, paint);
895 return builder.Build();
897 ASSERT_TRUE(OpenPlaygroundHere(callback));
903 DisplayListBuilder builder;
907 paint.setColor(DlColor::kWhite());
908 builder.DrawPaint(paint);
912 DlMatrix matrix = DlMatrix::MakeTranslation({50, 50});
914 paint.setColorSource(DlColorSource::MakeImage(
915 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
916 DlImageSampling::kNearestNeighbor, &matrix));
918 builder.DrawRect(SkRect::MakeLTRB(0, 0, 100, 100), paint);
927 Matrix matrix(1, -1, 0, 0,
931 paint.setColorSource(DlColorSource::MakeImage(
932 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
933 DlImageSampling::kNearestNeighbor, &matrix));
934 builder.DrawRect(SkRect::MakeLTRB(100, 0, 200, 100), paint);
940 builder.Translate(100, 0);
941 builder.Scale(100, 100);
944 DlMatrix matrix = DlMatrix::MakeScale({0.005, 0.005, 1});
945 paint.setColorSource(DlColorSource::MakeImage(
946 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
947 DlImageSampling::kNearestNeighbor, &matrix));
949 builder.DrawRect(SkRect::MakeLTRB(0, 0, 1, 1), paint);
952 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
956 DisplayListBuilder builder;
961 paint.setColor(DlColor::kBlue().modulateOpacity(0.5));
962 paint.setBlendMode(DlBlendMode::kSrc);
964 SkRect bounds = SkRect::MakeLTRB(0, 0, 200, 200);
965 builder.SaveLayer(&bounds, &paint);
967 paint.setColor(DlColor::kTransparent());
968 paint.setBlendMode(DlBlendMode::kSrc);
969 builder.DrawPaint(paint);
972 paint.setColor(DlColor::kBlue());
973 paint.setBlendMode(DlBlendMode::kDstOver);
974 builder.SaveLayer(
nullptr, &paint);
980 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
985 DisplayListBuilder builder;
986 builder.Scale(GetContentScale().
x, GetContentScale().y);
987 builder.Translate(100, 100);
991 DlMatrix translate = DlMatrix::MakeTranslation({300, 0});
992 paint.setImageFilter(
993 DlImageFilter::MakeMatrix(translate, DlImageSampling::kLinear));
994 builder.SaveLayer(
nullptr, &paint);
996 DlPaint circle_paint;
997 circle_paint.setColor(DlColor::kGreen());
998 builder.DrawCircle(SkPoint{-300, 0}, 100, circle_paint);
1001 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1006 MatrixImageFilterDoesntCullWhenScaledAndTranslatedFromOffscreen) {
1007 DisplayListBuilder builder;
1008 builder.Scale(GetContentScale().
x, GetContentScale().y);
1009 builder.Translate(100, 100);
1014 paint.setImageFilter(DlImageFilter::MakeMatrix(
1015 DlMatrix::MakeTranslation({300, 0}) * DlMatrix::MakeScale({2, 2, 1}),
1016 DlImageSampling::kNearestNeighbor));
1017 builder.SaveLayer(
nullptr, &paint);
1019 DlPaint circle_paint;
1020 circle_paint.setColor(DlColor::kGreen());
1021 builder.DrawCircle(SkPoint{-150, 0}, 50, circle_paint);
1024 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1029 SetWindowSize({400, 400});
1030 DisplayListBuilder builder;
1032 builder.Scale(GetContentScale().
x, GetContentScale().y);
1035 paint.setColor(DlColor::kRed());
1036 builder.DrawRect(SkRect::MakeLTRB(200, 200, 300, 300), paint);
1038 paint.setImageFilter(DlImageFilter::MakeMatrix(DlMatrix::MakeScale({2, 2, 1}),
1039 DlImageSampling::kLinear));
1040 builder.SaveLayer(
nullptr, &paint);
1043 paint.setColor(DlColor::kGreen());
1044 builder.DrawRect(SkRect::MakeLTRB(0, 0, 400, 400), paint);
1047 paint.setColor(DlColor::kRed());
1048 builder.DrawRect(SkRect::MakeLTRB(0, 0, 800, 800), paint);
1051 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1055 DisplayListBuilder builder;
1056 builder.Scale(GetContentScale().
x, GetContentScale().y);
1059 paint.setColor(DlColor::kRed());
1060 builder.DrawPaint(paint);
1061 builder.ClipRect(SkRect::MakeXYWH(100, 100, 200, 200));
1062 paint.setColor(DlColor::kBlue());
1063 builder.SaveLayer(
nullptr, &paint);
1066 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1070 DisplayListBuilder builder;
1071 builder.Scale(GetContentScale().
x, GetContentScale().y);
1073 builder.DrawImage(image, SkPoint{10, 10}, {});
1074 builder.ClipRect(SkRect::MakeXYWH(100, 100, 200, 200));
1077 paint.setBlendMode(DlBlendMode::kClear);
1078 builder.SaveLayer(
nullptr, &paint);
1081 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1085 CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
1086 DisplayListBuilder builder;
1089 red.setColor(DlColor::kRed());
1092 green.setColor(DlColor::kGreen());
1095 blue.setColor(DlColor::kBlue());
1098 save.setColor(DlColor::kBlack().modulateOpacity(0.5));
1100 SkRect huge_bounds = SkRect::MakeXYWH(0, 0, 100000, 100000);
1101 builder.SaveLayer(&huge_bounds, &save);
1103 builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), red);
1104 builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100), green);
1105 builder.DrawRect(SkRect::MakeXYWH(20, 20, 100, 100), blue);
1109 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1114 EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
1120 GetContext()->GetCapabilities()->GetDefaultColorFormat();
1127 DisplayListBuilder builder;
1134 builder.Translate(100, 200);
1135 builder.Scale(0.5, 0.5);
1136 builder.DrawImage(image, SkPoint::Make(100.0, 100.0),
1137 DlImageSampling::kNearestNeighbor);
1144 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
1146 builder.SaveLayer(
nullptr, &alpha);
1149 paint.setColor(DlColor::kRed());
1150 builder.DrawRect(SkRect::MakeXYWH(000, 000, 100, 100), paint);
1151 paint.setColor(DlColor::kGreen());
1152 builder.DrawRect(SkRect::MakeXYWH(020, 020, 100, 100), paint);
1153 paint.setColor(DlColor::kBlue());
1154 builder.DrawRect(SkRect::MakeXYWH(040, 040, 100, 100), paint);
1159 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1163 DisplayListBuilder builder;
1166 paint.setColor(DlColor::kRed());
1167 builder.DrawCircle(SkPoint::Make(250, 250), 125, paint);
1169 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1173 DisplayListBuilder builder;
1176 red.setColor(DlColor::kRed());
1178 builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), red);
1180 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1184 DisplayListBuilder builder;
1187 save.setColor(DlColor::kBlack());
1189 SkRect save_bounds = SkRect::MakeXYWH(0, 0, 50, 50);
1190 builder.SaveLayer(&save_bounds, &save);
1193 paint.setColor(DlColor::kRed());
1194 builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint);
1195 paint.setColor(DlColor::kGreen());
1196 builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100), paint);
1197 paint.setColor(DlColor::kBlue());
1198 builder.DrawRect(SkRect::MakeXYWH(20, 20, 100, 100), paint);
1202 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1206 DisplayListBuilder builder;
1207 builder.Scale(GetContentScale().
x, GetContentScale().y);
1210 const int color_count = 3;
1211 DlColor colors[color_count] = {
1214 DlColor::ARGB(1.0, 220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f),
1217 paint.setColor(DlColor::kWhite());
1218 builder.DrawPaint(paint);
1220 auto draw_rrect_as_path = [&builder](
const SkRect& rect,
Scalar x,
Scalar y,
1221 const DlPaint& paint) {
1223 path.addRoundRect(rect,
x, y);
1224 builder.DrawPath(path, paint);
1228 for (
int i = 0; i < 4; i++) {
1229 for (
int j = 0; j < 4; j++) {
1230 paint.setColor(colors[(c_index++) % color_count]);
1231 draw_rrect_as_path(SkRect::MakeXYWH(i * 100 + 10, j * 100 + 20, 80, 80),
1232 i * 5 + 10, j * 5 + 10, paint);
1235 paint.setColor(colors[(c_index++) % color_count]);
1236 draw_rrect_as_path(SkRect::MakeXYWH(10, 420, 380, 80), 40, 40, paint);
1237 paint.setColor(colors[(c_index++) % color_count]);
1238 draw_rrect_as_path(SkRect::MakeXYWH(410, 20, 80, 380), 40, 40, paint);
1240 std::vector<DlColor> gradient_colors = {
1241 DlColor::RGBA(0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0),
1242 DlColor::RGBA(0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0),
1243 DlColor::RGBA(0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0),
1244 DlColor::RGBA(0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0),
1245 DlColor::RGBA(0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0),
1246 DlColor::RGBA(0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0),
1247 DlColor::RGBA(0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0)};
1248 std::vector<Scalar> stops = {
1258 CreateTextureForFixture(
"airplane.jpg",
1261 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
1262 paint.setColorSource(DlColorSource::MakeRadial(
1265 gradient_colors.size(),
1266 gradient_colors.data(),
1268 DlTileMode::kMirror));
1269 for (
int i = 1; i <= 10; i++) {
1271 draw_rrect_as_path(SkRect::MakeLTRB(550 - i * 20, 550 - j * 20,
1272 550 + i * 20, 550 + j * 20),
1273 i * 10, j * 10, paint);
1275 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
1276 paint.setColorSource(DlColorSource::MakeRadial(
1279 gradient_colors.size(),
1280 gradient_colors.data(),
1282 DlTileMode::kMirror));
1283 draw_rrect_as_path(SkRect::MakeLTRB(100, 610, 300, 690), 40, 40, paint);
1284 draw_rrect_as_path(SkRect::MakeLTRB(160, 550, 240, 750), 40, 40, paint);
1286 auto matrix = DlMatrix::MakeTranslation({520, 20});
1287 paint.setColor(DlColor::kWhite().modulateOpacity(0.1));
1288 paint.setColorSource(DlColorSource::MakeImage(
1289 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1290 DlImageSampling::kMipmapLinear, &matrix));
1291 for (
int i = 1; i <= 10; i++) {
1293 draw_rrect_as_path(SkRect::MakeLTRB(720 - i * 20, 220 - j * 20,
1294 720 + i * 20, 220 + j * 20),
1295 i * 10, j * 10, paint);
1297 matrix = DlMatrix::MakeTranslation({800, 300});
1298 paint.setColor(DlColor::kWhite().modulateOpacity(0.5));
1299 paint.setColorSource(DlColorSource::MakeImage(
1300 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
1301 DlImageSampling::kMipmapLinear, &matrix));
1303 draw_rrect_as_path(SkRect::MakeLTRB(800, 410, 1000, 490), 40, 40, paint);
1304 draw_rrect_as_path(SkRect::MakeLTRB(860, 350, 940, 550), 40, 40, paint);
1306 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1310 auto callback = [&]() -> sk_sp<DisplayList> {
1311 DisplayListBuilder builder;
1312 builder.Scale(GetContentScale().x, GetContentScale().y);
1315 alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
1317 auto current =
Point{25, 25};
1319 const auto size =
Size(100, 100);
1324 SkRect bounds = SkRect::MakeLTRB(b0.x, b0.y, b1.x, b1.y);
1326 DlPaint stroke_paint;
1327 stroke_paint.setColor(DlColor::kYellow());
1328 stroke_paint.setStrokeWidth(5);
1329 stroke_paint.setDrawStyle(DlDrawStyle::kStroke);
1330 builder.DrawRect(bounds, stroke_paint);
1332 builder.SaveLayer(&bounds, &alpha);
1335 paint.setColor(DlColor::kRed());
1337 SkRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1339 paint.setColor(DlColor::kGreen());
1342 SkRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1344 paint.setColor(DlColor::kBlue());
1347 SkRect::MakeXYWH(current.x, current.y, size.width, size.height), paint);
1351 return builder.Build();
1354 ASSERT_TRUE(OpenPlaygroundHere(callback));
1359 DisplayListBuilder builder;
1362 paint.setColor(DlColor::kBlack());
1363 SkRect rect = SkRect::MakeXYWH(25, 25, 25, 25);
1364 builder.DrawRect(rect, paint);
1366 builder.Translate(10, 10);
1369 builder.SaveLayer(
nullptr, &save_paint);
1371 paint.setColor(DlColor::kGreen());
1372 builder.DrawRect(rect, paint);
1376 builder.Translate(10, 10);
1377 paint.setColor(DlColor::kRed());
1378 builder.DrawRect(rect, paint);
1380 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1384 DisplayListBuilder builder;
1386 SkRect rect = SkRect::MakeXYWH(0, 0, 1000, 1000);
1391 SkRect bounds = SkRect::MakeXYWH(25, 25, 25, 25);
1392 builder.SaveLayer(&bounds, &save_paint);
1393 paint.setColor(DlColor::kBlack());
1394 builder.DrawRect(rect, paint);
1400 SkRect bounds = SkRect::MakeXYWH(35, 35, 25, 25);
1401 builder.SaveLayer(&bounds, &save_paint);
1402 paint.setColor(DlColor::kGreen());
1403 builder.DrawRect(rect, paint);
1409 SkRect bounds = SkRect::MakeXYWH(45, 45, 25, 25);
1410 builder.SaveLayer(&bounds, &save_paint);
1411 paint.setColor(DlColor::kRed());
1412 builder.DrawRect(rect, paint);
1416 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1420 DisplayListBuilder builder;
1423 paint.setColor(DlColor::kWhite());
1424 builder.DrawPaint(paint);
1429 SkPath path = SkPath::Circle(100, 100, 50);
1430 builder.ClipPath(path);
1432 SkRect bounds = SkRect::MakeXYWH(50, 50, 100, 100);
1434 builder.SaveLayer(&bounds, &save_paint);
1437 paint.setColor(DlColor::kWhite());
1438 builder.DrawRect(SkRect::MakeSize(SkSize{400, 400}), paint);
1441 paint.setColor(DlColor::kGreen());
1442 paint.setBlendMode(DlBlendMode::kHardLight);
1443 builder.DrawRect(SkRect::MakeSize(SkSize{400, 400}), paint);
1446 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1450 DisplayListBuilder builder;
1452 builder.Scale(GetContentScale().
x, GetContentScale().y);
1453 builder.Translate(100, 100);
1456 auto draw_image_layer = [&builder, &texture](
const DlPaint& paint) {
1457 builder.SaveLayer(
nullptr, &paint);
1458 builder.DrawImage(texture, SkPoint{}, DlImageSampling::kLinear);
1462 DlPaint effect_paint;
1463 effect_paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 6));
1464 draw_image_layer(effect_paint);
1466 builder.Translate(300, 300);
1467 builder.Scale(3, 3);
1468 draw_image_layer(effect_paint);
1470 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1474 DisplayListBuilder builder;
1476 builder.Scale(GetContentScale().
x, GetContentScale().y);
1478 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 1));
1481 save_paint.setColor(DlColor::kWhite());
1482 builder.DrawPaint(save_paint);
1484 paint.setColor(DlColor::kBlue());
1485 for (
int i = 0; i < 5; i++) {
1487 Scalar y_radius = i * 15;
1488 for (
int j = 0; j < 5; j++) {
1490 Scalar x_radius = j * 15;
1492 SkRRect::MakeRectXY(SkRect::MakeXYWH(
x + 50, y + 50, 100.0f, 100.0f),
1493 x_radius, y_radius),
1498 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1502 DisplayListBuilder builder;
1506 builder.SaveLayer(
nullptr, &paint);
1508 builder.Translate(100, 100);
1509 paint.setColor(DlColor::kBlue());
1510 builder.DrawCircle(SkPoint::Make(200, 200), 200, paint);
1511 builder.ClipRect(SkRect::MakeXYWH(100, 100, 200, 200));
1513 paint.setColor(DlColor::kGreen());
1514 paint.setBlendMode(DlBlendMode::kSrcOver);
1515 paint.setImageFilter(DlImageFilter::MakeColorFilter(
1516 DlColorFilter::MakeBlend(DlColor::kWhite(), DlBlendMode::kDst)));
1517 builder.DrawCircle(SkPoint::Make(200, 200), 200, paint);
1521 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1529 GTEST_SKIP() <<
"Swiftshader is running out of memory on this example.";
1531 DisplayListBuilder builder(SkRect::MakeSize(SkSize::Make(1000, 1000)));
1533 auto filter = DlImageFilter::MakeMatrix(
1534 DlMatrix::MakeScale({0.001, 0.001, 1}), DlImageSampling::kLinear);
1537 paint.setImageFilter(filter);
1538 builder.SaveLayer(
nullptr, &paint);
1541 paint.setColor(DlColor::kRed());
1542 builder.DrawRect(SkRect::MakeLTRB(0, 0, 100000, 100000), paint);
1546 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
1553 auto callback = [&]() -> sk_sp<DisplayList> {
1555 ImGuiWindowFlags_AlwaysAutoResize)) {
1556 ImGui::SliderFloat(
"width", &width, 0, 200);
1557 ImGui::SliderFloat(
"height", &height, 0, 200);
1558 ImGui::SliderFloat(
"corner", &corner, 0, 1);
1562 DisplayListBuilder builder;
1563 builder.Scale(GetContentScale().
x, GetContentScale().y);
1565 DlPaint background_paint;
1566 background_paint.setColor(DlColor(1, 0.1, 0.1, 0.1, DlColorSpace::kSRGB));
1567 builder.DrawPaint(background_paint);
1569 std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kBlue()};
1570 std::vector<Scalar> stops = {0.0, 1.0};
1573 auto gradient = DlColorSource::MakeLinear(
1574 {0, 0}, {200, 200}, 2, colors.data(), stops.data(), DlTileMode::kClamp);
1575 paint.setColorSource(gradient);
1576 paint.setColor(DlColor::kWhite());
1577 paint.setDrawStyle(DlDrawStyle::kStroke);
1578 paint.setStrokeWidth(20);
1581 builder.Translate(100, 100);
1583 Scalar corner_x = ((1 - corner) * 50) + 50;
1584 Scalar corner_y = corner * 50 + 50;
1585 SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, width, height),
1586 corner_x, corner_y);
1587 builder.DrawRRect(rrect, paint);
1589 return builder.Build();
1591 ASSERT_TRUE(OpenPlaygroundHere(callback));
1595 DisplayListBuilder builder;
1597 builder.DrawPaint(DlPaint().setColor(DlColor::kWhite()));
1600 builder.ClipRect(DlRect::MakeLTRB(100, 100, 800, 800));
1604 builder.ClipRect(DlRect::MakeLTRB(600, 600, 800, 800));
1605 builder.DrawPaint(DlPaint().setColor(DlColor::kRed()));
1606 builder.DrawPaint(DlPaint().setColor(DlColor::kBlue().withAlphaF(0.5)));
1607 builder.ClipRect(DlRect::MakeLTRB(700, 700, 750, 800));
1608 builder.DrawPaint(DlPaint().setColor(DlColor::kRed().withAlphaF(0.5)));
1612 auto image_filter = DlImageFilter::MakeBlur(10, 10, DlTileMode::kDecal);
1613 builder.SaveLayer(std::nullopt,
nullptr, image_filter.get());
1616 builder.DrawCircle(SkPoint{100, 100}, 100,
1617 DlPaint().setColor(DlColor::kAqua()));
1619 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)
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