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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 op_record_->SetString("cmd_string", op_name); | 463 op_record_->SetString("cmd_string", op_name); |
464 op_record_->Set("info", op_params_); | 464 op_record_->Set("info", op_params_); |
465 | 465 |
466 if (paint) | 466 if (paint) |
467 this->addParam("paint", AsValue(*paint)); | 467 this->addParam("paint", AsValue(*paint)); |
468 | 468 |
469 if (canvas->flags_ & kOverdrawVisualization_Flag) { | 469 if (canvas->flags_ & kOverdrawVisualization_Flag) { |
470 DCHECK(canvas->overdraw_xfermode_); | 470 DCHECK(canvas->overdraw_xfermode_); |
471 | 471 |
472 paint_ = paint ? filtered_paint_.set(*paint) : filtered_paint_.init(); | 472 paint_ = paint ? filtered_paint_.set(*paint) : filtered_paint_.init(); |
473 filtered_paint_.get()->setXfermode(canvas->overdraw_xfermode_.get()); | 473 filtered_paint_.get()->setXfermode(canvas->overdraw_xfermode_); |
474 filtered_paint_.get()->setAntiAlias(false); | 474 filtered_paint_.get()->setAntiAlias(false); |
475 } | 475 } |
476 | 476 |
477 start_ticks_ = base::TimeTicks::Now(); | 477 start_ticks_ = base::TimeTicks::Now(); |
478 } | 478 } |
479 | 479 |
480 ~AutoOp() { | 480 ~AutoOp() { |
481 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; | 481 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; |
482 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); | 482 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); |
483 | 483 |
(...skipping 19 matching lines...) Expand all Loading... |
503 SkTLazy<SkPaint> filtered_paint_; | 503 SkTLazy<SkPaint> filtered_paint_; |
504 }; | 504 }; |
505 | 505 |
506 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) | 506 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) |
507 : INHERITED(canvas->imageInfo().width(), | 507 : INHERITED(canvas->imageInfo().width(), |
508 canvas->imageInfo().height()) | 508 canvas->imageInfo().height()) |
509 , flags_(flags) { | 509 , flags_(flags) { |
510 addCanvas(canvas); | 510 addCanvas(canvas); |
511 | 511 |
512 if (flags & kOverdrawVisualization_Flag) | 512 if (flags & kOverdrawVisualization_Flag) |
513 overdraw_xfermode_ = AdoptRef(new OverdrawXfermode); | 513 overdraw_xfermode_ = sk_make_sp<OverdrawXfermode>(); |
514 } | 514 } |
515 | 515 |
516 BenchmarkingCanvas::~BenchmarkingCanvas() { | 516 BenchmarkingCanvas::~BenchmarkingCanvas() { |
517 } | 517 } |
518 | 518 |
519 size_t BenchmarkingCanvas::CommandCount() const { | 519 size_t BenchmarkingCanvas::CommandCount() const { |
520 return op_records_.GetSize(); | 520 return op_records_.GetSize(); |
521 } | 521 } |
522 | 522 |
523 const base::ListValue& BenchmarkingCanvas::Commands() const { | 523 const base::ListValue& BenchmarkingCanvas::Commands() const { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 DCHECK(blob); | 795 DCHECK(blob); |
796 AutoOp op(this, "DrawTextBlob", &paint); | 796 AutoOp op(this, "DrawTextBlob", &paint); |
797 op.addParam("blob", AsValue(*blob)); | 797 op.addParam("blob", AsValue(*blob)); |
798 op.addParam("x", AsValue(x)); | 798 op.addParam("x", AsValue(x)); |
799 op.addParam("y", AsValue(y)); | 799 op.addParam("y", AsValue(y)); |
800 | 800 |
801 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); | 801 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); |
802 } | 802 } |
803 | 803 |
804 } // namespace skia | 804 } // namespace skia |
OLD | NEW |