| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 SkIRect in_rect = gfx::RectToSkIRect(rect); | 345 SkIRect in_rect = gfx::RectToSkIRect(rect); |
| 346 SkIRect out_rect = image_filter()->filterBounds( | 346 SkIRect out_rect = image_filter()->filterBounds( |
| 347 in_rect, matrix, SkImageFilter::kForward_MapDirection); | 347 in_rect, matrix, SkImageFilter::kForward_MapDirection); |
| 348 return gfx::SkIRectToRect(out_rect); | 348 return gfx::SkIRectToRect(out_rect); |
| 349 } | 349 } |
| 350 default: | 350 default: |
| 351 return rect; | 351 return rect; |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect, |
| 356 const SkMatrix& matrix) const { |
| 357 switch (type_) { |
| 358 case FilterOperation::BLUR: { |
| 359 SkVector spread = MapStdDeviation(amount(), matrix); |
| 360 gfx::Rect result = rect; |
| 361 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| 362 return result; |
| 363 } |
| 364 case FilterOperation::DROP_SHADOW: { |
| 365 SkVector spread = MapStdDeviation(amount(), matrix); |
| 366 gfx::Rect result = rect; |
| 367 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| 368 result -= drop_shadow_offset().OffsetFromOrigin(); |
| 369 result.Union(rect); |
| 370 return result; |
| 371 } |
| 372 case FilterOperation::REFERENCE: { |
| 373 if (!image_filter()) |
| 374 return rect; |
| 375 SkIRect in_rect = gfx::RectToSkIRect(rect); |
| 376 SkIRect out_rect = image_filter()->filterBounds( |
| 377 in_rect, matrix, SkImageFilter::kReverse_MapDirection); |
| 378 return gfx::SkIRectToRect(out_rect); |
| 379 } |
| 380 default: |
| 381 return rect; |
| 382 } |
| 383 } |
| 384 |
| 355 } // namespace cc | 385 } // namespace cc |
| OLD | NEW |