Chromium Code Reviews| Index: cc/output/filter_operation.cc |
| diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc |
| index 78588748ba59d63c5d68bd35e1df56cba76f0d22..efa91b4347f46a78d53082eda67f60861e2f5bf4 100644 |
| --- a/cc/output/filter_operation.cc |
| +++ b/cc/output/filter_operation.cc |
| @@ -327,14 +327,18 @@ gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, |
| switch (type_) { |
| case FilterOperation::BLUR: { |
| SkVector spread = MapStdDeviation(amount(), matrix); |
| + float spreadX = std::abs(spread.x()); |
| + float spreadY = std::abs(spread.y()); |
| gfx::Rect result = rect; |
| - result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| + result.Inset(-spreadX, -spreadY, -spreadX, -spreadY); |
| return result; |
| } |
| case FilterOperation::DROP_SHADOW: { |
| SkVector spread = MapStdDeviation(amount(), matrix); |
| + float spreadX = std::abs(spread.x()); |
| + float spreadY = std::abs(spread.y()); |
| gfx::Rect result = rect; |
| - result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| + result.Inset(-spreadX, -spreadY, -spreadX, -spreadY); |
| result += drop_shadow_offset().OffsetFromOrigin(); |
| result.Union(rect); |
| return result; |
| @@ -352,4 +356,38 @@ gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, |
| } |
| } |
| +gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect, |
|
Stephen White
2016/06/07 16:00:34
This looks awfully similar to the existing flavour
jbroman
2016/06/08 15:17:37
Done.
|
| + const SkMatrix& matrix) const { |
| + switch (type_) { |
| + case FilterOperation::BLUR: { |
| + SkVector spread = MapStdDeviation(amount(), matrix); |
| + float spreadX = std::abs(spread.x()); |
|
Stephen White
2016/06/07 16:00:34
If this needs to be abs'ed to handle negative scal
jbroman
2016/06/08 15:17:37
SkBlurImageFilter does apply abs:
sigma.fX = SkMi
Stephen White
2016/06/08 22:05:23
So it does. Thanks!
|
| + float spreadY = std::abs(spread.y()); |
| + gfx::Rect result = rect; |
| + result.Inset(-spreadX, -spreadY, -spreadX, -spreadY); |
| + return result; |
| + } |
| + case FilterOperation::DROP_SHADOW: { |
| + SkVector spread = MapStdDeviation(amount(), matrix); |
| + float spreadX = std::abs(spread.x()); |
| + float spreadY = std::abs(spread.y()); |
| + gfx::Rect result = rect; |
| + result.Inset(-spreadX, -spreadY, -spreadX, -spreadY); |
| + result -= drop_shadow_offset().OffsetFromOrigin(); |
| + result.Union(rect); |
| + return result; |
| + } |
| + case FilterOperation::REFERENCE: { |
| + if (!image_filter()) |
| + return rect; |
| + SkIRect in_rect = gfx::RectToSkIRect(rect); |
| + SkIRect out_rect = image_filter()->filterBounds( |
| + in_rect, matrix, SkImageFilter::kReverse_MapDirection); |
| + return gfx::SkIRectToRect(out_rect); |
| + } |
| + default: |
| + return rect; |
| + } |
| +} |
| + |
| } // namespace cc |