Skip to content

Commit

Permalink
cc: Update SpreadForStdDeviation to 3*sigma, and update tests.
Browse files Browse the repository at this point in the history
A recent change (https://codereview.chromium.org/1980613003) updated one path
to use 3*sigma as the estimated spread for gaussian blurs in filters. This
propagates that change to the "filter outset" path, for consistency, and
updates test results accordingly (including one visually-indistinguishable
pixel diff).

BUG=600821
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2004443002
Cr-Commit-Position: refs/heads/master@{#395126}
  • Loading branch information
jeremyroman authored and Commit bot committed May 20, 2016
1 parent fd1cc4c commit 6797dde
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions cc/output/filter_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ void FilterOperation::AsValueInto(base::trace_event::TracedValue* value) const {
}

static SkVector MapStdDeviation(float std_deviation, const SkMatrix& matrix) {
// Corresponds to SpreadForStdDeviation in filter_operations.cc.
SkVector sigma = SkVector::Make(std_deviation, std_deviation);
matrix.mapVectors(&sigma, 1);
return sigma * SkIntToScalar(3);
Expand Down
7 changes: 2 additions & 5 deletions cc/output/filter_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ bool FilterOperations::IsEmpty() const {
}

static int SpreadForStdDeviation(float std_deviation) {
// https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#feGaussianBlurElement
// provides this approximation for evaluating a gaussian blur by a triple box
// filter.
float d = floorf(std_deviation * 3.f * sqrt(8.f * atan(1.f)) / 4.f + 0.5f);
return static_cast<int>(ceilf(d * 3.f / 2.f));
// Corresponds to MapStdDeviation in filter_operation.cc.
return std_deviation * 3;
}

gfx::Rect FilterOperations::MapRect(const gfx::Rect& rect,
Expand Down
16 changes: 8 additions & 8 deletions cc/output/filter_operations_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ TEST(FilterOperationsTest, GetOutsetsBlur) {
int top, right, bottom, left;
top = right = bottom = left = 0;
ops.GetOutsets(&top, &right, &bottom, &left);
EXPECT_EQ(57, top);
EXPECT_EQ(57, right);
EXPECT_EQ(57, bottom);
EXPECT_EQ(57, left);
EXPECT_EQ(60, top);
EXPECT_EQ(60, right);
EXPECT_EQ(60, bottom);
EXPECT_EQ(60, left);
}

TEST(FilterOperationsTest, MapRectBlur) {
Expand Down Expand Up @@ -100,10 +100,10 @@ TEST(FilterOperationsTest, GetOutsetsDropShadow) {
int top, right, bottom, left;
top = right = bottom = left = 0;
ops.GetOutsets(&top, &right, &bottom, &left);
EXPECT_EQ(49, top);
EXPECT_EQ(60, right);
EXPECT_EQ(65, bottom);
EXPECT_EQ(54, left);
EXPECT_EQ(52, top);
EXPECT_EQ(63, right);
EXPECT_EQ(68, bottom);
EXPECT_EQ(57, left);
}

TEST(FilterOperationsTest, MapRectDropShadow) {
Expand Down
Binary file modified cc/test/data/background_filter_rotated_gl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_host_common_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
ASSERT_TRUE(parent->render_surface());
EXPECT_EQ(2U, parent->render_surface()->layer_list().size());
EXPECT_EQ(4U, render_surface_layer_list.size());
EXPECT_EQ(gfx::RectF(-29, -29, 158, 158),
EXPECT_EQ(gfx::RectF(-30, -30, 160, 160),
parent->render_surface()->DrawableContentRect());
}

Expand Down

0 comments on commit 6797dde

Please sign in to comment.