| 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 "base/containers/hash_tables.h" | 5 #include "base/containers/hash_tables.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "skia/ext/benchmarking_canvas.h" | 8 #include "skia/ext/benchmarking_canvas.h" |
| 9 #include "third_party/skia/include/core/SkSurface.h" | 9 #include "third_party/skia/include/core/SkSurface.h" |
| 10 #include "third_party/skia/include/utils/SkProxyCanvas.h" | 10 #include "third_party/skia/include/utils/SkProxyCanvas.h" |
| 11 | 11 |
| 12 namespace skia { | 12 namespace skia { |
| 13 | 13 |
| 14 class AutoStamper { | 14 class AutoStamper { |
| 15 public: | 15 public: |
| 16 AutoStamper(TimingCanvas* timing_canvas); | 16 AutoStamper(TimingCanvas* timing_canvas); |
| 17 ~AutoStamper(); | 17 ~AutoStamper(); |
| 18 | 18 |
| 19 private: | 19 private: |
| 20 TimingCanvas* timing_canvas_; | 20 TimingCanvas* timing_canvas_; |
| 21 base::TimeTicks start_ticks_; | 21 base::TimeTicks start_ticks_; |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 class TimingCanvas : public SkProxyCanvas { | 24 class TimingCanvas : public SkProxyCanvas { |
| 25 public: | 25 public: |
| 26 TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas) | 26 TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas) |
| 27 : tracking_canvas_(track_canvas) { | 27 : tracking_canvas_(track_canvas) { |
| 28 surface_ = skia::AdoptRef(SkSurface::NewRasterPMColor(width, height)); | 28 surface_ = skia::AdoptRef(SkSurface::NewRasterN32Premul(width, height)); |
| 29 | 29 |
| 30 setProxy(surface_->getCanvas()); | 30 setProxy(surface_->getCanvas()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 ~TimingCanvas() override {} | 33 ~TimingCanvas() override {} |
| 34 | 34 |
| 35 double GetTime(size_t index) { | 35 double GetTime(size_t index) { |
| 36 TimingsMap::const_iterator timing_info = timings_map_.find(index); | 36 TimingsMap::const_iterator timing_info = timings_map_.find(index); |
| 37 return timing_info != timings_map_.end() | 37 return timing_info != timings_map_.end() |
| 38 ? timing_info->second.InMillisecondsF() | 38 ? timing_info->second.InMillisecondsF() |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 246 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
| 247 return debug_canvas_->getDrawCommandAt(index); | 247 return debug_canvas_->getDrawCommandAt(index); |
| 248 } | 248 } |
| 249 | 249 |
| 250 double BenchmarkingCanvas::GetTime(size_t index) { | 250 double BenchmarkingCanvas::GetTime(size_t index) { |
| 251 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 251 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
| 252 return timing_canvas_->GetTime(index); | 252 return timing_canvas_->GetTime(index); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace skia | 255 } // namespace skia |
| OLD | NEW |