Add caching of the snapshot image form a surface
Notify the surface when the canvas draws into it, so it can invalidate the
cached image, and (if needed) perform a copy-on-write on the surface if it
was being shared with the image.
Review URL: https://codereview.appspot.com/6441115

git-svn-id: http://skia.googlecode.com/svn/trunk@5306 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 216f094..daed241 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -59,6 +59,8 @@
     // exposed for SkSurface_Raster via SkNewImageFromPixelRef
     SkImage_Raster(const SkImage::Info&, SkPixelRef*, size_t rowBytes);
 
+    SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
+
 private:
     SkImage_Raster() : INHERITED(0, 0) {}
 
@@ -93,8 +95,6 @@
 
 SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes)
 : INHERITED(info.fWidth, info.fHeight) {
-    SkASSERT(pr->isImmutable());
-
     bool isOpaque;
     SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
 
@@ -159,3 +159,7 @@
     return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
 }
 
+SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
+    return ((SkImage_Raster*)image)->getPixelRef();
+}
+