54 auto dl = builder.
Build();
55 ASSERT_TRUE(OpenPlaygroundHere(dl));
68 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
80 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
92 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
104 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
119 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
136 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
156 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
161 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
206 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
211 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
261 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
269 auto callback = [&]() -> sk_sp<DisplayList> {
271 ImGuiWindowFlags_AlwaysAutoResize)) {
272 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
273 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
274 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
275 ImGui::SliderFloat(
"Width", &
width, 0, 2);
280 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
291 builder.
Scale(scale, scale);
295 for (
int i = 0;
i < 5; ++
i) {
296 Scalar yoffset =
i * 25.25f + 300.f;
304 return builder.
Build();
307 ASSERT_TRUE(OpenPlaygroundHere(
callback));
314 auto callback = [&]() -> sk_sp<DisplayList> {
316 ImGuiWindowFlags_AlwaysAutoResize)) {
317 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
318 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
319 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
324 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
332 builder.
Scale(scale, scale);
336 for (
int i = 0;
i < 5; ++
i) {
337 Scalar yoffset =
i * 25.25f + 300.f;
342 return builder.
Build();
345 ASSERT_TRUE(OpenPlaygroundHere(
callback));
350 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
370 reference_builder.
MoveTo(component.p1);
371 constexpr int N = 100;
372 for (
int i = 1;
i < N;
i++) {
373 reference_builder.
LineTo(component.Solve(
static_cast<Scalar>(
i) / N));
375 reference_builder.
LineTo(component.p2);
394 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
405 .top_right = {25, 50},
406 .bottom_left = {25, 50},
407 .bottom_right = {50, 25},
424 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
450 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
463 path_builder.
Close();
472 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
477 auto callback = [&]() -> sk_sp<DisplayList> {
479 static float scale = 3;
480 static bool add_circle_clip =
true;
483 ImGuiWindowFlags_AlwaysAutoResize)) {
484 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&color));
485 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
486 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
491 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
505 path_builder.
Close();
510 builder.
Scale(scale, scale);
512 if (add_circle_clip) {
517 auto [handle_a, handle_b] =
524 screen_to_canvas = screen_to_canvas.
Invert();
526 Point point_a = screen_to_canvas * handle_a;
527 Point point_b = screen_to_canvas * handle_b;
529 Point middle = point_a + point_b;
530 middle *= GetContentScale().
x / 2;
532 auto radius = point_a.GetDistance(middle);
538 {DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
541 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
549 return builder.
Build();
552 ASSERT_TRUE(OpenPlaygroundHere(
callback));
557 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
563 auto draw = [&builder](
DlPaint& paint) {
565 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
569 for (
int d = 15;
d < 90;
d += 15) {
571 Point origin = {100, 100};
574 auto a = origin + m * p0;
575 auto b = origin + m *
p1;
589 std::vector<DlColor> colors = {
597 std::vector<Scalar> stops = {
608 CreateTextureForFixture(
"airplane.jpg",
614 colors.data(), stops.data(),
615 DlTileMode::kMirror));
620 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
621 DlImageSampling::kMipmapLinear, &matrix));
624 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
633 EnsureContextSupportsAntialiasLines();
637 auto callback = [&]() -> sk_sp<DisplayList> {
639 ImGuiWindowFlags_AlwaysAutoResize)) {
640 ImGui::SliderFloat(
"Scale", &scale, 0.001, 5);
641 ImGui::SliderFloat(
"Width", &line_width, 1, 20);
646 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
660 builder.
Scale(scale, scale);
674 builder.
Scale(0.2, 0.2);
681 return builder.
Build();
683 ASSERT_TRUE(OpenPlaygroundHere(
callback));
689 EnsureContextSupportsAntialiasLines();
692 float line_width = 10.f;
693 float rotation = 0.f;
695 auto callback = [&]() -> sk_sp<DisplayList> {
697 ImGuiWindowFlags_AlwaysAutoResize)) {
699 ImGui::SliderFloat(
"Scale", &scale, 0.001f, 5.0f);
700 ImGui::SliderFloat(
"Width", &line_width, 1.0f, 20.0f);
701 ImGui::SliderFloat(
"Rotation", &rotation, 0.0f, 180.0f);
706 builder.
Scale(
static_cast<float>(GetContentScale().
x),
707 static_cast<float>(GetContentScale().
y));
721 float r_sin60 = r * std::sqrt(3.0f) / 2.0f;
722 float r_cos60 = r / 2.0f;
732 DlPoint(cx + r_cos60, cy + r_sin60);
736 builder.
Scale(scale, scale);
740 builder.
DrawLine(v0, v1, hex_paint);
741 builder.
DrawLine(v1, v2, hex_paint);
742 builder.
DrawLine(v2, v3, hex_paint);
743 builder.
DrawLine(v3, v4, hex_paint);
744 builder.
DrawLine(v4, v5, hex_paint);
745 builder.
DrawLine(v5, v0, hex_paint);
748 return builder.
Build();
750 ASSERT_TRUE(OpenPlaygroundHere(
callback));
756 EnsureContextSupportsAntialiasLines();
759 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
767 auto draw = [&builder](
DlPaint& paint) {
769 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
773 for (
int d = 15;
d < 90;
d += 15) {
775 Point origin = {100, 100};
778 auto a = origin + m * p0;
779 auto b = origin + m *
p1;
795 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
808 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
822 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
827 for (
auto i = 0;
i < 10;
i++) {
834 path_builder.
Close();
836 path_builder.
MoveTo(
DlPoint(100.f + 50.f *
i - 100, 100.f + 50.f *
i));
837 path_builder.
LineTo(
DlPoint(100.f + 50.f *
i, 100.f + 50.f *
i - 100));
839 100.f + 50.f *
i - 100));
840 path_builder.
Close();
850 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
855 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
860 std::vector<DlColor> colors = {
DlColor::RGBA(1.0, 0.0, 0.0, 1.0),
862 std::vector<Scalar> stops = {0.0, 1.0};
866 stops.data(), DlTileMode::kMirror));
886 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
894 auto callback = [&]() -> sk_sp<DisplayList> {
896 ImGuiWindowFlags_AlwaysAutoResize)) {
897 ImGui::SliderFloat(
"Stroke Width", &stroke_width, 1, 300);
898 ImGui::SliderFloat(
"Aspect", &aspect, 0.5, 2.0);
899 ImGui::SliderFloat(
"Start Angle", &start_angle, 0, 360);
900 ImGui::SliderFloat(
"End Angle", &end_angle, 0, 360);
918 builder.
DrawArc(rect, start_angle, end_angle,
920 DlScalar frontier = rect.GetRight() + stroke_width / 2.0;
923 return builder.
Build();
925 ASSERT_TRUE(OpenPlaygroundHere(
callback));
936 .top_right =
DlSize(50, 50),
937 .bottom_left =
DlSize(50, 50),
938 .bottom_right =
DlSize(50, 50),
941 const Scalar kTriangleHeight = 100;
956 path_builder.
Close();
957 path_builder.
AddPath(rrect_path);
969 path_builder.
Close();
970 path_builder.
AddPath(rrect_path);
975 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
995 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1007 for (
auto join : std::vector<DlStrokeJoin>{
1008 DlStrokeJoin::kMiter, DlStrokeJoin::kRound, DlStrokeJoin::kBevel}) {
1021 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1026 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
1031 for (
auto cap : std::vector<DlStrokeCap>{
1032 DlStrokeCap::kButt, DlStrokeCap::kRound, DlStrokeCap::kSquare}) {
1034 path_builder.
MoveTo({20, 50});
1035 path_builder.
LineTo({50, 50});
1036 path_builder.
MoveTo({120, 50});
1037 path_builder.
LineTo({120, 80});
1038 path_builder.
MoveTo({180, 50});
1039 path_builder.
LineTo({180, 50});
1064 for (
auto join : std::vector<DlStrokeJoin>{
1065 DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
1067 path_builder.
MoveTo({20, 50});
1068 path_builder.
LineTo({50, 50});
1069 path_builder.
LineTo({80, 50});
1070 path_builder.
MoveTo({20, 150});
1071 path_builder.
LineTo({50, 150});
1072 path_builder.
LineTo({50, 180});
1073 path_builder.
MoveTo({20, 250});
1074 path_builder.
LineTo({50, 250});
1075 path_builder.
LineTo({70, 270});
1076 path_builder.
MoveTo({20, 350});
1077 path_builder.
LineTo({50, 350});
1078 path_builder.
LineTo({30, 370});
1079 path_builder.
MoveTo({20, 450});
1080 path_builder.
LineTo({50, 450});
1081 path_builder.
LineTo({20, 450});
1082 path_builder.
MoveTo({120, 80});
1083 path_builder.
LineTo({150, 80});
1084 path_builder.
LineTo({180, 80});
1085 path_builder.
MoveTo({120, 180});
1086 path_builder.
LineTo({150, 180});
1087 path_builder.
LineTo({150, 150});
1088 path_builder.
MoveTo({120, 280});
1089 path_builder.
LineTo({150, 280});
1090 path_builder.
LineTo({170, 260});
1091 path_builder.
MoveTo({120, 380});
1092 path_builder.
LineTo({150, 380});
1093 path_builder.
LineTo({130, 360});
1094 path_builder.
MoveTo({120, 480});
1095 path_builder.
LineTo({150, 480});
1096 path_builder.
LineTo({120, 480});
1117 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1130 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawArc(const DlRect &bounds, DlScalar start, DlScalar sweep, bool useCenter, const DlPaint &paint) override
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
DlMatrix GetMatrix() const override
void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint) override
void DrawLine(const DlPoint &p0, const DlPoint &p1, const DlPaint &paint) override
void Rotate(DlScalar degrees) override
void Scale(DlScalar sx, DlScalar sy) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void ClipPath(const DlPath &path, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void Transform(const DlMatrix &matrix) override
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
static std::shared_ptr< const DlColorFilter > MakeBlend(DlColor color, DlBlendMode mode)
static std::shared_ptr< DlColorSource > MakeSweep(DlPoint center, DlScalar start, DlScalar end, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeImage(const sk_sp< const DlImage > &image, DlTileMode horizontal_tile_mode, DlTileMode vertical_tile_mode, DlImageSampling sampling=DlImageSampling::kLinear, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRadial(DlPoint center, DlScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
DlPaint & setColor(DlColor color)
DlPaint & setStrokeCap(DlStrokeCap cap)
DlPaint & setStrokeWidth(float width)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setStrokeJoin(DlStrokeJoin join)
DlPaint & setColorFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
DlPathBuilder & 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...
static constexpr const DlScalar kArcApproximationMagic
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
DlPathBuilder & SetFillType(DlPathFillType fill_type)
Set the fill type that should be used to determine the interior of this path to the indicated |fill_t...
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 & AddArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center=false)
Append an arc contour to the path which:
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 MakeLine(const DlPoint a, const DlPoint b)
static DlPath MakeRoundRect(const DlRoundRect &rrect)
static DlPath MakeCircle(const DlPoint center, DlScalar radius)
static DlPath MakeArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center)
static DlPath MakeRect(const DlRect &rect)
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)
FlutterDesktopBinaryReply callback
impeller::Scalar DlScalar
impeller::Degrees DlDegrees
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)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
constexpr float kSqrt2Over2
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor ARGB(DlScalar a, DlScalar r, DlScalar g, DlScalar b)
Construct a 32 bit color from floating point A, R, G, and B color channels.
static constexpr DlColor kYellow()
static constexpr DlColor kFuchsia()
static constexpr DlColor kAliceBlue()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kGreenYellow()
static constexpr Color Black()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color Red()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
bool IsInvertible() const
static Matrix MakeRotationZ(Radians r)
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeCircleBounds(const TPoint< Type > ¢er, Type radius)
static constexpr TRect MakeSize(const TSize< U > &size)