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()));
271static void DrawLinesTest(
AiksTest* test,
const DrawLinesCallback& draw_fn) {
275 Scalar width_adjustment = 0.f;
276 bool invert_colors =
false;
278 auto callback = [=]()
mutable -> sk_sp<DisplayList> {
279 if (test->IsPlaygroundEnabled()) {
280 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
281 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
282 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
283 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
284 ImGui::SliderFloat(
"Width Adjustment", &width_adjustment, -1, 2);
285 ImGui::Checkbox(
"Invert colors", &invert_colors);
303 std::vector<Scalar> widths = {0.0f, 0.3f, 1.0f};
304 std::vector<Scalar> angles = {0.0f, 3.0f, 45.0f, 87.0f, 90.0f};
306 const Scalar column_spacing = 1024.0f / widths.size();
307 const Scalar row_spacing = 768.0f / angles.size();
309 for (
size_t col = 0; col < widths.size(); ++col) {
310 Scalar col_x = (col + 0.5f) * column_spacing;
311 Scalar width = std::max(0.0f, widths[col] + width_adjustment);
312 for (
size_t row = 0; row < angles.size(); ++row) {
313 Scalar row_y = (row + 0.5f) * row_spacing;
316 builder.
Scale(scale, scale);
317 builder.
Rotate(angles[row] + rotation);
322 for (
int i = 0;
i < 4; ++
i) {
323 Scalar base_y =
i * 8.0f - 12.0f;
325 Scalar line_y = base_y + subpixel_y + offset;
328 draw_fn(builder, paint, p0,
p1,
width);
335 return builder.
Build();
338 ASSERT_TRUE(test->OpenPlaygroundHere(
callback));
395 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
415 reference_builder.
MoveTo(component.p1);
416 constexpr int N = 100;
417 for (
int i = 1;
i < N;
i++) {
418 reference_builder.
LineTo(component.Solve(
static_cast<Scalar>(
i) / N));
420 reference_builder.
LineTo(component.p2);
439 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
450 .top_right = {25, 50},
451 .bottom_left = {25, 50},
452 .bottom_right = {50, 25},
469 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
495 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
508 path_builder.
Close();
517 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
522 auto callback = [&]() -> sk_sp<DisplayList> {
524 static float scale = 3;
525 static bool add_circle_clip =
true;
527 if (IsPlaygroundEnabled()) {
528 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
529 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&color));
530 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
531 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
536 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
550 path_builder.
Close();
555 builder.
Scale(scale, scale);
557 if (add_circle_clip) {
562 auto [handle_a, handle_b] =
569 screen_to_canvas = screen_to_canvas.
Invert();
571 Point point_a = screen_to_canvas * handle_a;
572 Point point_b = screen_to_canvas * handle_b;
574 Point middle = point_a + point_b;
575 middle *= GetContentScale().
x / 2;
577 auto radius = point_a.GetDistance(middle);
583 {DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
586 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
594 return builder.
Build();
597 ASSERT_TRUE(OpenPlaygroundHere(
callback));
602 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
608 auto draw = [&builder](
DlPaint& paint) {
610 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
614 for (
int d = 15;
d < 90;
d += 15) {
616 Point origin = {100, 100};
619 auto a = origin + m * p0;
620 auto b = origin + m *
p1;
634 std::vector<DlColor> colors = {
642 std::vector<Scalar> stops = {
653 CreateTextureForFixture(
"airplane.jpg",
659 colors.data(), stops.data(),
660 DlTileMode::kMirror));
665 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
666 DlImageSampling::kMipmapLinear, &matrix));
669 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
682 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
696 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
701 for (
auto i = 0;
i < 10;
i++) {
708 path_builder.
Close();
710 path_builder.
MoveTo(
DlPoint(100.f + 50.f *
i - 100, 100.f + 50.f *
i));
711 path_builder.
LineTo(
DlPoint(100.f + 50.f *
i, 100.f + 50.f *
i - 100));
713 100.f + 50.f *
i - 100));
714 path_builder.
Close();
724 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
729 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
734 std::vector<DlColor> colors = {
DlColor::RGBA(1.0, 0.0, 0.0, 1.0),
736 std::vector<Scalar> stops = {0.0, 1.0};
740 stops.data(), DlTileMode::kMirror));
760 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
768 auto callback = [&]() -> sk_sp<DisplayList> {
769 if (IsPlaygroundEnabled()) {
770 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
771 ImGui::SliderFloat(
"Stroke Width", &stroke_width, 1, 300);
772 ImGui::SliderFloat(
"Aspect", &aspect, 0.5, 2.0);
773 ImGui::SliderFloat(
"Start Angle", &start_angle, 0, 360);
774 ImGui::SliderFloat(
"End Angle", &end_angle, 0, 360);
792 builder.
DrawArc(rect, start_angle, end_angle,
794 DlScalar frontier = rect.GetRight() + stroke_width / 2.0;
797 return builder.
Build();
799 ASSERT_TRUE(OpenPlaygroundHere(
callback));
810 .top_right =
DlSize(50, 50),
811 .bottom_left =
DlSize(50, 50),
812 .bottom_right =
DlSize(50, 50),
815 const Scalar kTriangleHeight = 100;
830 path_builder.
Close();
831 path_builder.
AddPath(rrect_path);
843 path_builder.
Close();
844 path_builder.
AddPath(rrect_path);
849 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
869 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
881 for (
auto join : std::vector<DlStrokeJoin>{
882 DlStrokeJoin::kMiter, DlStrokeJoin::kRound, DlStrokeJoin::kBevel}) {
895 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
900 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
905 for (
auto cap : std::vector<DlStrokeCap>{
906 DlStrokeCap::kButt, DlStrokeCap::kRound, DlStrokeCap::kSquare}) {
908 path_builder.
MoveTo({20, 50});
909 path_builder.
LineTo({50, 50});
910 path_builder.
MoveTo({120, 50});
911 path_builder.
LineTo({120, 80});
912 path_builder.
MoveTo({180, 50});
913 path_builder.
LineTo({180, 50});
938 for (
auto join : std::vector<DlStrokeJoin>{
939 DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
941 path_builder.
MoveTo({20, 50});
942 path_builder.
LineTo({50, 50});
943 path_builder.
LineTo({80, 50});
944 path_builder.
MoveTo({20, 150});
945 path_builder.
LineTo({50, 150});
946 path_builder.
LineTo({50, 180});
947 path_builder.
MoveTo({20, 250});
948 path_builder.
LineTo({50, 250});
949 path_builder.
LineTo({70, 270});
950 path_builder.
MoveTo({20, 350});
951 path_builder.
LineTo({50, 350});
952 path_builder.
LineTo({30, 370});
953 path_builder.
MoveTo({20, 450});
954 path_builder.
LineTo({50, 450});
955 path_builder.
LineTo({20, 450});
956 path_builder.
MoveTo({120, 80});
957 path_builder.
LineTo({150, 80});
958 path_builder.
LineTo({180, 80});
959 path_builder.
MoveTo({120, 180});
960 path_builder.
LineTo({150, 180});
961 path_builder.
LineTo({150, 150});
962 path_builder.
MoveTo({120, 280});
963 path_builder.
LineTo({150, 280});
964 path_builder.
LineTo({170, 260});
965 path_builder.
MoveTo({120, 380});
966 path_builder.
LineTo({150, 380});
967 path_builder.
LineTo({130, 360});
968 path_builder.
MoveTo({120, 480});
969 path_builder.
LineTo({150, 480});
970 path_builder.
LineTo({120, 480});
991 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1004 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawRoundRect(const DlRoundRect &rrect, const DlPaint &paint) override
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 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)
AiksPlaygroundWithGoldens AiksTest
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 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 MakeRectRadius(const Rect &rect, Scalar radius)
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static constexpr TRect MakeEllipseBounds(const TPoint< Type > ¢er, const TSize< Type > &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)