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/SkBitmapDevice.h" | |
10 #include "third_party/skia/include/utils/SkProxyCanvas.h" | 9 #include "third_party/skia/include/utils/SkProxyCanvas.h" |
11 | 10 |
12 namespace skia { | 11 namespace skia { |
13 | 12 |
14 class AutoStamper { | 13 class AutoStamper { |
15 public: | 14 public: |
16 AutoStamper(TimingCanvas* timing_canvas); | 15 AutoStamper(TimingCanvas* timing_canvas); |
17 ~AutoStamper(); | 16 ~AutoStamper(); |
18 | 17 |
19 private: | 18 private: |
20 TimingCanvas* timing_canvas_; | 19 TimingCanvas* timing_canvas_; |
21 base::TimeTicks start_ticks_; | 20 base::TimeTicks start_ticks_; |
22 }; | 21 }; |
23 | 22 |
24 class TimingCanvas : public SkProxyCanvas { | 23 class TimingCanvas : public SkProxyCanvas { |
25 public: | 24 public: |
26 TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas) | 25 TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas) |
27 : tracking_canvas_(track_canvas) { | 26 : tracking_canvas_(track_canvas) { |
28 skia::RefPtr<SkBaseDevice> device = skia::AdoptRef( | 27 canvas_ = skia::AdoptRef(SkCanvas::NewRasterN32(width, height)); |
29 SkNEW_ARGS(SkBitmapDevice, (SkBitmap::kARGB_8888_Config, width, height))
); | |
30 canvas_ = skia::AdoptRef(SkNEW_ARGS(SkCanvas, (device.get()))); | |
31 | 28 |
32 setProxy(canvas_.get()); | 29 setProxy(canvas_.get()); |
33 } | 30 } |
34 | 31 |
35 virtual ~TimingCanvas() { | 32 virtual ~TimingCanvas() { |
36 } | 33 } |
37 | 34 |
38 double GetTime(size_t index) { | 35 double GetTime(size_t index) { |
39 TimingsMap::const_iterator timing_info = timings_map_.find(index); | 36 TimingsMap::const_iterator timing_info = timings_map_.find(index); |
40 return timing_info != timings_map_.end() | 37 return timing_info != timings_map_.end() |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 227 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
231 return debug_canvas_->getDrawCommandAt(index); | 228 return debug_canvas_->getDrawCommandAt(index); |
232 } | 229 } |
233 | 230 |
234 double BenchmarkingCanvas::GetTime(size_t index) { | 231 double BenchmarkingCanvas::GetTime(size_t index) { |
235 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 232 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
236 return timing_canvas_->GetTime(index); | 233 return timing_canvas_->GetTime(index); |
237 } | 234 } |
238 | 235 |
239 } // namespace skia | 236 } // namespace skia |
OLD | NEW |