Chromium Code Reviews| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 value->AppendInteger(it.rect().y()); | 308 value->AppendInteger(it.rect().y()); |
| 309 value->AppendInteger(it.rect().width()); | 309 value->AppendInteger(it.rect().width()); |
| 310 value->AppendInteger(it.rect().height()); | 310 value->AppendInteger(it.rect().height()); |
| 311 } | 311 } |
| 312 value->EndArray(); | 312 value->EndArray(); |
| 313 } | 313 } |
| 314 break; | 314 break; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 static int SpreadForStdDeviation(float std_deviation) { | 318 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
| |
| 319 // https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#feGaussianBlurE lement | 319 SkVector sigma = SkVector::Make(std_deviation, std_deviation); |
| 320 // provides this approximation for evaluating a gaussian blur by a triple box | 320 matrix.mapVectors(&sigma, 1); |
| 321 // filter. | 321 return sigma * SkIntToScalar(3); |
| 322 float d = floorf(std_deviation * 3.f * sqrt(8.f * atan(1.f)) / 4.f + 0.5f); | |
| 323 return static_cast<int>(ceilf(d * 3.f / 2.f)); | |
| 324 } | 322 } |
| 325 | 323 |
| 326 gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect) const { | 324 gfx::Rect FilterOperation::MapRect(const gfx::Rect& rect, |
| 325 const SkMatrix& matrix) const { | |
| 327 switch (type_) { | 326 switch (type_) { |
| 328 case FilterOperation::BLUR: { | 327 case FilterOperation::BLUR: { |
| 329 int spread = SpreadForStdDeviation(amount()); | 328 SkVector spread = MapStdDeviation(amount(), matrix); |
| 330 gfx::Rect result = rect; | 329 gfx::Rect result = rect; |
| 331 result.Inset(-spread, -spread, -spread, -spread); | 330 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| 332 return result; | 331 return result; |
| 333 } | 332 } |
| 334 case FilterOperation::DROP_SHADOW: { | 333 case FilterOperation::DROP_SHADOW: { |
| 335 int spread = SpreadForStdDeviation(amount()); | 334 SkVector spread = MapStdDeviation(amount(), matrix); |
| 336 gfx::Rect result = rect; | 335 gfx::Rect result = rect; |
| 337 result.Inset(-spread, -spread, -spread, -spread); | 336 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y()); |
| 338 result += drop_shadow_offset().OffsetFromOrigin(); | 337 result += drop_shadow_offset().OffsetFromOrigin(); |
| 339 result.Union(rect); | 338 result.Union(rect); |
| 340 return result; | 339 return result; |
| 341 } | 340 } |
| 342 case FilterOperation::REFERENCE: { | 341 case FilterOperation::REFERENCE: { |
| 343 if (!image_filter()) | 342 if (!image_filter()) |
| 344 return rect; | 343 return rect; |
| 345 SkIRect in_rect = gfx::RectToSkIRect(rect); | 344 SkIRect in_rect = gfx::RectToSkIRect(rect); |
| 346 SkIRect out_rect = image_filter()->filterBounds( | 345 SkIRect out_rect = image_filter()->filterBounds( |
| 347 in_rect, SkMatrix::I(), SkImageFilter::kForward_MapDirection); | 346 in_rect, matrix, SkImageFilter::kForward_MapDirection); |
| 348 return gfx::SkIRectToRect(out_rect); | 347 return gfx::SkIRectToRect(out_rect); |
| 349 } | 348 } |
| 350 default: | 349 default: |
| 351 return rect; | 350 return rect; |
| 352 } | 351 } |
| 353 } | 352 } |
| 354 | 353 |
| 355 } // namespace cc | 354 } // namespace cc |
| OLD | NEW |