| 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 "cc/output/filter_operations.h" | 5 #include "cc/output/filter_operations.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 void FilterOperations::Clear() { | 45 void FilterOperations::Clear() { |
| 46 operations_.clear(); | 46 operations_.clear(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool FilterOperations::IsEmpty() const { | 49 bool FilterOperations::IsEmpty() const { |
| 50 return operations_.empty(); | 50 return operations_.empty(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 static int SpreadForStdDeviation(float std_deviation) { | 53 static int SpreadForStdDeviation(float std_deviation) { |
| 54 // https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#feGaussianBlurE
lement | 54 // Corresponds to MapStdDeviation in filter_operation.cc. |
| 55 // provides this approximation for evaluating a gaussian blur by a triple box | 55 return std_deviation * 3; |
| 56 // filter. | |
| 57 float d = floorf(std_deviation * 3.f * sqrt(8.f * atan(1.f)) / 4.f + 0.5f); | |
| 58 return static_cast<int>(ceilf(d * 3.f / 2.f)); | |
| 59 } | 56 } |
| 60 | 57 |
| 61 gfx::Rect FilterOperations::MapRect(const gfx::Rect& rect, | 58 gfx::Rect FilterOperations::MapRect(const gfx::Rect& rect, |
| 62 const SkMatrix& matrix) const { | 59 const SkMatrix& matrix) const { |
| 63 auto accumulate_rect = [matrix](const gfx::Rect& rect, | 60 auto accumulate_rect = [matrix](const gfx::Rect& rect, |
| 64 const FilterOperation& op) { | 61 const FilterOperation& op) { |
| 65 return op.MapRect(rect, matrix); | 62 return op.MapRect(rect, matrix); |
| 66 }; | 63 }; |
| 67 return std::accumulate(operations_.begin(), operations_.end(), rect, | 64 return std::accumulate(operations_.begin(), operations_.end(), rect, |
| 68 accumulate_rect); | 65 accumulate_rect); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 void FilterOperations::AsValueInto( | 221 void FilterOperations::AsValueInto( |
| 225 base::trace_event::TracedValue* value) const { | 222 base::trace_event::TracedValue* value) const { |
| 226 for (size_t i = 0; i < operations_.size(); ++i) { | 223 for (size_t i = 0; i < operations_.size(); ++i) { |
| 227 value->BeginDictionary(); | 224 value->BeginDictionary(); |
| 228 operations_[i].AsValueInto(value); | 225 operations_[i].AsValueInto(value); |
| 229 value->EndDictionary(); | 226 value->EndDictionary(); |
| 230 } | 227 } |
| 231 } | 228 } |
| 232 | 229 |
| 233 } // namespace cc | 230 } // namespace cc |
| OLD | NEW |