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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/values.h" | |
7 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
8 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
9 #include "third_party/skia/include/core/SkMath.h" | 10 #include "third_party/skia/include/core/SkMath.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 bool FilterOperation::operator==(const FilterOperation& other) const { | 14 bool FilterOperation::operator==(const FilterOperation& other) const { |
14 if (type_ != other.type_) | 15 if (type_ != other.type_) |
15 return false; | 16 return false; |
16 if (type_ == COLOR_MATRIX) | 17 if (type_ == COLOR_MATRIX) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 blended_filter.set_drop_shadow_color(BlendSkColors( | 211 blended_filter.set_drop_shadow_color(BlendSkColors( |
211 from_op.drop_shadow_color(), to_op.drop_shadow_color(), progress)); | 212 from_op.drop_shadow_color(), to_op.drop_shadow_color(), progress)); |
212 } else if (to_op.type() == FilterOperation::ZOOM) { | 213 } else if (to_op.type() == FilterOperation::ZOOM) { |
213 blended_filter.set_zoom_inset(std::max( | 214 blended_filter.set_zoom_inset(std::max( |
214 BlendInts(from_op.zoom_inset(), to_op.zoom_inset(), progress), 0)); | 215 BlendInts(from_op.zoom_inset(), to_op.zoom_inset(), progress), 0)); |
215 } | 216 } |
216 | 217 |
217 return blended_filter; | 218 return blended_filter; |
218 } | 219 } |
219 | 220 |
221 scoped_ptr<base::Value> FilterOperation::AsValue() const { | |
222 scoped_ptr<base::DictionaryValue> value(new DictionaryValue); | |
223 value->SetInteger("type", type_); | |
224 switch (type_) { | |
vmpstr
2013/07/26 16:07:23
Can you add a default NOTREACHED() so that we catc
danakj
2013/07/26 16:49:08
Actually, I'd prefer to not have a 'default' case
| |
225 case FilterOperation::GRAYSCALE: | |
226 case FilterOperation::SEPIA: | |
227 case FilterOperation::SATURATE: | |
228 case FilterOperation::HUE_ROTATE: | |
229 case FilterOperation::INVERT: | |
230 case FilterOperation::BRIGHTNESS: | |
231 case FilterOperation::CONTRAST: | |
232 case FilterOperation::OPACITY: | |
233 case FilterOperation::BLUR: | |
234 case FilterOperation::SATURATING_BRIGHTNESS: | |
235 value->SetDouble("amount", amount_); | |
236 break; | |
237 case FilterOperation::DROP_SHADOW: | |
238 value->SetDouble("std_deviation", amount_); | |
239 value->Set("offset", MathUtil::AsValue(drop_shadow_offset_).release()); | |
240 value->SetInteger("color", drop_shadow_color_); | |
241 break; | |
242 case FilterOperation::COLOR_MATRIX: { | |
243 scoped_ptr<ListValue> matrix(new ListValue); | |
244 for (size_t i = 0; i < arraysize(matrix_); ++i) | |
245 matrix->AppendDouble(matrix_[i]); | |
246 value->Set("matrix", matrix.release()); | |
247 break; | |
248 } | |
249 case FilterOperation::ZOOM: | |
250 value->SetDouble("amount", amount_); | |
251 value->SetDouble("inset", zoom_inset_); | |
252 break; | |
253 } | |
254 return value.PassAs<base::Value>(); | |
255 } | |
256 | |
220 } // namespace cc | 257 } // namespace cc |
OLD | NEW |