| 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/debug/trace_event_argument.h" | |
| 8 #include "base/values.h" | 7 #include "base/values.h" |
| 9 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 10 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
| 11 #include "ui/gfx/animation/tween.h" | 10 #include "ui/gfx/animation/tween.h" |
| 12 | 11 |
| 13 namespace cc { | 12 namespace cc { |
| 14 | 13 |
| 15 bool FilterOperation::operator==(const FilterOperation& other) const { | 14 bool FilterOperation::operator==(const FilterOperation& other) const { |
| 16 if (type_ != other.type_) | 15 if (type_ != other.type_) |
| 17 return false; | 16 return false; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 gfx::Tween::FloatValueBetween(progress, | 247 gfx::Tween::FloatValueBetween(progress, |
| 249 from_op.outer_threshold(), | 248 from_op.outer_threshold(), |
| 250 to_op.outer_threshold()), | 249 to_op.outer_threshold()), |
| 251 to_op.type())); | 250 to_op.type())); |
| 252 blended_filter.set_region(to_op.region()); | 251 blended_filter.set_region(to_op.region()); |
| 253 } | 252 } |
| 254 | 253 |
| 255 return blended_filter; | 254 return blended_filter; |
| 256 } | 255 } |
| 257 | 256 |
| 258 void FilterOperation::AsValueInto(base::debug::TracedValue* value) const { | 257 scoped_ptr<base::Value> FilterOperation::AsValue() const { |
| 258 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
| 259 value->SetInteger("type", type_); | 259 value->SetInteger("type", type_); |
| 260 switch (type_) { | 260 switch (type_) { |
| 261 case FilterOperation::GRAYSCALE: | 261 case FilterOperation::GRAYSCALE: |
| 262 case FilterOperation::SEPIA: | 262 case FilterOperation::SEPIA: |
| 263 case FilterOperation::SATURATE: | 263 case FilterOperation::SATURATE: |
| 264 case FilterOperation::HUE_ROTATE: | 264 case FilterOperation::HUE_ROTATE: |
| 265 case FilterOperation::INVERT: | 265 case FilterOperation::INVERT: |
| 266 case FilterOperation::BRIGHTNESS: | 266 case FilterOperation::BRIGHTNESS: |
| 267 case FilterOperation::CONTRAST: | 267 case FilterOperation::CONTRAST: |
| 268 case FilterOperation::OPACITY: | 268 case FilterOperation::OPACITY: |
| 269 case FilterOperation::BLUR: | 269 case FilterOperation::BLUR: |
| 270 case FilterOperation::SATURATING_BRIGHTNESS: | 270 case FilterOperation::SATURATING_BRIGHTNESS: |
| 271 value->SetDouble("amount", amount_); | 271 value->SetDouble("amount", amount_); |
| 272 break; | 272 break; |
| 273 case FilterOperation::DROP_SHADOW: | 273 case FilterOperation::DROP_SHADOW: |
| 274 value->SetDouble("std_deviation", amount_); | 274 value->SetDouble("std_deviation", amount_); |
| 275 value->BeginArray("offset"); | 275 value->Set("offset", MathUtil::AsValue(drop_shadow_offset_).release()); |
| 276 MathUtil::AddToTracedValue(drop_shadow_offset_, value); | |
| 277 value->EndArray(); | |
| 278 value->SetInteger("color", drop_shadow_color_); | 276 value->SetInteger("color", drop_shadow_color_); |
| 279 break; | 277 break; |
| 280 case FilterOperation::COLOR_MATRIX: { | 278 case FilterOperation::COLOR_MATRIX: { |
| 281 value->BeginArray("matrix"); | 279 scoped_ptr<base::ListValue> matrix(new base::ListValue); |
| 282 for (size_t i = 0; i < arraysize(matrix_); ++i) | 280 for (size_t i = 0; i < arraysize(matrix_); ++i) |
| 283 value->AppendDouble(matrix_[i]); | 281 matrix->AppendDouble(matrix_[i]); |
| 284 value->EndArray(); | 282 value->Set("matrix", matrix.release()); |
| 285 break; | 283 break; |
| 286 } | 284 } |
| 287 case FilterOperation::ZOOM: | 285 case FilterOperation::ZOOM: |
| 288 value->SetDouble("amount", amount_); | 286 value->SetDouble("amount", amount_); |
| 289 value->SetDouble("inset", zoom_inset_); | 287 value->SetDouble("inset", zoom_inset_); |
| 290 break; | 288 break; |
| 291 case FilterOperation::REFERENCE: { | 289 case FilterOperation::REFERENCE: { |
| 292 int count_inputs = 0; | 290 int count_inputs = 0; |
| 293 bool can_filter_image_gpu = false; | 291 bool can_filter_image_gpu = false; |
| 294 if (image_filter_) { | 292 if (image_filter_) { |
| 295 count_inputs = image_filter_->countInputs(); | 293 count_inputs = image_filter_->countInputs(); |
| 296 can_filter_image_gpu = image_filter_->canFilterImageGPU(); | 294 can_filter_image_gpu = image_filter_->canFilterImageGPU(); |
| 297 } | 295 } |
| 298 value->SetBoolean("is_null", !image_filter_); | 296 value->SetBoolean("is_null", !image_filter_); |
| 299 value->SetInteger("count_inputs", count_inputs); | 297 value->SetInteger("count_inputs", count_inputs); |
| 300 value->SetBoolean("can_filter_image_gpu", can_filter_image_gpu); | 298 value->SetBoolean("can_filter_image_gpu", can_filter_image_gpu); |
| 301 break; | 299 break; |
| 302 } | 300 } |
| 303 case FilterOperation::ALPHA_THRESHOLD: { | 301 case FilterOperation::ALPHA_THRESHOLD: { |
| 304 value->SetDouble("inner_threshold", amount_); | 302 value->SetDouble("inner_threshold", amount_); |
| 305 value->SetDouble("outer_threshold", outer_threshold_); | 303 value->SetDouble("outer_threshold", outer_threshold_); |
| 306 scoped_ptr<base::ListValue> region_value(new base::ListValue()); | 304 scoped_ptr<base::ListValue> region_value(new base::ListValue()); |
| 307 value->BeginArray("region"); | |
| 308 for (SkRegion::Iterator it(region_); !it.done(); it.next()) { | 305 for (SkRegion::Iterator it(region_); !it.done(); it.next()) { |
| 309 value->AppendInteger(it.rect().x()); | 306 region_value->AppendInteger(it.rect().x()); |
| 310 value->AppendInteger(it.rect().y()); | 307 region_value->AppendInteger(it.rect().y()); |
| 311 value->AppendInteger(it.rect().width()); | 308 region_value->AppendInteger(it.rect().width()); |
| 312 value->AppendInteger(it.rect().height()); | 309 region_value->AppendInteger(it.rect().height()); |
| 313 } | 310 } |
| 314 value->EndArray(); | 311 value->Set("region", region_value.release()); |
| 315 } | 312 } |
| 316 break; | 313 break; |
| 317 } | 314 } |
| 315 return value.PassAs<base::Value>(); |
| 318 } | 316 } |
| 319 | 317 |
| 320 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |