Null canvas
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 11 Jun 2012 15:39:15 +0000 (15:39 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 11 Jun 2012 15:39:15 +0000 (15:39 +0000)
Review URL: http://codereview.appspot.com/6117051/

git-svn-id: http://skia.googlecode.com/svn/trunk@4220 2bbb7eff-a529-9590-31e7-b0007b416f81

gyp/utils.gyp
include/utils/SkNullCanvas.h [new file with mode: 0644]
src/utils/SkNullCanvas.cpp [new file with mode: 0644]

index d2c413e..9b11e59 100644 (file)
@@ -26,6 +26,7 @@
         '../include/utils/SkMeshUtils.h',
         '../include/utils/SkNinePatch.h',
         '../include/utils/SkNWayCanvas.h',
+        '../include/utils/SkNullCanvas.h',
         '../include/utils/SkParse.h',
         '../include/utils/SkParsePaint.h',
         '../include/utils/SkParsePath.h',
@@ -50,6 +51,7 @@
         '../src/utils/SkMeshUtils.cpp',
         '../src/utils/SkNinePatch.cpp',
         '../src/utils/SkNWayCanvas.cpp',
+        '../src/utils/SkNullCanvas.cpp',
         '../src/utils/SkOSFile.cpp',
         '../src/utils/SkParse.cpp',
         '../src/utils/SkParseColor.cpp',
diff --git a/include/utils/SkNullCanvas.h b/include/utils/SkNullCanvas.h
new file mode 100644 (file)
index 0000000..62a9edd
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkNullCanvas_DEFINED
+#define SkNullCanvas_DEFINED
+
+#include "SkBitmap.h"
+
+class SkCanvas;
+
+/**
+ * Creates a canvas that draws nothing. This is useful for performance testing.
+ */
+SkCanvas* SkCreateNullCanvas();
+
+#endif
diff --git a/src/utils/SkNullCanvas.cpp b/src/utils/SkNullCanvas.cpp
new file mode 100644 (file)
index 0000000..2dc448f
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkNullCanvas.h"
+
+#include "SkCanvas.h"
+#include "SKNWayCanvas.h"
+
+
+SkCanvas* SkCreateNullCanvas() {
+    // An N-Way canvas forwards calls to N canvas's. When N == 0 it's
+    // effectively a null canvas.
+    return SkNEW(SkNWayCanvas);
+}