Chromium Code Reviews| Index: cc/output/filter_operation.cc |
| diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc |
| index 46e662986de30c3ec96d0bbfa245db6fed1083c4..a9c52a2e80144d50916f3f3bf851968f40bbe36f 100644 |
| --- a/cc/output/filter_operation.cc |
| +++ b/cc/output/filter_operation.cc |
| @@ -315,26 +315,25 @@ void FilterOperation::AsValueInto(base::trace_event::TracedValue* value) 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)); |
| +static SkVector MapStdDeviation(float std_deviation, const SkMatrix& matrix) { |
|
enne (OOO)
2016/05/13 21:31:13
Can you explain this change to me?
Stephen White
2016/05/13 21:51:07
Basically, this syncs this function up with the Sk
|
| + SkVector sigma = SkVector::Make(std_deviation, std_deviation); |
| + matrix.mapVectors(&sigma, 1); |
| + return sigma * SkIntToScalar(3); |
| } |
| -gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect) const { |
| +gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, |
| + const SkMatrix& matrix) const { |
| switch (type_) { |
| case FilterOperation::BLUR: { |
| - int spread = SpreadForStdDeviation(amount()); |
| + SkVector spread = MapStdDeviation(amount(), matrix); |
| gfx::Rect result = rect; |
| - result.Inset(-spread, -spread, -spread, -spread); |
| + result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| return result; |
| } |
| case FilterOperation::DROP_SHADOW: { |
| - int spread = SpreadForStdDeviation(amount()); |
| + SkVector spread = MapStdDeviation(amount(), matrix); |
| gfx::Rect result = rect; |
| - result.Inset(-spread, -spread, -spread, -spread); |
| + result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| result += drop_shadow_offset().OffsetFromOrigin(); |
| result.Union(rect); |
| return result; |
| @@ -344,7 +343,7 @@ gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect) const { |
| return rect; |
| SkIRect in_rect = gfx::RectToSkIRect(rect); |
| SkIRect out_rect = image_filter()->filterBounds( |
| - in_rect, SkMatrix::I(), SkImageFilter::kForward_MapDirection); |
| + in_rect, matrix, SkImageFilter::kForward_MapDirection); |
| return gfx::SkIRectToRect(out_rect); |
| } |
| default: |