|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +#include "gtest/gtest.h" |
| 6 | +#include "third_party/imgui/imgui.h" |
| 7 | +#include "third_party/skia/include/core/SkColor.h" |
| 8 | +#include "third_party/skia/include/core/SkPathBuilder.h" |
| 9 | + |
5 | 10 | #include "flutter/display_list/display_list_builder.h"
|
6 | 11 | #include "flutter/testing/testing.h"
|
7 | 12 | #include "impeller/display_list/display_list_image_impeller.h"
|
8 | 13 | #include "impeller/display_list/display_list_playground.h"
|
9 |
| -#include "third_party/skia/include/core/SkPathBuilder.h" |
| 14 | +#include "impeller/geometry/point.h" |
| 15 | +#include "impeller/playground/widgets.h" |
10 | 16 |
|
11 | 17 | namespace impeller {
|
12 | 18 | namespace testing {
|
@@ -36,7 +42,7 @@ TEST_F(DisplayListTest, CanDrawImage) {
|
36 | 42 | ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
37 | 43 | }
|
38 | 44 |
|
39 |
| -TEST_F(DisplayListTest, CapsAndJoins) { |
| 45 | +TEST_F(DisplayListTest, CanDrawCapsAndJoins) { |
40 | 46 | flutter::DisplayListBuilder builder;
|
41 | 47 |
|
42 | 48 | builder.setStyle(SkPaint::Style::kStroke_Style);
|
@@ -81,5 +87,45 @@ TEST_F(DisplayListTest, CapsAndJoins) {
|
81 | 87 | ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
82 | 88 | }
|
83 | 89 |
|
| 90 | +TEST_F(DisplayListTest, CanDrawArc) { |
| 91 | + bool first_frame = true; |
| 92 | + auto callback = [&]() { |
| 93 | + if (first_frame) { |
| 94 | + first_frame = false; |
| 95 | + ImGui::SetNextWindowSize({400, 100}); |
| 96 | + ImGui::SetNextWindowPos({300, 550}); |
| 97 | + } |
| 98 | + |
| 99 | + static float start_angle = 45; |
| 100 | + static float sweep_angle = 270; |
| 101 | + static bool use_center = true; |
| 102 | + |
| 103 | + ImGui::Begin("Controls"); |
| 104 | + ImGui::SliderFloat("Start angle", &start_angle, -360, 360); |
| 105 | + ImGui::SliderFloat("Sweep angle", &sweep_angle, -360, 360); |
| 106 | + ImGui::Checkbox("Use center", &use_center); |
| 107 | + ImGui::End(); |
| 108 | + |
| 109 | + auto [p1, p2] = IMPELLER_PLAYGROUND_LINE( |
| 110 | + Point(200, 200), Point(400, 400), 20, Color::White(), Color::White()); |
| 111 | + |
| 112 | + flutter::DisplayListBuilder builder; |
| 113 | + builder.setStyle(SkPaint::Style::kStroke_Style); |
| 114 | + builder.setStrokeCap(SkPaint::Cap::kRound_Cap); |
| 115 | + builder.setStrokeJoin(SkPaint::Join::kMiter_Join); |
| 116 | + builder.setStrokeMiter(10); |
| 117 | + auto rect = SkRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y); |
| 118 | + builder.setColor(SK_ColorGREEN); |
| 119 | + builder.setStrokeWidth(2); |
| 120 | + builder.drawRect(rect); |
| 121 | + builder.setColor(SK_ColorRED); |
| 122 | + builder.setStrokeWidth(10); |
| 123 | + builder.drawArc(rect, start_angle, sweep_angle, use_center); |
| 124 | + |
| 125 | + return builder.Build(); |
| 126 | + }; |
| 127 | + ASSERT_TRUE(OpenPlaygroundHere(callback)); |
| 128 | +} |
| 129 | + |
84 | 130 | } // namespace testing
|
85 | 131 | } // namespace impeller
|
0 commit comments