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/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 #include "third_party/skia/include/utils/SkProxyCanvas.h" | 10 #include "third_party/skia/include/utils/SkProxyCanvas.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 const BenchmarkingCanvas* tracking_canvas_; | 196 const BenchmarkingCanvas* tracking_canvas_; |
197 }; | 197 }; |
198 | 198 |
199 AutoStamper::AutoStamper(TimingCanvas *timing_canvas) | 199 AutoStamper::AutoStamper(TimingCanvas *timing_canvas) |
200 : timing_canvas_(timing_canvas) { | 200 : timing_canvas_(timing_canvas) { |
201 start_ticks_ = base::TimeTicks::HighResNow(); | 201 start_ticks_ = base::TimeTicks::HighResNow(); |
202 } | 202 } |
203 | 203 |
204 AutoStamper::~AutoStamper() { | 204 AutoStamper::~AutoStamper() { |
205 base::TimeDelta delta = base::TimeTicks::HighResNow() - start_ticks_; | 205 base::TimeDelta delta = base::TimeTicks::HighResNow() - start_ticks_; |
206 int command_index = timing_canvas_->tracking_canvas_->CommandCount(); | 206 int command_index = timing_canvas_->tracking_canvas_->CommandCount() - 1; |
| 207 DCHECK_GE(command_index, 0); |
207 timing_canvas_->timings_map_[command_index] = delta; | 208 timing_canvas_->timings_map_[command_index] = delta; |
208 } | 209 } |
209 | 210 |
210 BenchmarkingCanvas::BenchmarkingCanvas(int width, int height) | 211 BenchmarkingCanvas::BenchmarkingCanvas(int width, int height) |
211 : SkNWayCanvas(width, height) { | 212 : SkNWayCanvas(width, height) { |
212 debug_canvas_ = skia::AdoptRef(SkNEW_ARGS(SkDebugCanvas, (width, height))); | 213 debug_canvas_ = skia::AdoptRef(SkNEW_ARGS(SkDebugCanvas, (width, height))); |
213 timing_canvas_ = skia::AdoptRef(SkNEW_ARGS(TimingCanvas, (width, height, this)
)); | 214 timing_canvas_ = skia::AdoptRef(SkNEW_ARGS(TimingCanvas, (width, height, this)
)); |
214 | 215 |
215 addCanvas(debug_canvas_.get()); | 216 addCanvas(debug_canvas_.get()); |
216 addCanvas(timing_canvas_.get()); | 217 addCanvas(timing_canvas_.get()); |
(...skipping 11 matching lines...) Expand all Loading... |
228 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 229 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
229 return debug_canvas_->getDrawCommandAt(index); | 230 return debug_canvas_->getDrawCommandAt(index); |
230 } | 231 } |
231 | 232 |
232 double BenchmarkingCanvas::GetTime(size_t index) { | 233 double BenchmarkingCanvas::GetTime(size_t index) { |
233 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 234 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
234 return timing_canvas_->GetTime(index); | 235 return timing_canvas_->GetTime(index); |
235 } | 236 } |
236 | 237 |
237 } // namespace skia | 238 } // namespace skia |
OLD | NEW |