Index: content/renderer/skia_benchmarking/skia_benchmarking_canvas.h |
diff --git a/content/renderer/skia_benchmarking/skia_benchmarking_canvas.h b/content/renderer/skia_benchmarking/skia_benchmarking_canvas.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..02fa9a8d625379425b069b92305311511e44d172 |
--- /dev/null |
+++ b/content/renderer/skia_benchmarking/skia_benchmarking_canvas.h |
@@ -0,0 +1,54 @@ |
+// 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 CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H_ |
+#define CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "base/memory/ref_counted.h" |
+#include "third_party/skia/include/utils/SkNWayCanvas.h" |
+#include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" |
+ |
+namespace gfx { |
+class Rect; |
+} |
+ |
+namespace content { |
+ |
+class SkiaTimingCanvas; |
+ |
+class SkiaBenchmarkingCanvas : public SkNWayCanvas { |
+public: |
+ SkiaBenchmarkingCanvas(const gfx::Rect&); |
+ virtual ~SkiaBenchmarkingCanvas(); |
+ |
+ // 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 (microseconds) for a draw command index. |
+ int64 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. |
+ |
+ scoped_refptr<SkDebugCanvas> debug_canvas_; |
+ scoped_refptr<SkiaTimingCanvas> timing_canvas_; |
+}; |
+ |
+} |
+#endif // CONTENT_RENDERER_SKIA_BENCHMARKING_CANVAS_H |