Skip to content

Commit

Permalink
added coverage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gaaclarke committed Nov 3, 2023
1 parent 348f8ee commit 8567c94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ std::optional<Rect> DirectionalGaussianBlurFilterContents::GetFilterCoverage(

auto transform = inputs[0]->GetTransform(entity) * effect_transform.Basis();
auto transformed_blur_vector =
transform.TransformDirection(blur_direction_ * Radius{blur_sigma_}.radius)
transform
.TransformDirection(blur_direction_ *
Radius{ScaleSigma(blur_sigma_)}.radius)
.Abs();
return coverage->Expand(transformed_blur_vector);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class DirectionalGaussianBlurFilterContentsTest : public ::testing::Test {
.WillRepeatedly(Invoke(([](const TextureDescriptor& desc) {
auto result = std::make_shared<MockTexture>(desc);
EXPECT_CALL(*result, IsValid()).WillRepeatedly(Return(true));
EXPECT_CALL(*result, GetSize()).WillRepeatedly(Return(desc.size));
return result;
})));
}
Expand Down Expand Up @@ -174,11 +175,22 @@ TEST_F(DirectionalGaussianBlurFilterContentsTest, RenderSomething) {
ContentContext renderer(mock_context_, mock_typographer_context_,
mock_render_target_allocator_);
Entity entity;
Rect coverage_hint = Rect::MakeLTRB(0, 0, 0, 0);
std::optional<Entity> result =
contents->GetEntity(renderer, entity, coverage_hint);
contents->GetEntity(renderer, entity, /*coverage_hint=*/{});
ASSERT_TRUE(result.has_value());
ASSERT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver);
EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver);
std::optional<Rect> result_coverage = result.value().GetCoverage();
std::optional<Rect> contents_coverage = contents->GetCoverage(entity);
EXPECT_TRUE(result_coverage.has_value());
EXPECT_TRUE(contents_coverage.has_value());
EXPECT_NEAR(result_coverage.value().GetLeft(),
contents_coverage.value().GetLeft(), kEhCloseEnough);
EXPECT_NEAR(result_coverage.value().GetTop(),
contents_coverage.value().GetTop(), kEhCloseEnough);
EXPECT_NEAR(result_coverage.value().GetRight(),
contents_coverage.value().GetRight(), kEhCloseEnough);
EXPECT_NEAR(result_coverage.value().GetBottom(),
contents_coverage.value().GetBottom(), kEhCloseEnough);
}

} // namespace testing
Expand Down

0 comments on commit 8567c94

Please sign in to comment.