add pixelref->readPixels()

unimplemented (for now) on the gpu side



git-svn-id: http://skia.googlecode.com/svn/trunk@1037 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 177ecec..8fb368a 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -20,7 +20,9 @@
 #include "SkRefCnt.h"
 #include "SkString.h"
 
+class SkBitmap;
 class SkColorTable;
+struct SkIRect;
 class SkMutex;
 class SkFlattenableReadBuffer;
 class SkFlattenableWriteBuffer;
@@ -112,6 +114,8 @@
      */
     virtual SkGpuTexture* getTexture() { return NULL; }
 
+    bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL);
+
     // serialization
 
     typedef SkPixelRef* (*Factory)(SkFlattenableReadBuffer&);
@@ -157,6 +161,14 @@
     */
     virtual void onUnlockPixels() = 0;
 
+    /**
+     *  For pixelrefs that don't have access to their raw pixels, they may be
+     *  able to make a copy of them (e.g. if the pixels are on the GPU).
+     *
+     *  The base class implementation returns false;
+     */
+    virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull);
+
     /** Return the mutex associated with this pixelref. This value is assigned
         in the constructor, and cannot change during the lifetime of the object.
     */
diff --git a/include/gpu/SkGrTexturePixelRef.h b/include/gpu/SkGrTexturePixelRef.h
index 1f5133f..a423251 100644
--- a/include/gpu/SkGrTexturePixelRef.h
+++ b/include/gpu/SkGrTexturePixelRef.h
@@ -40,6 +40,7 @@
 
     // override from SkPixelRef
     virtual void onUnlockPixels() {}
+    virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
 
 private:
     GrTexture*  fTexture;