Plugin Power Saver: Force SW rendering for peripheral plugins.
[chromium-blink-merge.git] / skia / ext / benchmarking_canvas.h
blob50289a5746b57cce5d6f56938e94cf875be6dc02
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.
5 #ifndef SKIA_EXT_BENCHMARKING_CANVAS_H_
6 #define SKIA_EXT_BENCHMARKING_CANVAS_H_
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"
13 namespace skia {
15 class TimingCanvas;
17 class SK_API BenchmarkingCanvas : public SkNWayCanvas {
18 public:
19 BenchmarkingCanvas(int width, int height);
20 ~BenchmarkingCanvas() override;
22 // Returns the number of draw commands executed on this canvas.
23 size_t CommandCount() const;
25 // Get draw command info for a given index.
26 SkDrawCommand* GetCommand(size_t index);
28 // Return the recorded render time (milliseconds) for a draw command index.
29 double GetTime(size_t index);
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).
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.
45 skia::RefPtr<SkDebugCanvas> debug_canvas_;
46 skia::RefPtr<TimingCanvas> timing_canvas_;
50 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H