summaryrefslogtreecommitdiffstats
path: root/skia/ext/benchmarking_canvas.h
diff options
context:
space:
mode:
Diffstat (limited to 'skia/ext/benchmarking_canvas.h')
-rw-r--r--skia/ext/benchmarking_canvas.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/skia/ext/benchmarking_canvas.h b/skia/ext/benchmarking_canvas.h
new file mode 100644
index 0000000..7ef8204
--- /dev/null
+++ b/skia/ext/benchmarking_canvas.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_BENCHMARKING_CANVAS_H_
+#define SKIA_EXT_BENCHMARKING_CANVAS_H_
+
+#include "base/compiler_specific.h"
+#include "skia/ext/refptr.h"
+#include "third_party/skia/include/utils/SkNWayCanvas.h"
+#include "third_party/skia/src/utils/debugger/SkDebugCanvas.h"
+
+namespace skia {
+
+class TimingCanvas;
+
+class SK_API BenchmarkingCanvas : public SkNWayCanvas {
+public:
+ BenchmarkingCanvas(int width, int height);
+ virtual ~BenchmarkingCanvas();
+
+ // Returns the number of draw commands executed on this canvas.
+ size_t CommandCount() const;
+
+ // Get draw command info for a given index.
+ SkDrawCommand* GetCommand(size_t index);
+
+ // Return the recorded render time (milliseconds) for a draw command index.
+ double GetTime(size_t index);
+
+private:
+ // In order to avoid introducing a Skia version dependency, this
+ // implementation dispatches draw commands in lock-step to two distinct
+ // canvases:
+ // * a SkDebugCanvas used for gathering command info and tracking
+ // the current command index
+ // * a SkiaTimingCanvas used for measuring raster paint times (and relying
+ // on the former for tracking the current command index).
+ //
+ // This way, if the SkCanvas API is extended, we don't need to worry about
+ // updating content::SkiaTimingCanvas to accurately override all new methods
+ // (to avoid timing info indices from getting out of sync), as SkDebugCanvas
+ // already does that for us.
+
+ skia::RefPtr<SkDebugCanvas> debug_canvas_;
+ skia::RefPtr<TimingCanvas> timing_canvas_;
+};
+
+}
+#endif // SKIA_EXT_BENCHMARKING_CANVAS_H