7 #include "flutter/display_list/dl_builder.h"
8 #include "flutter/display_list/dl_color.h"
9 #include "flutter/display_list/dl_paint.h"
10 #include "flutter/display_list/geometry/dl_path_builder.h"
12 #include "flutter/testing/testing.h"
22 class PathReflector :
public PathReceiver {
25 static PathReflector ReflectAroundX(
Scalar x_coordinate) {
26 return PathReflector(-1.0f, x_coordinate * 2.0f, 1.0f, 0.0f);
30 static PathReflector ReflectAroundY(
Scalar y_coordinate) {
31 return PathReflector(1.0f, 0.0f, -1.0f, y_coordinate * 2.0f);
35 static PathReflector ReflectAround(
const Point& anchor) {
36 return PathReflector(-1.0f, anchor.x * 2.0f, -1.0f, anchor.y * 2.0f);
40 void MoveTo(
const Point& p2,
bool will_be_closed)
override {
41 path_builder_.MoveTo(reflect(p2));
45 void LineTo(
const Point& p2)
override { path_builder_.LineTo(reflect(p2)); }
48 void QuadTo(
const Point& cp,
const Point& p2)
override {
49 path_builder_.QuadraticCurveTo(reflect(cp), reflect(p2));
54 path_builder_.ConicCurveTo(reflect(cp), reflect(p2), weight);
60 path_builder_.CubicCurveTo(reflect(cp1), reflect(cp2), reflect(p2));
64 void Close()
override { path_builder_.Close(); }
66 DlPath TakePath() {
return path_builder_.TakePath(); }
69 PathReflector(
Scalar scale_x,
74 translate_x_(translate_x),
76 translate_y_(translate_y) {}
84 return DlPoint(in_point.x * scale_x_ + translate_x_,
85 in_point.y * scale_y_ + translate_y_);
88 DlPathBuilder path_builder_;
92 PathReflector reflector =
93 PathReflector::ReflectAroundY(path.GetBounds().GetCenter().y);
94 path.Dispatch(reflector);
95 return reflector.TakePath();
98 void DrawShadowMesh(DisplayListBuilder& builder,
102 bool should_optimize = path.IsConvex();
103 Matrix matrix = builder.GetMatrix();
106 Scalar light_radius = 800 / 600;
107 EXPECT_EQ(light_radius, 1.0f);
108 Scalar occluder_z = elevation * dpr;
109 Radius radius = Radius{light_radius * occluder_z / matrix.GetScale().y};
110 Sigma sigma = radius;
113 Scalar device_radius = sigma.sigma * 2.8 * matrix.GetMaxBasisLengthXY();
115 Tessellator tessellator;
116 std::shared_ptr<ShadowVertices> shadow_vertices =
118 device_radius, matrix);
119 EXPECT_EQ(shadow_vertices !=
nullptr, should_optimize);
120 Point shadow_translate =
Point(0, occluder_z) * matrix.Invert().GetScale().
y;
123 paint.setDrawStyle(DlDrawStyle::kStroke);
124 paint.setColor(DlColor::kDarkGrey());
126 if (shadow_vertices) {
128 builder.Translate(shadow_translate.x, shadow_translate.y);
129 auto indices = shadow_vertices->GetIndices();
130 auto vertices = shadow_vertices->GetVertices();
131 DlPathBuilder mesh_builder;
132 for (
size_t i = 0; i < shadow_vertices->GetIndexCount(); i += 3) {
133 mesh_builder.MoveTo(vertices[indices[i + 0]]);
134 mesh_builder.LineTo(vertices[indices[i + 1]]);
135 mesh_builder.LineTo(vertices[indices[i + 2]]);
136 mesh_builder.Close();
138 DlPath mesh_path = mesh_builder.TakePath();
139 builder.DrawPath(mesh_path, paint);
144 builder.Translate(shadow_translate.x, shadow_translate.y);
145 paint.setColor(DlColor::kPurple());
146 builder.DrawPath(path, paint);
151 DlPathBuilder path_builder;
152 path_builder.AddPath(path);
157 path_builder.LineTo(
DlPoint(0, 0));
158 return path_builder.TakePath();
161 void DrawShadowAndCompareMeshes(DisplayListBuilder& builder,
165 const DlPath* simple_path =
nullptr) {
166 DlPath complex_path = MakeComplexPath(path);
171 builder.DrawShadow(*simple_path, DlColor::kBlue(), elevation,
true, dpr);
174 builder.Translate(300, 0);
175 builder.DrawShadow(path, DlColor::kBlue(), elevation,
true, dpr);
177 builder.Translate(300, 0);
178 builder.DrawShadow(complex_path, DlColor::kBlue(), elevation,
true, dpr);
181 builder.Translate(0, 300);
186 builder.Translate(300, 0);
187 builder.DrawShadow(path, DlColor::kBlue(), elevation,
true, dpr);
188 DrawShadowMesh(builder, path, elevation, dpr);
195 DlPath MakeAlmostRoundRectPath(
const Rect& bounds,
196 const RoundingRadii& radii,
197 bool clockwise =
true) {
201 DlScalar bottom = bounds.GetBottom();
208 DlPathBuilder path_builder;
209 path_builder.MoveTo(
DlPoint(right - radii.top_right.width, top));
210 path_builder.ConicCurveTo(
DlPoint(right, top),
211 DlPoint(right, top + radii.top_right.height),
213 path_builder.LineTo(
DlPoint(right, bottom - radii.bottom_right.height));
214 path_builder.ConicCurveTo(
DlPoint(right, bottom),
215 DlPoint(right - radii.bottom_right.width, bottom),
217 path_builder.LineTo(
DlPoint(left + radii.bottom_left.width, bottom));
218 path_builder.ConicCurveTo(
DlPoint(left, bottom),
219 DlPoint(left, bottom - radii.bottom_left.height),
221 path_builder.LineTo(
DlPoint(left, top + radii.top_left.height));
222 path_builder.ConicCurveTo(
DlPoint(left, top),
223 DlPoint(left + radii.top_left.width, top),
225 path_builder.Close();
226 DlPath path = path_builder.TakePath();
228 path = ReflectPath(path);
235 DisplayListBuilder builder;
236 builder.Clear(DlColor::kWhite());
237 builder.Scale(GetContentScale().
x, GetContentScale().y);
238 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
241 DlPathBuilder path_builder;
242 path_builder.MoveTo(
DlPoint(100, 100));
243 path_builder.LineTo(
DlPoint(300, 300));
244 path_builder.LineTo(
DlPoint(100, 300));
245 path_builder.LineTo(
DlPoint(300, 100));
246 path_builder.Close();
247 DlPath path = path_builder.TakePath();
249 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
251 auto dl = builder.Build();
252 ASSERT_TRUE(OpenPlaygroundHere(dl));
256 DisplayListBuilder builder;
257 builder.Clear(DlColor::kWhite());
258 builder.Scale(GetContentScale().
x, GetContentScale().y);
259 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
263 DlPathBuilder path_builder;
264 path_builder.MoveTo(
DlPoint(300, 200));
265 for (
int i = 1; i < step_count * 2; i++) {
267 Scalar radius = 80.0f + std::abs(i - step_count);
268 path_builder.LineTo(
DlPoint(200, 200) +
DlPoint(std::cos(angle) * radius,
269 std::sin(angle) * radius));
271 path_builder.Close();
272 DlPath path = path_builder.TakePath();
274 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
276 auto dl = builder.Build();
277 ASSERT_TRUE(OpenPlaygroundHere(dl));
281 DisplayListBuilder builder;
282 builder.Clear(DlColor::kWhite());
283 builder.Scale(GetContentScale().
x, GetContentScale().y);
284 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
288 DlPathBuilder path_builder;
289 path_builder.MoveTo(
DlPoint(280, 200));
290 for (
int i = 1; i < step_count * 2; i++) {
292 Scalar radius = 100.0f - std::abs(i - step_count);
293 path_builder.LineTo(
DlPoint(200, 200) +
DlPoint(std::cos(angle) * radius,
294 std::sin(angle) * radius));
296 path_builder.Close();
297 DlPath path = path_builder.TakePath();
299 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
301 auto dl = builder.Build();
302 ASSERT_TRUE(OpenPlaygroundHere(dl));
306 DisplayListBuilder builder;
307 builder.Clear(DlColor::kWhite());
308 builder.Scale(GetContentScale().
x, GetContentScale().y);
309 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
312 DlPathBuilder path_builder;
313 path_builder.MoveTo(
DlPoint(150, 100));
314 path_builder.LineTo(
DlPoint(200, 300));
315 path_builder.LineTo(
DlPoint(100, 300));
316 path_builder.Close();
317 path_builder.MoveTo(
DlPoint(250, 100));
318 path_builder.LineTo(
DlPoint(300, 300));
319 path_builder.LineTo(
DlPoint(200, 300));
320 path_builder.Close();
321 DlPath path = path_builder.TakePath();
323 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
325 auto dl = builder.Build();
326 ASSERT_TRUE(OpenPlaygroundHere(dl));
330 DisplayListBuilder builder;
331 builder.Clear(DlColor::kWhite());
332 builder.Scale(GetContentScale().
x, GetContentScale().y);
333 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
336 DlPathBuilder path_builder;
337 path_builder.MoveTo(
DlPoint(200, 100));
338 path_builder.LineTo(
DlPoint(300, 300));
339 path_builder.LineTo(
DlPoint(100, 300));
340 path_builder.Close();
341 DlPath path = path_builder.TakePath();
343 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
345 auto dl = builder.Build();
346 ASSERT_TRUE(OpenPlaygroundHere(dl));
350 DisplayListBuilder builder;
351 builder.Clear(DlColor::kWhite());
352 builder.Scale(GetContentScale().
x, GetContentScale().y);
353 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
356 DlPathBuilder path_builder;
357 path_builder.MoveTo(
DlPoint(200, 100));
358 path_builder.LineTo(
DlPoint(100, 300));
359 path_builder.LineTo(
DlPoint(300, 300));
360 path_builder.Close();
361 DlPath path = path_builder.TakePath();
363 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
365 auto dl = builder.Build();
366 ASSERT_TRUE(OpenPlaygroundHere(dl));
370 DisplayListBuilder builder;
371 builder.Clear(DlColor::kWhite());
372 builder.Scale(GetContentScale().
x, GetContentScale().y);
373 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
376 DlPathBuilder path_builder;
377 path_builder.MoveTo(
DlPoint(100, 100));
380 path_builder.LineTo(
DlPoint(299.9, 100));
381 path_builder.LineTo(
DlPoint(300, 300));
382 path_builder.LineTo(
DlPoint(100, 300));
383 path_builder.Close();
384 DlPath path = path_builder.TakePath();
387 ASSERT_TRUE(path.IsConvex());
388 ASSERT_FALSE(path.IsRect());
389 ASSERT_FALSE(path.IsOval());
390 ASSERT_FALSE(path.IsRoundRect());
392 const DlPath simple_path = DlPath::MakeRectLTRB(100, 100, 300, 300);
393 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
395 auto dl = builder.Build();
396 ASSERT_TRUE(OpenPlaygroundHere(dl));
400 DisplayListBuilder builder;
401 builder.Clear(DlColor::kWhite());
402 builder.Scale(GetContentScale().
x, GetContentScale().y);
403 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
406 DlPathBuilder path_builder;
407 path_builder.MoveTo(
DlPoint(100, 100));
408 path_builder.LineTo(
DlPoint(100, 300));
409 path_builder.LineTo(
DlPoint(300, 300));
412 path_builder.LineTo(
DlPoint(299.9, 100));
413 path_builder.Close();
414 DlPath path = path_builder.TakePath();
417 ASSERT_TRUE(path.IsConvex());
418 ASSERT_FALSE(path.IsRect());
419 ASSERT_FALSE(path.IsOval());
420 ASSERT_FALSE(path.IsRoundRect());
422 const DlPath simple_path = DlPath::MakeRectLTRB(100, 100, 300, 300);
423 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
425 auto dl = builder.Build();
426 ASSERT_TRUE(OpenPlaygroundHere(dl));
430 DisplayListBuilder builder;
431 builder.Clear(DlColor::kWhite());
432 builder.Scale(GetContentScale().
x, GetContentScale().y);
433 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
441 DlPathBuilder path_builder;
442 path_builder.MoveTo(
DlPoint(200, 100));
443 path_builder.ConicCurveTo(
DlPoint(300, 100),
DlPoint(300, 200), kWeight);
444 path_builder.ConicCurveTo(
DlPoint(300, 300),
DlPoint(200, 300), kWeight);
445 path_builder.ConicCurveTo(
DlPoint(100, 300),
DlPoint(100, 200), kWeight);
446 path_builder.ConicCurveTo(
DlPoint(100, 100),
DlPoint(200, 100), kWeight);
447 path_builder.Close();
448 DlPath path = path_builder.TakePath();
451 ASSERT_TRUE(path.IsConvex());
452 ASSERT_FALSE(path.IsRect());
453 ASSERT_FALSE(path.IsOval());
454 ASSERT_FALSE(path.IsRoundRect());
456 const DlPath simple_path = DlPath::MakeCircle(
DlPoint(200, 200), 100);
457 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
459 auto dl = builder.Build();
460 ASSERT_TRUE(OpenPlaygroundHere(dl));
464 DisplayListBuilder builder;
465 builder.Clear(DlColor::kWhite());
466 builder.Scale(GetContentScale().
x, GetContentScale().y);
467 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
475 DlPathBuilder path_builder;
476 path_builder.MoveTo(
DlPoint(200, 100));
477 path_builder.ConicCurveTo(
DlPoint(100, 100),
DlPoint(100, 200), kWeight);
478 path_builder.ConicCurveTo(
DlPoint(100, 300),
DlPoint(200, 300), kWeight);
479 path_builder.ConicCurveTo(
DlPoint(300, 300),
DlPoint(300, 200), kWeight);
480 path_builder.ConicCurveTo(
DlPoint(300, 100),
DlPoint(200, 100), kWeight);
481 path_builder.Close();
482 DlPath path = path_builder.TakePath();
485 ASSERT_TRUE(path.IsConvex());
486 ASSERT_FALSE(path.IsRect());
487 ASSERT_FALSE(path.IsOval());
488 ASSERT_FALSE(path.IsRoundRect());
490 const DlPath simple_path = DlPath::MakeCircle(
DlPoint(200, 200), 100);
491 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
493 auto dl = builder.Build();
494 ASSERT_TRUE(OpenPlaygroundHere(dl));
498 DisplayListBuilder builder;
499 builder.Clear(DlColor::kWhite());
500 builder.Scale(GetContentScale().
x, GetContentScale().y);
501 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
509 DlPathBuilder path_builder;
510 path_builder.MoveTo(
DlPoint(200, 120));
511 path_builder.ConicCurveTo(
DlPoint(300, 120),
DlPoint(300, 200), kWeight);
512 path_builder.ConicCurveTo(
DlPoint(300, 280),
DlPoint(200, 280), kWeight);
513 path_builder.ConicCurveTo(
DlPoint(100, 280),
DlPoint(100, 200), kWeight);
514 path_builder.ConicCurveTo(
DlPoint(100, 120),
DlPoint(200, 120), kWeight);
515 path_builder.Close();
516 DlPath path = path_builder.TakePath();
519 ASSERT_TRUE(path.IsConvex());
520 ASSERT_FALSE(path.IsRect());
521 ASSERT_FALSE(path.IsOval());
522 ASSERT_FALSE(path.IsRoundRect());
524 const DlPath simple_path = DlPath::MakeOvalLTRB(100, 120, 300, 280);
525 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
527 auto dl = builder.Build();
528 ASSERT_TRUE(OpenPlaygroundHere(dl));
532 DisplayListBuilder builder;
533 builder.Clear(DlColor::kWhite());
534 builder.Scale(GetContentScale().
x, GetContentScale().y);
535 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
543 DlPathBuilder path_builder;
544 path_builder.MoveTo(
DlPoint(200, 120));
545 path_builder.ConicCurveTo(
DlPoint(100, 120),
DlPoint(100, 200), kWeight);
546 path_builder.ConicCurveTo(
DlPoint(100, 280),
DlPoint(200, 280), kWeight);
547 path_builder.ConicCurveTo(
DlPoint(300, 280),
DlPoint(300, 200), kWeight);
548 path_builder.ConicCurveTo(
DlPoint(300, 120),
DlPoint(200, 120), kWeight);
549 path_builder.Close();
550 DlPath path = path_builder.TakePath();
553 ASSERT_TRUE(path.IsConvex());
554 ASSERT_FALSE(path.IsRect());
555 ASSERT_FALSE(path.IsOval());
556 ASSERT_FALSE(path.IsRoundRect());
558 const DlPath simple_path = DlPath::MakeOvalLTRB(100, 120, 300, 280);
559 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
561 auto dl = builder.Build();
562 ASSERT_TRUE(OpenPlaygroundHere(dl));
566 DisplayListBuilder builder;
567 builder.Clear(DlColor::kWhite());
568 builder.Scale(GetContentScale().
x, GetContentScale().y);
569 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
572 DlPath path = MakeAlmostRoundRectPath(DlRect::MakeLTRB(100, 100, 300, 300),
573 DlRoundingRadii::MakeRadius(30),
true);
576 ASSERT_TRUE(path.IsConvex());
577 ASSERT_FALSE(path.IsRect());
578 ASSERT_FALSE(path.IsOval());
579 ASSERT_FALSE(path.IsRoundRect());
583 const DlPath simple_path = DlPath::MakeRoundRect(round_rect);
584 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
586 auto dl = builder.Build();
587 ASSERT_TRUE(OpenPlaygroundHere(dl));
591 DisplayListBuilder builder;
592 builder.Clear(DlColor::kWhite());
593 builder.Scale(GetContentScale().
x, GetContentScale().y);
594 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
597 DlPath path = MakeAlmostRoundRectPath(DlRect::MakeLTRB(100, 100, 300, 300),
598 DlRoundingRadii::MakeRadius(30),
false);
601 ASSERT_TRUE(path.IsConvex());
602 ASSERT_FALSE(path.IsRect());
603 ASSERT_FALSE(path.IsOval());
604 ASSERT_FALSE(path.IsRoundRect());
608 const DlPath simple_path = DlPath::MakeRoundRect(round_rect);
609 DrawShadowAndCompareMeshes(builder, path, elevation, dpr, &simple_path);
611 auto dl = builder.Build();
612 ASSERT_TRUE(OpenPlaygroundHere(dl));
616 DisplayListBuilder builder;
617 builder.Clear(DlColor::kWhite());
618 builder.Scale(GetContentScale().
x, GetContentScale().y);
619 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
622 DlRoundingRadii radii = DlRoundingRadii{
623 .top_left = {80, 60},
624 .top_right = {20, 25},
625 .bottom_left = {60, 80},
626 .bottom_right = {25, 20},
628 DlPath path = MakeAlmostRoundRectPath(DlRect::MakeLTRB(100, 100, 300, 300),
632 ASSERT_TRUE(path.IsConvex());
633 ASSERT_FALSE(path.IsRect());
634 ASSERT_FALSE(path.IsOval());
635 ASSERT_FALSE(path.IsRoundRect());
637 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
639 auto dl = builder.Build();
640 ASSERT_TRUE(OpenPlaygroundHere(dl));
644 DisplayListBuilder builder;
645 builder.Clear(DlColor::kWhite());
646 builder.Scale(GetContentScale().
x, GetContentScale().y);
647 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
650 DlRoundingRadii radii = DlRoundingRadii{
651 .top_left = {80, 60},
652 .top_right = {20, 25},
653 .bottom_left = {60, 80},
654 .bottom_right = {25, 20},
656 DlPath path = MakeAlmostRoundRectPath(DlRect::MakeLTRB(100, 100, 300, 300),
660 ASSERT_TRUE(path.IsConvex());
661 ASSERT_FALSE(path.IsRect());
662 ASSERT_FALSE(path.IsOval());
663 ASSERT_FALSE(path.IsRoundRect());
665 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
667 auto dl = builder.Build();
668 ASSERT_TRUE(OpenPlaygroundHere(dl));
672 DisplayListBuilder builder;
673 builder.Clear(DlColor::kWhite());
674 builder.Scale(GetContentScale().
x, GetContentScale().y);
675 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
678 DlPathBuilder path_builder;
679 path_builder.MoveTo(
DlPoint(200, 100));
680 path_builder.QuadraticCurveTo(
DlPoint(300, 100),
DlPoint(300, 200));
681 path_builder.QuadraticCurveTo(
DlPoint(300, 300),
DlPoint(200, 300));
682 path_builder.QuadraticCurveTo(
DlPoint(100, 300),
DlPoint(100, 200));
683 path_builder.QuadraticCurveTo(
DlPoint(100, 100),
DlPoint(200, 100));
684 path_builder.Close();
685 DlPath path = path_builder.TakePath();
687 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
689 auto dl = builder.Build();
690 ASSERT_TRUE(OpenPlaygroundHere(dl));
694 DisplayListBuilder builder;
695 builder.Clear(DlColor::kWhite());
696 builder.Scale(GetContentScale().
x, GetContentScale().y);
697 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
700 DlPathBuilder path_builder;
701 path_builder.MoveTo(
DlPoint(200, 100));
702 path_builder.QuadraticCurveTo(
DlPoint(100, 100),
DlPoint(100, 200));
703 path_builder.QuadraticCurveTo(
DlPoint(100, 300),
DlPoint(200, 300));
704 path_builder.QuadraticCurveTo(
DlPoint(300, 300),
DlPoint(300, 200));
705 path_builder.QuadraticCurveTo(
DlPoint(300, 100),
DlPoint(200, 100));
706 path_builder.Close();
707 DlPath path = path_builder.TakePath();
709 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
711 auto dl = builder.Build();
712 ASSERT_TRUE(OpenPlaygroundHere(dl));
716 DisplayListBuilder builder;
717 builder.Clear(DlColor::kWhite());
718 builder.Scale(GetContentScale().
x, GetContentScale().y);
719 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
722 DlPathBuilder path_builder;
723 path_builder.MoveTo(
DlPoint(200, 100));
724 path_builder.ConicCurveTo(
DlPoint(300, 100),
DlPoint(300, 200), 0.4f);
725 path_builder.ConicCurveTo(
DlPoint(300, 300),
DlPoint(200, 300), 0.4f);
726 path_builder.ConicCurveTo(
DlPoint(100, 300),
DlPoint(100, 200), 0.4f);
727 path_builder.ConicCurveTo(
DlPoint(100, 100),
DlPoint(200, 100), 0.4f);
728 path_builder.Close();
729 DlPath path = path_builder.TakePath();
731 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
733 auto dl = builder.Build();
734 ASSERT_TRUE(OpenPlaygroundHere(dl));
738 DisplayListBuilder builder;
739 builder.Clear(DlColor::kWhite());
740 builder.Scale(GetContentScale().
x, GetContentScale().y);
741 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
744 DlPathBuilder path_builder;
745 path_builder.MoveTo(
DlPoint(200, 100));
746 path_builder.ConicCurveTo(
DlPoint(100, 100),
DlPoint(100, 200), 0.4f);
747 path_builder.ConicCurveTo(
DlPoint(100, 300),
DlPoint(200, 300), 0.4f);
748 path_builder.ConicCurveTo(
DlPoint(300, 300),
DlPoint(300, 200), 0.4f);
749 path_builder.ConicCurveTo(
DlPoint(300, 100),
DlPoint(200, 100), 0.4f);
750 path_builder.Close();
751 DlPath path = path_builder.TakePath();
753 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
755 auto dl = builder.Build();
756 ASSERT_TRUE(OpenPlaygroundHere(dl));
760 DisplayListBuilder builder;
761 builder.Clear(DlColor::kWhite());
762 builder.Scale(GetContentScale().
x, GetContentScale().y);
763 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
766 DlPathBuilder path_builder;
767 path_builder.MoveTo(
DlPoint(200, 100));
776 path_builder.Close();
777 DlPath path = path_builder.TakePath();
779 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
781 auto dl = builder.Build();
782 ASSERT_TRUE(OpenPlaygroundHere(dl));
786 DisplayListBuilder builder;
787 builder.Clear(DlColor::kWhite());
788 builder.Scale(GetContentScale().
x, GetContentScale().y);
789 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
792 DlPathBuilder path_builder;
793 path_builder.MoveTo(
DlPoint(200, 100));
802 path_builder.Close();
803 DlPath path = path_builder.TakePath();
805 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
807 auto dl = builder.Build();
808 ASSERT_TRUE(OpenPlaygroundHere(dl));
812 DisplayListBuilder builder;
813 builder.Clear(DlColor::kWhite());
814 builder.Scale(GetContentScale().
x, GetContentScale().y);
815 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
818 DlPathBuilder path_builder;
819 path_builder.MoveTo(
DlPoint(100, 125));
820 path_builder.LineTo(
DlPoint(125, 100));
821 path_builder.LineTo(
DlPoint(275, 100));
822 path_builder.LineTo(
DlPoint(300, 125));
823 path_builder.LineTo(
DlPoint(300, 275));
824 path_builder.LineTo(
DlPoint(275, 300));
825 path_builder.LineTo(
DlPoint(125, 300));
826 path_builder.LineTo(
DlPoint(100, 275));
827 path_builder.Close();
828 DlPath path = path_builder.TakePath();
830 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
832 auto dl = builder.Build();
833 ASSERT_TRUE(OpenPlaygroundHere(dl));
837 DisplayListBuilder builder;
838 builder.Clear(DlColor::kWhite());
839 builder.Scale(GetContentScale().
x, GetContentScale().y);
840 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
843 DlPathBuilder path_builder;
844 path_builder.MoveTo(
DlPoint(100, 125));
845 path_builder.LineTo(
DlPoint(100, 275));
846 path_builder.LineTo(
DlPoint(125, 300));
847 path_builder.LineTo(
DlPoint(275, 300));
848 path_builder.LineTo(
DlPoint(300, 275));
849 path_builder.LineTo(
DlPoint(300, 125));
850 path_builder.LineTo(
DlPoint(275, 100));
851 path_builder.LineTo(
DlPoint(125, 100));
852 path_builder.Close();
853 DlPath path = path_builder.TakePath();
855 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
857 auto dl = builder.Build();
858 ASSERT_TRUE(OpenPlaygroundHere(dl));
862 DisplayListBuilder builder;
863 builder.Clear(DlColor::kWhite());
864 builder.Scale(GetContentScale().
x, GetContentScale().y);
865 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
868 DlPathBuilder path_builder;
869 path_builder.MoveTo(
DlPoint(0, 0));
870 path_builder.MoveTo(
DlPoint(1000, 1000));
871 path_builder.MoveTo(
DlPoint(100, 50));
872 path_builder.MoveTo(
DlPoint(200, 100));
873 path_builder.LineTo(
DlPoint(300, 300));
874 path_builder.LineTo(
DlPoint(100, 300));
875 path_builder.Close();
876 path_builder.MoveTo(
DlPoint(1000, 1000));
877 path_builder.MoveTo(
DlPoint(500, 300));
878 DlPath path = path_builder.TakePath();
880 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
882 auto dl = builder.Build();
883 ASSERT_TRUE(OpenPlaygroundHere(dl));
887 DisplayListBuilder builder;
888 builder.Clear(DlColor::kWhite());
889 builder.Scale(GetContentScale().
x, GetContentScale().y);
890 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
893 DlPathBuilder path_builder;
894 path_builder.MoveTo(
DlPoint(200, 100));
895 path_builder.LineTo(
DlPoint(250, 200));
896 path_builder.LineTo(
DlPoint(300, 300));
897 path_builder.LineTo(
DlPoint(200, 300));
898 path_builder.LineTo(
DlPoint(100, 300));
899 path_builder.LineTo(
DlPoint(150, 200));
900 path_builder.Close();
901 DlPath path = path_builder.TakePath();
903 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
905 auto dl = builder.Build();
906 ASSERT_TRUE(OpenPlaygroundHere(dl));
910 DrawShadowCanOptimizeCounterClockwiseWithExtraColinearVertices) {
911 DisplayListBuilder builder;
912 builder.Clear(DlColor::kWhite());
913 builder.Scale(GetContentScale().
x, GetContentScale().y);
914 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().y);
917 DlPathBuilder path_builder;
918 path_builder.MoveTo(
DlPoint(200, 100));
919 path_builder.LineTo(
DlPoint(150, 200));
920 path_builder.LineTo(
DlPoint(100, 300));
921 path_builder.LineTo(
DlPoint(200, 300));
922 path_builder.LineTo(
DlPoint(300, 300));
923 path_builder.LineTo(
DlPoint(250, 200));
924 path_builder.Close();
925 DlPath path = path_builder.TakePath();
927 DrawShadowAndCompareMeshes(builder, path, elevation, dpr);
929 auto dl = builder.Build();
930 ASSERT_TRUE(OpenPlaygroundHere(dl));
static std::shared_ptr< ShadowVertices > MakeAmbientShadowVertices(Tessellator &tessellator, const PathSource &source, Scalar occluder_height, const Matrix &matrix)
TEST_P(AiksTest, DrawAtlasNoColor)
constexpr float kSqrt2Over2
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void CubicTo(PathBuilder *builder, Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar x3, Scalar y3)
flutter::DlScalar DlScalar
void Close(PathBuilder *builder)
static RoundRect MakeRectRadius(const Rect &rect, Scalar radius)
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)