@@ -925,6 +925,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
925
925
contents->SetStrokeCap (SolidStrokeContents::Cap::kButt );
926
926
contents->SetStrokeJoin (SolidStrokeContents::Join::kBevel );
927
927
contents->SetStrokeSize (4 );
928
+ contents->SetColor (Color::Black ());
928
929
entity.SetContents (std::move (contents));
929
930
auto actual = entity.GetCoverage ();
930
931
auto expected = Rect::MakeLTRB (-2 , -2 , 12 , 12 );
@@ -940,6 +941,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
940
941
contents->SetStrokeCap (SolidStrokeContents::Cap::kSquare );
941
942
contents->SetStrokeJoin (SolidStrokeContents::Join::kBevel );
942
943
contents->SetStrokeSize (4 );
944
+ contents->SetColor (Color::Black ());
943
945
entity.SetContents (std::move (contents));
944
946
auto actual = entity.GetCoverage ();
945
947
auto expected =
@@ -957,6 +959,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
957
959
contents->SetStrokeJoin (SolidStrokeContents::Join::kMiter );
958
960
contents->SetStrokeSize (4 );
959
961
contents->SetStrokeMiter (2 );
962
+ contents->SetColor (Color::Black ());
960
963
entity.SetContents (std::move (contents));
961
964
auto actual = entity.GetCoverage ();
962
965
auto expected = Rect::MakeLTRB (-4 , -4 , 14 , 14 );
@@ -1011,5 +1014,47 @@ TEST_P(EntityTest, DrawVerticesSolidColorTrianglesWithoutIndex) {
1011
1014
ASSERT_TRUE (OpenPlaygroundHere (e));
1012
1015
}
1013
1016
1017
+ TEST_P (EntityTest, SolidFillCoverageIsCorrect) {
1018
+ // No transform
1019
+ {
1020
+ auto fill = std::make_shared<SolidColorContents>();
1021
+ fill->SetColor (Color::CornflowerBlue ());
1022
+ auto expected = Rect::MakeLTRB (100 , 110 , 200 , 220 );
1023
+ fill->SetPath (PathBuilder{}.AddRect (expected).TakePath ());
1024
+
1025
+ auto coverage = fill->GetCoverage ({});
1026
+ ASSERT_TRUE (coverage.has_value ());
1027
+ ASSERT_RECT_NEAR (coverage.value (), expected);
1028
+ }
1029
+
1030
+ // Entity transform
1031
+ {
1032
+ auto fill = std::make_shared<SolidColorContents>();
1033
+ fill->SetColor (Color::CornflowerBlue ());
1034
+ fill->SetPath (
1035
+ PathBuilder{}.AddRect (Rect::MakeLTRB (100 , 110 , 200 , 220 )).TakePath ());
1036
+
1037
+ Entity entity;
1038
+ entity.SetTransformation (Matrix::MakeTranslation (Vector2 (4 , 5 )));
1039
+ entity.SetContents (std::move (fill));
1040
+
1041
+ auto coverage = entity.GetCoverage ();
1042
+ auto expected = Rect::MakeLTRB (104 , 115 , 204 , 225 );
1043
+ ASSERT_TRUE (coverage.has_value ());
1044
+ ASSERT_RECT_NEAR (coverage.value (), expected);
1045
+ }
1046
+
1047
+ // No coverage for fully transparent colors
1048
+ {
1049
+ auto fill = std::make_shared<SolidColorContents>();
1050
+ fill->SetColor (Color::WhiteTransparent ());
1051
+ fill->SetPath (
1052
+ PathBuilder{}.AddRect (Rect::MakeLTRB (100 , 110 , 200 , 220 )).TakePath ());
1053
+
1054
+ auto coverage = fill->GetCoverage ({});
1055
+ ASSERT_FALSE (coverage.has_value ());
1056
+ }
1057
+ }
1058
+
1014
1059
} // namespace testing
1015
1060
} // namespace impeller
0 commit comments