@@ -925,6 +925,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
925925 contents->SetStrokeCap (SolidStrokeContents::Cap::kButt );
926926 contents->SetStrokeJoin (SolidStrokeContents::Join::kBevel );
927927 contents->SetStrokeSize (4 );
928+ contents->SetColor (Color::Black ());
928929 entity.SetContents (std::move (contents));
929930 auto actual = entity.GetCoverage ();
930931 auto expected = Rect::MakeLTRB (-2 , -2 , 12 , 12 );
@@ -940,6 +941,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
940941 contents->SetStrokeCap (SolidStrokeContents::Cap::kSquare );
941942 contents->SetStrokeJoin (SolidStrokeContents::Join::kBevel );
942943 contents->SetStrokeSize (4 );
944+ contents->SetColor (Color::Black ());
943945 entity.SetContents (std::move (contents));
944946 auto actual = entity.GetCoverage ();
945947 auto expected =
@@ -957,6 +959,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
957959 contents->SetStrokeJoin (SolidStrokeContents::Join::kMiter );
958960 contents->SetStrokeSize (4 );
959961 contents->SetStrokeMiter (2 );
962+ contents->SetColor (Color::Black ());
960963 entity.SetContents (std::move (contents));
961964 auto actual = entity.GetCoverage ();
962965 auto expected = Rect::MakeLTRB (-4 , -4 , 14 , 14 );
@@ -1011,5 +1014,47 @@ TEST_P(EntityTest, DrawVerticesSolidColorTrianglesWithoutIndex) {
10111014 ASSERT_TRUE (OpenPlaygroundHere (e));
10121015}
10131016
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+
10141059} // namespace testing
10151060} // namespace impeller
0 commit comments