Adding option to serialize mutable bitmaps in SkPicture

BUG=http://code.google.com/p/chromium/issues/detail?id=115654
REVIEW=http://codereview.appspot.com/6221066/



git-svn-id: http://skia.googlecode.com/svn/trunk@4130 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 96809bf..4d0e962 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -86,12 +86,27 @@
     }
 
     void reset();
+    void setFlags(uint32_t recordFlags) {
+        fRecordFlags = recordFlags;
+    }
 
     const SkWriter32& writeStream() const {
         return fWriter;
     }
 
+    bool shouldFlattenPixels(const SkBitmap&) const;
 private:
+    struct PixelRefDictionaryEntry {
+        uint32_t fKey; // SkPixelRef GenerationID.
+        uint32_t fIndex; // Index of corresponding flattened bitmap in fBitmaps.
+        bool operator < (const PixelRefDictionaryEntry& other) const {
+            return this->fKey < other.fKey;
+        } 
+        bool operator != (const PixelRefDictionaryEntry& other) const {
+            return this->fKey != other.fKey;
+        } 
+    };
+
     SkTDArray<uint32_t> fRestoreOffsetStack;
     int fFirstSavedLayerIndex;
     enum {
@@ -127,6 +142,8 @@
     void addRegion(const SkRegion& region);
     void addText(const void* text, size_t byteLength);
 
+    int find(const SkBitmap& bitmap);
+
 #ifdef SK_DEBUG_DUMP
 public:
     void dumpMatrices();
@@ -163,6 +180,8 @@
 
 private:
     SkChunkAlloc fHeap;
+
+    SkTDArray<PixelRefDictionaryEntry> fPixelRefDictionary;
     SkBitmapDictionary fBitmaps;
     SkMatrixDictionary fMatrices;
     SkPaintDictionary fPaints;