Commit 86a5b39c authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Set filter bounds to empty rect if the content is empty

Previously if a filter has empty content, the bounds of the SaveLayerOp
was left unset, causing bad performance in pdf renderer. Now set the
bounds to an empty rect.

Bug: 918240, 1050694
Change-Id: I7d39336c9525a32af88dac29dc2eb0dc38cd067f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047380Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740824}
parent e14c1b39
...@@ -618,20 +618,20 @@ void ConversionContext::EndEffect() { ...@@ -618,20 +618,20 @@ void ConversionContext::EndEffect() {
DCHECK(effect_bounds_stack_.size()); DCHECK(effect_bounds_stack_.size());
const auto& bounds_info = effect_bounds_stack_.back(); const auto& bounds_info = effect_bounds_stack_.back();
FloatRect bounds = bounds_info.bounds; FloatRect bounds = bounds_info.bounds;
if (!bounds.IsEmpty()) { if (current_effect_->Filter().IsEmpty()) {
if (current_effect_->Filter().IsEmpty()) { if (!bounds.IsEmpty())
cc_list_.UpdateSaveLayerBounds(bounds_info.save_layer_id, bounds); cc_list_.UpdateSaveLayerBounds(bounds_info.save_layer_id, bounds);
} else { } else {
// The bounds for the SaveLayer[Alpha]Op should be the source bounds // The bounds for the SaveLayer[Alpha]Op should be the source bounds
// before the filter is applied, in the space of the TranslateOp which was // before the filter is applied, in the space of the TranslateOp which was
// emitted before the SaveLayer[Alpha]Op. // emitted before the SaveLayer[Alpha]Op.
auto save_layer_bounds = bounds; auto save_layer_bounds = bounds;
if (!save_layer_bounds.IsEmpty())
save_layer_bounds.MoveBy(-current_effect_->FiltersOrigin()); save_layer_bounds.MoveBy(-current_effect_->FiltersOrigin());
cc_list_.UpdateSaveLayerBounds(bounds_info.save_layer_id, cc_list_.UpdateSaveLayerBounds(bounds_info.save_layer_id,
save_layer_bounds); save_layer_bounds);
// We need to propagate the filtered bounds to the parent. // We need to propagate the filtered bounds to the parent.
bounds = current_effect_->MapRect(bounds); bounds = current_effect_->MapRect(bounds);
}
} }
effect_bounds_stack_.pop_back(); effect_bounds_stack_.pop_back();
......
...@@ -1313,5 +1313,23 @@ TEST_P(PaintChunksToCcLayerTest, AllowChunkEscapeLayerNoopEffects) { ...@@ -1313,5 +1313,23 @@ TEST_P(PaintChunksToCcLayerTest, AllowChunkEscapeLayerNoopEffects) {
})); }));
} }
TEST_P(PaintChunksToCcLayerTest, EmptyChunkRect) {
CompositorFilterOperations filter;
filter.AppendBlurFilter(5);
auto e1 = CreateFilterEffect(e0(), t0(), &c0(), filter, FloatPoint(0, 0));
TestChunks chunks;
chunks.AddChunk(nullptr, t0(), c0(), *e1, {0, 0, 0, 0});
auto output =
PaintChunksToCcLayer::Convert(
chunks.chunks, PropertyTreeState::Root(), gfx::Vector2dF(),
chunks.items, cc::DisplayItemList::kToBeReleasedAsPaintOpBuffer)
->ReleaseAsRecord();
EXPECT_THAT(*output,
PaintRecordMatcher::Make({cc::PaintOpType::SaveLayer, // <e1>
cc::PaintOpType::Restore})); // </e1>
EXPECT_EFFECT_BOUNDS(0, 0, 0, 0, *output, 0);
}
} // namespace } // namespace
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment