ImageFilterLayer should not contribute to readback region (flutter/engine#26741)

This commit is contained in:
Matej Knopp
2021-06-15 00:39:01 +02:00
committed by GitHub
parent 645ef0b0f9
commit d1c029c650
2 changed files with 3 additions and 9 deletions

View File

@@ -35,13 +35,6 @@ void ImageFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
filter->filterBounds(screen_bounds.roundOut(), SkMatrix::I(),
SkImageFilter::kForward_MapDirection);
context->AddLayerBounds(inverse.mapRect(SkRect::Make(filter_bounds)));
// Technically, there is no readback with ImageFilterLayer, but we can't
// clip the filter (because it may sample out of clip rect) so if any part
// of layer is repainted the whole layer needs to be.
// TODO(knopp) There is a room for optimization here - this doesn't need to
// be done if we know for sure that we're using raster cache
context->AddReadbackRegion(filter_bounds);
}
context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());

View File

@@ -376,13 +376,14 @@ TEST_F(ImageFilterLayerDiffTest, ImageFilterLayer) {
damage = DiffLayerTree(l3, l2);
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(130, 130, 140, 140));
// path intersecting ImageFilterLayer, should trigger ImageFilterLayer repaint
// path intersecting ImageFilterLayer, shouldn't trigger entire
// ImageFilterLayer repaint
MockLayerTree l4;
l4.root()->Add(scale);
auto path2 = SkPath().addRect(SkRect::MakeLTRB(130, 130, 141, 141));
l4.root()->Add(std::make_shared<MockLayer>(path2));
damage = DiffLayerTree(l4, l3);
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(130, 130, 280, 280));
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(130, 130, 141, 141));
}
#endif