Commit db2ace01 authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Change the CSS filter's max pixel movement to 3x of the blur radius

From https://codepen.io/wesselkroos/pen/KKpGReq, we can clear see the
blur the area modify by the blur effect is actually 3x of the blur
radius. See the screen shot in crbug.com/1117235.

Bug: 1117235
Change-Id: Ib38b70b28bc4bc181ea6366d9d84ad7f7e60b08a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493983Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821416}
parent f93ed919
...@@ -111,14 +111,14 @@ float FilterOperations::MaximumPixelMovement() const { ...@@ -111,14 +111,14 @@ float FilterOperations::MaximumPixelMovement() const {
switch (op.type()) { switch (op.type()) {
case FilterOperation::BLUR: case FilterOperation::BLUR:
// |op.amount| here is the blur radius. // |op.amount| here is the blur radius.
max_movement = fmax(max_movement, op.amount() * 2.f); max_movement = fmax(max_movement, op.amount() * 3.f);
continue; continue;
case FilterOperation::DROP_SHADOW: case FilterOperation::DROP_SHADOW:
// |op.amount| here is the blur radius. // |op.amount| here is the blur radius.
max_movement = max_movement =
fmax(max_movement, fmax(std::abs(op.drop_shadow_offset().x()), fmax(max_movement, fmax(std::abs(op.drop_shadow_offset().x()),
std::abs(op.drop_shadow_offset().y())) + std::abs(op.drop_shadow_offset().y())) +
op.amount() * 2.f); op.amount() * 3.f);
continue; continue;
case FilterOperation::ZOOM: case FilterOperation::ZOOM:
max_movement = fmax(max_movement, op.zoom_inset()); max_movement = fmax(max_movement, op.zoom_inset());
......
...@@ -932,12 +932,12 @@ TEST(FilterOperationsTest, MaximumPixelMovement) { ...@@ -932,12 +932,12 @@ TEST(FilterOperationsTest, MaximumPixelMovement) {
FilterOperations filters; FilterOperations filters;
filters.Append(FilterOperation::CreateBlurFilter(20)); filters.Append(FilterOperation::CreateBlurFilter(20));
EXPECT_FLOAT_EQ(20.f * 2, filters.MaximumPixelMovement()); EXPECT_FLOAT_EQ(20.f * 3, filters.MaximumPixelMovement());
filters.Clear(); filters.Clear();
filters.Append( filters.Append(
FilterOperation::CreateDropShadowFilter(gfx::Point(3, -8), 20, 0)); FilterOperation::CreateDropShadowFilter(gfx::Point(3, -8), 20, 0));
float max_movement = fmax(std::abs(3), std::abs(-8)) + 20.f * 2; float max_movement = fmax(std::abs(3), std::abs(-8)) + 20.f * 3;
EXPECT_FLOAT_EQ(max_movement, filters.MaximumPixelMovement()); EXPECT_FLOAT_EQ(max_movement, filters.MaximumPixelMovement());
filters.Clear(); filters.Clear();
......
...@@ -5139,16 +5139,14 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { ...@@ -5139,16 +5139,14 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
auto* root_pass = root_pass_list[2].get(); auto* root_pass = root_pass_list[2].get();
// Set the root damage rect which doesn't intersect with the expanded // Set the root damage rect which doesn't intersect with the expanded
// filter_pass quad (-4, -4, 13, 13) (filter quad (0, 0, 5, 5) + // filter_pass quad (-4, -4, 13, 13) (filter quad (0, 0, 5, 5) +
// MaximumPixelMovement(2 * 2 = 4)), so we don't have to add more damage // MaximumPixelMovement(2 * 3 = 6)), so we don't have to add more damage
// from the filter_pass and the first render pass draw quad will not be // from the filter_pass and the first render pass draw quad will not be
// drawn. // drawn.
root_pass->damage_rect = gfx::Rect(20, 20, 2, 2); root_pass->damage_rect = gfx::Rect(20, 20, 2, 2);
SubmitPassListAsFrame(root_sink_.get(), root_local_surface_id_, SubmitPassListAsFrame(root_sink_.get(), root_local_surface_id_,
&root_pass_list, std::move(referenced_surfaces), &root_pass_list, std::move(referenced_surfaces),
device_scale_factor); device_scale_factor);
}
{
auto aggregated_frame = AggregateFrame(root_surface_id); auto aggregated_frame = AggregateFrame(root_surface_id);
const auto& aggregated_pass_list = aggregated_frame.render_pass_list; const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
...@@ -5203,16 +5201,14 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { ...@@ -5203,16 +5201,14 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
filter_pass->filters.Append(cc::FilterOperation::CreateZoomFilter(2, 20)); filter_pass->filters.Append(cc::FilterOperation::CreateZoomFilter(2, 20));
auto* root_pass = root_pass_list[2].get(); auto* root_pass = root_pass_list[2].get();
// Make the root damage rect intersect with the expanded filter_pass // Make the root damage rect intersect with the expanded filter_pass
// quad (filter quad (0, 0, 5, 5) + MaximumPixelMovement(10 * 2) = (-20, // quad (filter quad (0, 0, 5, 5) + MaximumPixelMovement(10 * 3) = (-30,
// -20, 45, 45)), but not with filter_pass quad itself (0, 0, 5, 5). The // -30, 65, 65)), but not with filter_pass quad itself (0, 0, 5, 5). The
// first render pass will be drawn. // first render pass will be drawn.
root_pass->damage_rect = gfx::Rect(20, 20, 2, 2); root_pass->damage_rect = gfx::Rect(20, 20, 2, 2);
SubmitPassListAsFrame(root_sink_.get(), root_local_surface_id_, SubmitPassListAsFrame(root_sink_.get(), root_local_surface_id_,
&root_pass_list, std::move(referenced_surfaces), &root_pass_list, std::move(referenced_surfaces),
device_scale_factor); device_scale_factor);
}
{
auto aggregated_frame = AggregateFrame(root_surface_id); auto aggregated_frame = AggregateFrame(root_surface_id);
const auto& aggregated_pass_list = aggregated_frame.render_pass_list; const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
...@@ -5223,8 +5219,11 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { ...@@ -5223,8 +5219,11 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect);
// The filter pass intersects with the root surface damage, the root damage // The filter pass intersects with the root surface damage, the root damage
// increases (= original root damage + expanded filter pass quad). // should increase.
EXPECT_EQ(gfx::Rect(0, 0, 25, 25), aggregated_pass_list[3]->damage_rect); // damage_rect = original root damage (0, 0, 5, 5) + MaximumPixelMovement(10
// * 3) = (-30, -30, 65, 65). Then intersects with the root output_rect (0,
// 0, 100, 100) = (0, 0, 35, 35).
EXPECT_EQ(gfx::Rect(0, 0, 35, 35), aggregated_pass_list[3]->damage_rect);
EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
......
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