Adding SkSurface support to SkDeferredCanvas
Review URL: https://codereview.chromium.org/14178002
git-svn-id: http://skia.googlecode.com/svn/trunk/include@8648 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/utils/SkDeferredCanvas.h b/utils/SkDeferredCanvas.h
index 53bea82..97b4a66 100644
--- a/utils/SkDeferredCanvas.h
+++ b/utils/SkDeferredCanvas.h
@@ -12,6 +12,8 @@
#include "SkPixelRef.h"
class DeferredDevice;
+class SkImage;
+class SkSurface;
/** \class SkDeferredCanvas
Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred
@@ -33,6 +35,12 @@
*/
explicit SkDeferredCanvas(SkDevice* device);
+ /** Construct a canvas with the specified surface to draw into.
+ This constructor must be used for newImageSnapshot to work.
+ @param surface Specifies a surface for the canvas to draw into.
+ */
+ explicit SkDeferredCanvas(SkSurface* surface);
+
virtual ~SkDeferredCanvas();
/**
@@ -93,6 +101,15 @@
bool hasPendingCommands() const;
/**
+ * Flushes pending draw commands, if any, and returns an image of the
+ * current state of the surface pixels up to this point. Subsequent
+ * changes to the surface (by drawing into its canvas) will not be
+ * reflected in this image. Will return NULL if the deferred canvas
+ * was not constructed from an SkSurface.
+ */
+ SkImage* newImageShapshot();
+
+ /**
* Specify the maximum number of bytes to be allocated for the purpose
* of recording draw commands to this canvas. The default limit, is
* 64MB.