Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: cc/output/filter_operation.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/filter_operation.h ('k') | cc/output/filter_operations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
7 #include "base/values.h" 8 #include "base/values.h"
8 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
9 #include "cc/output/filter_operation.h" 10 #include "cc/output/filter_operation.h"
10 #include "ui/gfx/animation/tween.h" 11 #include "ui/gfx/animation/tween.h"
11 12
12 namespace cc { 13 namespace cc {
13 14
14 bool FilterOperation::operator==(const FilterOperation& other) const { 15 bool FilterOperation::operator==(const FilterOperation& other) const {
15 if (type_ != other.type_) 16 if (type_ != other.type_)
16 return false; 17 return false;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 gfx::Tween::FloatValueBetween(progress, 248 gfx::Tween::FloatValueBetween(progress,
248 from_op.outer_threshold(), 249 from_op.outer_threshold(),
249 to_op.outer_threshold()), 250 to_op.outer_threshold()),
250 to_op.type())); 251 to_op.type()));
251 blended_filter.set_region(to_op.region()); 252 blended_filter.set_region(to_op.region());
252 } 253 }
253 254
254 return blended_filter; 255 return blended_filter;
255 } 256 }
256 257
257 scoped_ptr<base::Value> FilterOperation::AsValue() const { 258 void FilterOperation::AsValueInto(base::debug::TracedValue* value) 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->Set("offset", MathUtil::AsValue(drop_shadow_offset_).release()); 275 value->BeginArray("offset");
276 MathUtil::AddToTracedValue(drop_shadow_offset_, value);
277 value->EndArray();
276 value->SetInteger("color", drop_shadow_color_); 278 value->SetInteger("color", drop_shadow_color_);
277 break; 279 break;
278 case FilterOperation::COLOR_MATRIX: { 280 case FilterOperation::COLOR_MATRIX: {
279 scoped_ptr<base::ListValue> matrix(new base::ListValue); 281 value->BeginArray("matrix");
280 for (size_t i = 0; i < arraysize(matrix_); ++i) 282 for (size_t i = 0; i < arraysize(matrix_); ++i)
281 matrix->AppendDouble(matrix_[i]); 283 value->AppendDouble(matrix_[i]);
282 value->Set("matrix", matrix.release()); 284 value->EndArray();
283 break; 285 break;
284 } 286 }
285 case FilterOperation::ZOOM: 287 case FilterOperation::ZOOM:
286 value->SetDouble("amount", amount_); 288 value->SetDouble("amount", amount_);
287 value->SetDouble("inset", zoom_inset_); 289 value->SetDouble("inset", zoom_inset_);
288 break; 290 break;
289 case FilterOperation::REFERENCE: { 291 case FilterOperation::REFERENCE: {
290 int count_inputs = 0; 292 int count_inputs = 0;
291 bool can_filter_image_gpu = false; 293 bool can_filter_image_gpu = false;
292 if (image_filter_) { 294 if (image_filter_) {
293 count_inputs = image_filter_->countInputs(); 295 count_inputs = image_filter_->countInputs();
294 can_filter_image_gpu = image_filter_->canFilterImageGPU(); 296 can_filter_image_gpu = image_filter_->canFilterImageGPU();
295 } 297 }
296 value->SetBoolean("is_null", !image_filter_); 298 value->SetBoolean("is_null", !image_filter_);
297 value->SetInteger("count_inputs", count_inputs); 299 value->SetInteger("count_inputs", count_inputs);
298 value->SetBoolean("can_filter_image_gpu", can_filter_image_gpu); 300 value->SetBoolean("can_filter_image_gpu", can_filter_image_gpu);
299 break; 301 break;
300 } 302 }
301 case FilterOperation::ALPHA_THRESHOLD: { 303 case FilterOperation::ALPHA_THRESHOLD: {
302 value->SetDouble("inner_threshold", amount_); 304 value->SetDouble("inner_threshold", amount_);
303 value->SetDouble("outer_threshold", outer_threshold_); 305 value->SetDouble("outer_threshold", outer_threshold_);
304 scoped_ptr<base::ListValue> region_value(new base::ListValue()); 306 scoped_ptr<base::ListValue> region_value(new base::ListValue());
307 value->BeginArray("region");
305 for (SkRegion::Iterator it(region_); !it.done(); it.next()) { 308 for (SkRegion::Iterator it(region_); !it.done(); it.next()) {
306 region_value->AppendInteger(it.rect().x()); 309 value->AppendInteger(it.rect().x());
307 region_value->AppendInteger(it.rect().y()); 310 value->AppendInteger(it.rect().y());
308 region_value->AppendInteger(it.rect().width()); 311 value->AppendInteger(it.rect().width());
309 region_value->AppendInteger(it.rect().height()); 312 value->AppendInteger(it.rect().height());
310 } 313 }
311 value->Set("region", region_value.release()); 314 value->EndArray();
312 } 315 }
313 break; 316 break;
314 } 317 }
315 return value.PassAs<base::Value>();
316 } 318 }
317 319
318 } // namespace cc 320 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/filter_operation.h ('k') | cc/output/filter_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698