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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 : type_(type), | 79 : type_(type), |
80 amount_(amount), | 80 amount_(amount), |
81 outer_threshold_(0), | 81 outer_threshold_(0), |
82 drop_shadow_offset_(0, 0), | 82 drop_shadow_offset_(0, 0), |
83 drop_shadow_color_(0), | 83 drop_shadow_color_(0), |
84 zoom_inset_(inset) { | 84 zoom_inset_(inset) { |
85 DCHECK_EQ(type_, ZOOM); | 85 DCHECK_EQ(type_, ZOOM); |
86 memset(matrix_, 0, sizeof(matrix_)); | 86 memset(matrix_, 0, sizeof(matrix_)); |
87 } | 87 } |
88 | 88 |
89 FilterOperation::FilterOperation( | 89 FilterOperation::FilterOperation(FilterType type, |
90 FilterType type, | 90 sk_sp<SkImageFilter> image_filter) |
91 const skia::RefPtr<SkImageFilter>& image_filter) | |
92 : type_(type), | 91 : type_(type), |
93 amount_(0), | 92 amount_(0), |
94 outer_threshold_(0), | 93 outer_threshold_(0), |
95 drop_shadow_offset_(0, 0), | 94 drop_shadow_offset_(0, 0), |
96 drop_shadow_color_(0), | 95 drop_shadow_color_(0), |
97 image_filter_(image_filter), | 96 image_filter_(image_filter), |
f(malita)
2016/04/21 15:45:46
std::move(image_filter)
tomhudson
2016/04/25 20:20:50
Done.
| |
98 zoom_inset_(0) { | 97 zoom_inset_(0) { |
99 DCHECK_EQ(type_, REFERENCE); | 98 DCHECK_EQ(type_, REFERENCE); |
100 memset(matrix_, 0, sizeof(matrix_)); | 99 memset(matrix_, 0, sizeof(matrix_)); |
101 } | 100 } |
102 | 101 |
103 FilterOperation::FilterOperation(FilterType type, | 102 FilterOperation::FilterOperation(FilterType type, |
104 const SkRegion& region, | 103 const SkRegion& region, |
105 float inner_threshold, | 104 float inner_threshold, |
106 float outer_threshold) | 105 float outer_threshold) |
107 : type_(type), | 106 : type_(type), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 SkScalar matrix[20]; | 156 SkScalar matrix[20]; |
158 memset(matrix, 0, 20 * sizeof(SkScalar)); | 157 memset(matrix, 0, 20 * sizeof(SkScalar)); |
159 matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1.f; | 158 matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1.f; |
160 return FilterOperation::CreateColorMatrixFilter(matrix); | 159 return FilterOperation::CreateColorMatrixFilter(matrix); |
161 } | 160 } |
162 case FilterOperation::ZOOM: | 161 case FilterOperation::ZOOM: |
163 return FilterOperation::CreateZoomFilter(1.f, 0); | 162 return FilterOperation::CreateZoomFilter(1.f, 0); |
164 case FilterOperation::SATURATING_BRIGHTNESS: | 163 case FilterOperation::SATURATING_BRIGHTNESS: |
165 return FilterOperation::CreateSaturatingBrightnessFilter(0.f); | 164 return FilterOperation::CreateSaturatingBrightnessFilter(0.f); |
166 case FilterOperation::REFERENCE: | 165 case FilterOperation::REFERENCE: |
167 return FilterOperation::CreateReferenceFilter( | 166 return FilterOperation::CreateReferenceFilter(nullptr); |
168 skia::RefPtr<SkImageFilter>()); | |
169 case FilterOperation::ALPHA_THRESHOLD: | 167 case FilterOperation::ALPHA_THRESHOLD: |
170 return FilterOperation::CreateAlphaThresholdFilter(SkRegion(), 1.f, 0.f); | 168 return FilterOperation::CreateAlphaThresholdFilter(SkRegion(), 1.f, 0.f); |
171 } | 169 } |
172 NOTREACHED(); | 170 NOTREACHED(); |
173 return FilterOperation::CreateEmptyFilter(); | 171 return FilterOperation::CreateEmptyFilter(); |
174 } | 172 } |
175 | 173 |
176 static float ClampAmountForFilterType(float amount, | 174 static float ClampAmountForFilterType(float amount, |
177 FilterOperation::FilterType type) { | 175 FilterOperation::FilterType type) { |
178 switch (type) { | 176 switch (type) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 SkIRect out_rect = image_filter()->filterBounds( | 346 SkIRect out_rect = image_filter()->filterBounds( |
349 in_rect, SkMatrix::I(), SkImageFilter::kForward_MapDirection); | 347 in_rect, SkMatrix::I(), SkImageFilter::kForward_MapDirection); |
350 return gfx::SkIRectToRect(out_rect); | 348 return gfx::SkIRectToRect(out_rect); |
351 } | 349 } |
352 default: | 350 default: |
353 return rect; | 351 return rect; |
354 } | 352 } |
355 } | 353 } |
356 | 354 |
357 } // namespace cc | 355 } // namespace cc |
OLD | NEW |