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/SkBitmapDevice.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 skia::RefPtr<SkDevice> device = skia::AdoptRef( | 28 skia::RefPtr<SkBaseDevice> device = skia::AdoptRef( |
29 SkNEW_ARGS(SkDevice, (SkBitmap::kARGB_8888_Config, width, height))); | 29 SkNEW_ARGS(SkBitmapDevice, (SkBitmap::kARGB_8888_Config, width, height))
); |
30 canvas_ = skia::AdoptRef(SkNEW_ARGS(SkCanvas, (device.get()))); | 30 canvas_ = skia::AdoptRef(SkNEW_ARGS(SkCanvas, (device.get()))); |
31 | 31 |
32 setProxy(canvas_.get()); | 32 setProxy(canvas_.get()); |
33 } | 33 } |
34 | 34 |
35 virtual ~TimingCanvas() { | 35 virtual ~TimingCanvas() { |
36 } | 36 } |
37 | 37 |
38 double GetTime(size_t index) { | 38 double GetTime(size_t index) { |
39 TimingsMap::const_iterator timing_info = timings_map_.find(index); | 39 TimingsMap::const_iterator timing_info = timings_map_.find(index); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 230 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
231 return debug_canvas_->getDrawCommandAt(index); | 231 return debug_canvas_->getDrawCommandAt(index); |
232 } | 232 } |
233 | 233 |
234 double BenchmarkingCanvas::GetTime(size_t index) { | 234 double BenchmarkingCanvas::GetTime(size_t index) { |
235 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 235 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
236 return timing_canvas_->GetTime(index); | 236 return timing_canvas_->GetTime(index); |
237 } | 237 } |
238 | 238 |
239 } // namespace skia | 239 } // namespace skia |
OLD | NEW |