Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 24c63aa

Browse files
committed
Pass context transform to filterBound instead of scaling the filter
1 parent 46ae46c commit 24c63aa

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

flow/layers/backdrop_filter_layer.cc

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,12 @@ void BackdropFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
2525
context->AddLayerBounds(paint_bounds);
2626

2727
if (filter_) {
28-
// convert paint bounds and filter to screen coordinates
29-
auto filter = filter_->makeWithLocalMatrix(context->GetTransform());
30-
if (filter) {
31-
context->GetTransform().mapRect(&paint_bounds);
32-
auto input_filter_bounds = paint_bounds.roundOut();
33-
auto filter_bounds = // in screen coordinates
34-
filter->filterBounds(input_filter_bounds, SkMatrix::I(),
35-
SkImageFilter::kReverse_MapDirection);
36-
37-
context->AddReadbackRegion(filter_bounds);
38-
} else {
39-
// Slightly less precise alternative that works even if filter can not be
40-
// transformed. It might cover larger area than the branch before, because
41-
// filterBounds() first rounds out to integer and and then we transform
42-
// the bounds, as opposed to transforming first and rounding second.
43-
// See https://github.com/flutter/flutter/issues/95211
44-
auto input_filter_bounds = paint_bounds.roundOut();
45-
auto filter_bounds = // in local coordinates
46-
filter_->filterBounds(input_filter_bounds, SkMatrix::I(),
47-
SkImageFilter::kReverse_MapDirection);
48-
auto screen_bounds = SkRect::Make(filter_bounds);
49-
context->GetTransform().mapRect(&screen_bounds);
50-
context->AddReadbackRegion(screen_bounds.roundOut());
51-
}
28+
context->GetTransform().mapRect(&paint_bounds);
29+
auto input_filter_bounds = paint_bounds.roundOut();
30+
auto filter_bounds = // in screen coordinates
31+
filter_->filterBounds(input_filter_bounds, context->GetTransform(),
32+
SkImageFilter::kReverse_MapDirection);
33+
context->AddReadbackRegion(filter_bounds);
5234
}
5335

5436
DiffChildren(context, prev);

flow/layers/backdrop_filter_layer_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ TEST_F(BackdropLayerDiffTest, BackdropLayerInvalidTransform) {
348348
std::make_shared<BackdropFilterLayer>(filter, SkBlendMode::kSrcOver));
349349

350350
auto damage = DiffLayerTree(l1, MockLayerTree(SkISize::Make(100, 100)));
351-
EXPECT_EQ(damage.frame_damage, SkIRect::MakeWH(5, 5));
351+
EXPECT_EQ(damage.frame_damage, SkIRect::MakeWH(15, 15));
352352
}
353353

354354
} // namespace testing

0 commit comments

Comments
 (0)