| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 float spread_x = std::abs(spread.x()); | 337 float spread_x = std::abs(spread.x()); |
| 338 float spread_y = std::abs(spread.y()); | 338 float spread_y = std::abs(spread.y()); |
| 339 gfx::Rect result = rect; | 339 gfx::Rect result = rect; |
| 340 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); | 340 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); |
| 341 return result; | 341 return result; |
| 342 } | 342 } |
| 343 case FilterOperation::DROP_SHADOW: { | 343 case FilterOperation::DROP_SHADOW: { |
| 344 SkVector spread = MapStdDeviation(op.amount(), matrix); | 344 SkVector spread = MapStdDeviation(op.amount(), matrix); |
| 345 float spread_x = std::abs(spread.x()); | 345 float spread_x = std::abs(spread.x()); |
| 346 float spread_y = std::abs(spread.y()); | 346 float spread_y = std::abs(spread.y()); |
| 347 gfx::Rect result = rect; | 347 gfx::RectF result(rect); |
| 348 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); | 348 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); |
| 349 | 349 |
| 350 gfx::Vector2d drop_shadow_offset = | 350 gfx::Point drop_shadow_offset = op.drop_shadow_offset(); |
| 351 op.drop_shadow_offset().OffsetFromOrigin(); | 351 SkVector mapped_drop_shadow_offset; |
| 352 if (direction == SkImageFilter::kForward_MapDirection) | 352 matrix.mapVector(drop_shadow_offset.x(), drop_shadow_offset.y(), |
| 353 result += drop_shadow_offset; | 353 &mapped_drop_shadow_offset); |
| 354 else | 354 if (direction == SkImageFilter::kReverse_MapDirection) |
| 355 result -= drop_shadow_offset; | 355 mapped_drop_shadow_offset = -mapped_drop_shadow_offset; |
| 356 | 356 result += gfx::Vector2dF(mapped_drop_shadow_offset.x(), |
| 357 result.Union(rect); | 357 mapped_drop_shadow_offset.y()); |
| 358 return result; | 358 result.Union(gfx::RectF(rect)); |
| 359 return gfx::ToEnclosingRect(result); |
| 359 } | 360 } |
| 360 case FilterOperation::REFERENCE: { | 361 case FilterOperation::REFERENCE: { |
| 361 if (!op.image_filter()) | 362 if (!op.image_filter()) |
| 362 return rect; | 363 return rect; |
| 363 return gfx::SkIRectToRect(op.image_filter()->filterBounds( | 364 return gfx::SkIRectToRect(op.image_filter()->filterBounds( |
| 364 gfx::RectToSkIRect(rect), matrix, direction)); | 365 gfx::RectToSkIRect(rect), matrix, direction)); |
| 365 } | 366 } |
| 366 default: | 367 default: |
| 367 return rect; | 368 return rect; |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace | 372 } // namespace |
| 372 | 373 |
| 373 gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, | 374 gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, |
| 374 const SkMatrix& matrix) const { | 375 const SkMatrix& matrix) const { |
| 375 return MapRectInternal(*this, rect, matrix, | 376 return MapRectInternal(*this, rect, matrix, |
| 376 SkImageFilter::kForward_MapDirection); | 377 SkImageFilter::kForward_MapDirection); |
| 377 } | 378 } |
| 378 | 379 |
| 379 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect, | 380 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect, |
| 380 const SkMatrix& matrix) const { | 381 const SkMatrix& matrix) const { |
| 381 return MapRectInternal(*this, rect, matrix, | 382 return MapRectInternal(*this, rect, matrix, |
| 382 SkImageFilter::kReverse_MapDirection); | 383 SkImageFilter::kReverse_MapDirection); |
| 383 } | 384 } |
| 384 | 385 |
| 385 } // namespace cc | 386 } // namespace cc |
| OLD | NEW |