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_);
92 PathReflector reflector =
93 PathReflector::ReflectAroundY(
path.GetBounds().GetCenter().y);
94 path.Dispatch(reflector);
95 return reflector.TakePath();
102 bool should_optimize =
path.IsConvex();
106 Scalar light_radius = 800 / 600;
107 EXPECT_EQ(light_radius, 1.0f);
108 Scalar occluder_z = elevation * dpr;
110 Sigma sigma = radius;
116 std::shared_ptr<ShadowVertices> shadow_vertices =
118 device_radius, matrix);
119 EXPECT_EQ(shadow_vertices !=
nullptr, should_optimize);
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();
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();
144 builder.
Translate(shadow_translate.
x, shadow_translate.
y);
165 const DlPath* simple_path =
nullptr) {
188 DrawShadowMesh(builder,
path, elevation, dpr);
195DlPath MakeAlmostRoundRectPath(
const Rect& bounds,
197 bool clockwise =
true) {
201 DlScalar bottom = bounds.GetBottom();
225 path_builder.
Close();
237 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
238 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
246 path_builder.
Close();
249 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
251 auto dl = builder.
Build();
252 ASSERT_TRUE(OpenPlaygroundHere(dl));
258 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
259 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
265 for (
int i = 1;
i < step_count * 2;
i++) {
267 Scalar radius = 80.0f + std::abs(
i - step_count);
269 std::sin(angle) * radius));
271 path_builder.
Close();
274 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
276 auto dl = builder.
Build();
277 ASSERT_TRUE(OpenPlaygroundHere(dl));
283 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
284 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
290 for (
int i = 1;
i < step_count * 2;
i++) {
292 Scalar radius = 100.0f - std::abs(
i - step_count);
294 std::sin(angle) * radius));
296 path_builder.
Close();
299 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
301 auto dl = builder.
Build();
302 ASSERT_TRUE(OpenPlaygroundHere(dl));
308 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
309 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
316 path_builder.
Close();
320 path_builder.
Close();
323 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
325 auto dl = builder.
Build();
326 ASSERT_TRUE(OpenPlaygroundHere(dl));
332 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
333 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
340 path_builder.
Close();
343 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
345 auto dl = builder.
Build();
346 ASSERT_TRUE(OpenPlaygroundHere(dl));
352 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
353 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
360 path_builder.
Close();
363 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
365 auto dl = builder.
Build();
366 ASSERT_TRUE(OpenPlaygroundHere(dl));
372 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
373 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
383 path_builder.
Close();
387 ASSERT_TRUE(
path.IsConvex());
388 ASSERT_FALSE(
path.IsRect());
389 ASSERT_FALSE(
path.IsOval());
390 ASSERT_FALSE(
path.IsRoundRect());
393 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
395 auto dl = builder.
Build();
396 ASSERT_TRUE(OpenPlaygroundHere(dl));
402 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
403 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
413 path_builder.
Close();
417 ASSERT_TRUE(
path.IsConvex());
418 ASSERT_FALSE(
path.IsRect());
419 ASSERT_FALSE(
path.IsOval());
420 ASSERT_FALSE(
path.IsRoundRect());
423 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
425 auto dl = builder.
Build();
426 ASSERT_TRUE(OpenPlaygroundHere(dl));
432 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
433 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
447 path_builder.
Close();
451 ASSERT_TRUE(
path.IsConvex());
452 ASSERT_FALSE(
path.IsRect());
453 ASSERT_FALSE(
path.IsOval());
454 ASSERT_FALSE(
path.IsRoundRect());
457 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
459 auto dl = builder.
Build();
460 ASSERT_TRUE(OpenPlaygroundHere(dl));
466 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
467 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
481 path_builder.
Close();
485 ASSERT_TRUE(
path.IsConvex());
486 ASSERT_FALSE(
path.IsRect());
487 ASSERT_FALSE(
path.IsOval());
488 ASSERT_FALSE(
path.IsRoundRect());
491 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
493 auto dl = builder.
Build();
494 ASSERT_TRUE(OpenPlaygroundHere(dl));
500 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
501 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
515 path_builder.
Close();
519 ASSERT_TRUE(
path.IsConvex());
520 ASSERT_FALSE(
path.IsRect());
521 ASSERT_FALSE(
path.IsOval());
522 ASSERT_FALSE(
path.IsRoundRect());
525 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
527 auto dl = builder.
Build();
528 ASSERT_TRUE(OpenPlaygroundHere(dl));
534 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
535 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
549 path_builder.
Close();
553 ASSERT_TRUE(
path.IsConvex());
554 ASSERT_FALSE(
path.IsRect());
555 ASSERT_FALSE(
path.IsOval());
556 ASSERT_FALSE(
path.IsRoundRect());
559 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
561 auto dl = builder.
Build();
562 ASSERT_TRUE(OpenPlaygroundHere(dl));
568 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
569 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
576 ASSERT_TRUE(
path.IsConvex());
577 ASSERT_FALSE(
path.IsRect());
578 ASSERT_FALSE(
path.IsOval());
579 ASSERT_FALSE(
path.IsRoundRect());
584 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
586 auto dl = builder.
Build();
587 ASSERT_TRUE(OpenPlaygroundHere(dl));
593 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
594 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
601 ASSERT_TRUE(
path.IsConvex());
602 ASSERT_FALSE(
path.IsRect());
603 ASSERT_FALSE(
path.IsOval());
604 ASSERT_FALSE(
path.IsRoundRect());
609 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr, &simple_path);
611 auto dl = builder.
Build();
612 ASSERT_TRUE(OpenPlaygroundHere(dl));
618 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
619 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
624 .top_right = {20, 25},
625 .bottom_left = {60, 80},
626 .bottom_right = {25, 20},
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));
646 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
647 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
652 .top_right = {20, 25},
653 .bottom_left = {60, 80},
654 .bottom_right = {25, 20},
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));
674 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
675 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
684 path_builder.
Close();
687 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
689 auto dl = builder.
Build();
690 ASSERT_TRUE(OpenPlaygroundHere(dl));
696 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
697 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
706 path_builder.
Close();
709 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
711 auto dl = builder.
Build();
712 ASSERT_TRUE(OpenPlaygroundHere(dl));
718 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
719 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
728 path_builder.
Close();
731 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
733 auto dl = builder.
Build();
734 ASSERT_TRUE(OpenPlaygroundHere(dl));
740 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
741 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
750 path_builder.
Close();
753 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
755 auto dl = builder.
Build();
756 ASSERT_TRUE(OpenPlaygroundHere(dl));
762 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
763 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
776 path_builder.
Close();
779 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
781 auto dl = builder.
Build();
782 ASSERT_TRUE(OpenPlaygroundHere(dl));
788 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
789 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
802 path_builder.
Close();
805 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
807 auto dl = builder.
Build();
808 ASSERT_TRUE(OpenPlaygroundHere(dl));
814 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
815 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
827 path_builder.
Close();
830 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
832 auto dl = builder.
Build();
833 ASSERT_TRUE(OpenPlaygroundHere(dl));
839 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
840 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
852 path_builder.
Close();
855 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
857 auto dl = builder.
Build();
858 ASSERT_TRUE(OpenPlaygroundHere(dl));
864 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
865 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
875 path_builder.
Close();
880 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
882 auto dl = builder.
Build();
883 ASSERT_TRUE(OpenPlaygroundHere(dl));
889 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
890 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
900 path_builder.
Close();
903 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
905 auto dl = builder.
Build();
906 ASSERT_TRUE(OpenPlaygroundHere(dl));
910 DrawShadowCanOptimizeCounterClockwiseWithExtraColinearVertices) {
913 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
914 Scalar dpr = std::max(GetContentScale().
x, GetContentScale().
y);
924 path_builder.
Close();
927 DrawShadowAndCompareMeshes(builder,
path, elevation, dpr);
929 auto dl = builder.
Build();
930 ASSERT_TRUE(OpenPlaygroundHere(dl));
void DrawShadow(const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
Draws the shadow of the given |path| rendered in the provided |color| (which is only consulted for it...
DlMatrix GetMatrix() const override
void Scale(DlScalar sx, DlScalar sy) override
void Translate(DlScalar tx, DlScalar ty) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void Clear(DlColor color)
DlPaint & setColor(DlColor color)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & AddPath(const DlPath &path)
Append the provided path to this path as if the commands used to construct it were repeated on this p...
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & ConicCurveTo(DlPoint cp, DlPoint p2, DlScalar weight)
Draw a conic curve (a rational quadratic bezier curve) from the current point to the indicated point ...
DlPathBuilder & QuadraticCurveTo(DlPoint cp, DlPoint p2)
Draw a quadratic bezier curve from the current point to the indicated point p2, using the indicated p...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
static DlPath MakeRectLTRB(DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
static DlPath MakeRoundRect(const DlRoundRect &rrect)
static DlPath MakeCircle(const DlPoint center, DlScalar radius)
static DlPath MakeOvalLTRB(DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
Collection of functions to receive path segments from the underlying path representation via the DlPa...
static std::shared_ptr< ShadowVertices > MakeAmbientShadowVertices(Tessellator &tessellator, const PathSource &source, Scalar occluder_height, const Matrix &matrix)
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
impeller::Scalar DlScalar
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
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)
void Close(PathBuilder *builder)
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor kPurple()
static constexpr DlColor kDarkGrey()
A 4x4 matrix using column-major storage.
Scalar GetMaxBasisLengthXY() const
Return the maximum scale applied specifically to either the X axis or Y axis unit vectors (the bases)...
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
static RoundRect MakeRectRadius(const Rect &rect, Scalar radius)
static constexpr RoundingRadii MakeRadius(Scalar radius)
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)