OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H_ |
| 6 #define CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "third_party/skia/include/utils/SkNWayCanvas.h" |
| 11 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" |
| 12 |
| 13 namespace gfx { |
| 14 class Rect; |
| 15 } |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class SkiaTimingCanvas; |
| 20 |
| 21 class SkiaBenchmarkingCanvas : public SkNWayCanvas { |
| 22 public: |
| 23 SkiaBenchmarkingCanvas(const gfx::Rect&); |
| 24 virtual ~SkiaBenchmarkingCanvas(); |
| 25 |
| 26 // Returns the number of draw commands executed on this canvas. |
| 27 size_t CommandCount() const; |
| 28 |
| 29 // Get draw command info for a given index. |
| 30 SkDrawCommand* GetCommand(size_t index); |
| 31 |
| 32 // Return the recorded render time (microseconds) for a draw command index. |
| 33 int64 GetTime(size_t index); |
| 34 |
| 35 private: |
| 36 // In order to avoid introducing a Skia version dependency, this |
| 37 // implementation dispatches draw commands in lock-step to two distinct |
| 38 // canvases: |
| 39 // * a SkDebugCanvas used for gathering command info and tracking |
| 40 // the current command index |
| 41 // * a SkiaTimingCanvas used for measuring raster paint times (and relying |
| 42 // on the former for tracking the current command index). |
| 43 // |
| 44 // This way, if the SkCanvas API is extended, we don't need to worry about |
| 45 // updating content::SkiaTimingCanvas to accurately override all new methods |
| 46 // (to avoid timing info indices from getting out of sync), as SkDebugCanvas |
| 47 // already does that for us. |
| 48 |
| 49 scoped_refptr<SkDebugCanvas> debug_canvas_; |
| 50 scoped_refptr<SkiaTimingCanvas> timing_canvas_; |
| 51 }; |
| 52 |
| 53 } |
| 54 #endif // CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H |
OLD | NEW |