-
Notifications
You must be signed in to change notification settings - Fork 0
Merge pull request #2 from Mairramer/master #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
09f6267
2c4e7eb
aaafeaf
8fe7618
e25d71b
2a950ef
ab089c0
811a4d2
0c6af9d
d94c0e9
7f0e5b5
67b6303
2f50318
1dfd694
c1a514e
ae4cb25
5fa0ba5
4714854
adf3ac7
74a0f8a
6a5ea63
f605613
7429b1f
7e2de38
34241f1
c373a0d
428db29
4755505
2663f4d
9649575
66f9ac9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2313,6 +2313,117 @@ TEST_P(EntityTest, FillPathGeometryGetPositionBufferReturnsExpectedMode) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| TEST_P(EntityTest, StrokeArcGeometryGetPositionBufferReturnsExpectedMode) { | ||||||
| RenderTarget target; | ||||||
| testing::MockRenderPass mock_pass(GetContext(), target); | ||||||
| Rect oval_bounds = Rect::MakeLTRB(100, 100, 200, 200); | ||||||
|
|
||||||
| // Butt caps never overlap | ||||||
| { | ||||||
| StrokeParameters stroke = {.width = 50.0f, .cap = Cap::kButt}; | ||||||
| for (auto start = 0; start < 360; start += 60) { | ||||||
| for (auto sweep = 0; sweep < 360; sweep += 12) { | ||||||
| auto geometry = Geometry::MakeStrokedArc(oval_bounds, Degrees(start), | ||||||
| Degrees(sweep), stroke); | ||||||
|
|
||||||
| GeometryResult result = | ||||||
| geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass); | ||||||
|
|
||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Round caps with 10 stroke width overlap starting at 348.6 degrees | ||||||
| { | ||||||
| StrokeParameters stroke = {.width = 10.0f, .cap = Cap::kRound}; | ||||||
| for (auto start = 0; start < 360; start += 60) { | ||||||
| for (auto sweep = 0; sweep < 360; sweep += 12) { | ||||||
| auto geometry = Geometry::MakeStrokedArc(oval_bounds, Degrees(start), | ||||||
| Degrees(sweep), stroke); | ||||||
|
|
||||||
| GeometryResult result = | ||||||
| geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass); | ||||||
|
|
||||||
| if (sweep < 348.6) { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } else { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kPreventOverdraw) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Round caps with 50 stroke width overlap starting at 300.1 degrees | ||||||
| { | ||||||
| StrokeParameters stroke = {.width = 50.0f, .cap = Cap::kRound}; | ||||||
| for (auto start = 0; start < 360; start += 60) { | ||||||
| for (auto sweep = 0; sweep < 360; sweep += 12) { | ||||||
| auto geometry = Geometry::MakeStrokedArc(oval_bounds, Degrees(start), | ||||||
| Degrees(sweep), stroke); | ||||||
|
|
||||||
| GeometryResult result = | ||||||
| geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass); | ||||||
|
|
||||||
| if (sweep < 300.0) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be a slight logic error in this condition. The comment on line 2360 states that overlap starts at To align with the comment, you should adjust the condition.
Suggested change
|
||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } else { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kPreventOverdraw) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Square caps with 10 stroke width overlap starting at 347.4 degrees | ||||||
| { | ||||||
| StrokeParameters stroke = {.width = 10.0f, .cap = Cap::kSquare}; | ||||||
| for (auto start = 0; start < 360; start += 60) { | ||||||
| for (auto sweep = 0; sweep < 360; sweep += 12) { | ||||||
| auto geometry = Geometry::MakeStrokedArc(oval_bounds, Degrees(start), | ||||||
| Degrees(sweep), stroke); | ||||||
|
|
||||||
| GeometryResult result = | ||||||
| geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass); | ||||||
|
|
||||||
| if (sweep < 347.4) { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } else { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kPreventOverdraw) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Square caps with 50 stroke width overlap starting at 270.1 degrees | ||||||
| { | ||||||
| StrokeParameters stroke = {.width = 50.0f, .cap = Cap::kSquare}; | ||||||
| for (auto start = 0; start < 360; start += 60) { | ||||||
| for (auto sweep = 0; sweep < 360; sweep += 12) { | ||||||
| auto geometry = Geometry::MakeStrokedArc(oval_bounds, Degrees(start), | ||||||
| Degrees(sweep), stroke); | ||||||
|
|
||||||
| GeometryResult result = | ||||||
| geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass); | ||||||
|
|
||||||
| if (sweep < 270.1) { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kNormal) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } else { | ||||||
| EXPECT_EQ(result.mode, GeometryResult::Mode::kPreventOverdraw) | ||||||
| << "start: " << start << " sweep: " << sweep; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| TEST_P(EntityTest, FailOnValidationError) { | ||||||
| if (GetParam() != PlaygroundBackend::kVulkan) { | ||||||
| GTEST_SKIP() << "Validation is only fatal on Vulkan backend."; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case for round caps with a 10px stroke width doesn't seem to be testing the
kPreventOverdrawscenario correctly. Theforloop forsweep(for (auto sweep = 0; sweep < 360; sweep += 12)) generates values up to 348. Since348 < 348.6is true, theelseblock which checks forGeometryResult::Mode::kPreventOverdrawis never reached. This means the test doesn't verify the overlap detection for this case.To fix this, you could adjust the loop to include values greater than or equal to 348.6, for example by changing the loop condition to
sweep <= 360.