OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "skia/ext/benchmarking_canvas.h" | 5 #include "skia/ext/benchmarking_canvas.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 372 } |
373 | 373 |
374 } // namespace | 374 } // namespace |
375 | 375 |
376 namespace skia { | 376 namespace skia { |
377 | 377 |
378 class BenchmarkingCanvas::AutoOp { | 378 class BenchmarkingCanvas::AutoOp { |
379 public: | 379 public: |
380 // AutoOp objects are always scoped within draw call frames, | 380 // AutoOp objects are always scoped within draw call frames, |
381 // so the paint is guaranteed to be valid for their lifetime. | 381 // so the paint is guaranteed to be valid for their lifetime. |
382 AutoOp(BenchmarkingCanvas* canvas, const char op_name[], | 382 AutoOp(BenchmarkingCanvas* canvas, |
383 const SkPaint* paint = nullptr) | 383 const char op_name[], |
384 : canvas_(canvas) | 384 const SkPaint* paint = nullptr) |
385 , op_record_(new base::DictionaryValue()) | 385 : canvas_(canvas), op_record_(new base::DictionaryValue()) { |
386 , op_params_(new base::ListValue()) { | 386 DCHECK(canvas); |
| 387 DCHECK(op_name); |
387 | 388 |
388 DCHECK(canvas); | 389 op_record_->SetString("cmd_string", op_name); |
389 DCHECK(op_name); | 390 op_params_ = |
| 391 op_record_->SetList("info", base::MakeUnique<base::ListValue>()); |
390 | 392 |
391 op_record_->SetString("cmd_string", op_name); | 393 if (paint) { |
392 op_record_->Set("info", op_params_); | 394 this->addParam("paint", AsValue(*paint)); |
| 395 filtered_paint_ = *paint; |
| 396 } |
393 | 397 |
394 if (paint) { | 398 start_ticks_ = base::TimeTicks::Now(); |
395 this->addParam("paint", AsValue(*paint)); | |
396 filtered_paint_ = *paint; | |
397 } | |
398 | |
399 start_ticks_ = base::TimeTicks::Now(); | |
400 } | 399 } |
401 | 400 |
402 ~AutoOp() { | 401 ~AutoOp() { |
403 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; | 402 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; |
404 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); | 403 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); |
405 | 404 |
406 canvas_->op_records_.Append(std::move(op_record_)); | 405 canvas_->op_records_.Append(std::move(op_record_)); |
407 } | 406 } |
408 | 407 |
409 void addParam(const char name[], std::unique_ptr<base::Value> value) { | 408 void addParam(const char name[], std::unique_ptr<base::Value> value) { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 DCHECK(blob); | 711 DCHECK(blob); |
713 AutoOp op(this, "DrawTextBlob", &paint); | 712 AutoOp op(this, "DrawTextBlob", &paint); |
714 op.addParam("blob", AsValue(*blob)); | 713 op.addParam("blob", AsValue(*blob)); |
715 op.addParam("x", AsValue(x)); | 714 op.addParam("x", AsValue(x)); |
716 op.addParam("y", AsValue(y)); | 715 op.addParam("y", AsValue(y)); |
717 | 716 |
718 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); | 717 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); |
719 } | 718 } |
720 | 719 |
721 } // namespace skia | 720 } // namespace skia |
OLD | NEW |