Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3627,5 +3627,23 @@ TEST_P(AiksTest, ClearColorOptimizationWhenSubpassIsBiggerThanParentPass) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, MaskBlurWithZeroSigmaIsSkipped) {
Canvas canvas;

Paint paint = {
.color = Color::White(),
.mask_blur_descriptor =
Paint::MaskBlurDescriptor{
.style = FilterContents::BlurStyle::kNormal,
.sigma = Sigma(0),
},
};

canvas.DrawCircle({300, 300}, 200, paint);
canvas.DrawRect(Rect::MakeLTRB(100, 300, 500, 600), paint);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

} // namespace testing
} // namespace impeller
6 changes: 6 additions & 0 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "impeller/entity/contents/texture_contents.h"
#include "impeller/entity/contents/vertices_contents.h"
#include "impeller/entity/geometry/geometry.h"
#include "impeller/geometry/constants.h"
#include "impeller/geometry/path_builder.h"

namespace impeller {
Expand Down Expand Up @@ -205,6 +206,11 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
return false;
}

if (std::fabs(new_paint.mask_blur_descriptor->sigma.sigma) <=
kEhCloseEnough) {
return true;
}

// For symmetrically mask blurred solid RRects, absorb the mask blur and use
// a faster SDF approximation.

Expand Down
4 changes: 3 additions & 1 deletion impeller/entity/contents/solid_rrect_blur_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/entity.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/constants.h"
#include "impeller/geometry/path.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/renderer/render_pass.h"
Expand Down Expand Up @@ -55,7 +56,8 @@ std::optional<Rect> SolidRRectBlurContents::GetCoverage(
bool SolidRRectBlurContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
if (!rect_.has_value()) {
// Early return if sigma is close to zero to avoid rendering NaNs.
if (!rect_.has_value() || std::fabs(sigma_.sigma) <= kEhCloseEnough) {
return true;
}

Expand Down