• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SKIA_EXT_BENCHMARKING_CANVAS_H_
6 #define SKIA_EXT_BENCHMARKING_CANVAS_H_
7 
8 #include "base/compiler_specific.h"
9 #include "skia/ext/refptr.h"
10 #include "third_party/skia/include/utils/SkNWayCanvas.h"
11 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h"
12 
13 namespace skia {
14 
15 class TimingCanvas;
16 
17 class SK_API BenchmarkingCanvas : public SkNWayCanvas {
18 public:
19   BenchmarkingCanvas(int width, int height);
20   virtual ~BenchmarkingCanvas();
21 
22   // Returns the number of draw commands executed on this canvas.
23   size_t CommandCount() const;
24 
25   // Get draw command info for a given index.
26   SkDrawCommand* GetCommand(size_t index);
27 
28   // Return the recorded render time (milliseconds) for a draw command index.
29   double GetTime(size_t index);
30 
31 private:
32   // In order to avoid introducing a Skia version dependency, this
33   // implementation dispatches draw commands in lock-step to two distinct
34   // canvases:
35   //   * a SkDebugCanvas used for gathering command info and tracking
36   //     the current command index
37   //   * a SkiaTimingCanvas used for measuring raster paint times (and relying
38   //     on the former for tracking the current command index).
39   //
40   // This way, if the SkCanvas API is extended, we don't need to worry about
41   // updating content::SkiaTimingCanvas to accurately override all new methods
42   // (to avoid timing info indices from getting out of sync), as SkDebugCanvas
43   // already does that for us.
44 
45   skia::RefPtr<SkDebugCanvas> debug_canvas_;
46   skia::RefPtr<TimingCanvas> timing_canvas_;
47 };
48 
49 }
50 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H
51