Revert of Revert "Serialization of SkPictureImageFilter" (https://codereview.chromium.org/153583007/)

Reason for revert:
New SKPs with version20 are in Google Storage due to http://108.170.219.160:10117/builders/Housekeeper-Nightly-RecreateSKPs/builds/22

Original issue's description:
> Revert "Serialization of SkPictureImageFilter"
>
> This reverts commit 227321b30106e57942929eb96fa5bc22544f6c9e.
>
> Revert "Sanitizing source files in Housekeeper-Nightly"
>
> This reverts commit baf28584b7636c01355f8d8d972e06aa7fb66d77.
>
> TBR=robertphillips@google.com,sugoi@google.com
>
> Committed: https://code.google.com/p/skia/source/detail?r=13356

R=robertphillips@google.com, sugoi@google.com, fmalita@google.com, fmalita@chromium.org
TBR=fmalita@chromium.org, fmalita@google.com, robertphillips@google.com, sugoi@google.com
NOTREECHECKS=true
NOTRY=true

Author: rmistry@google.com

Review URL: https://codereview.chromium.org/143163005

git-svn-id: http://skia.googlecode.com/svn/trunk@13357 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 2353655..c9f9396 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -85,7 +85,7 @@
      *  ignored.
      */
     const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const;
-    
+
     /**
      *  Encode the image's pixels and return the result as a new SkData, which
      *  the caller must manage (i.e. call unref() when they are done).
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 82d6835..a717153 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -68,6 +68,16 @@
     static SkPicture* CreateFromStream(SkStream*,
                                        InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory);
 
+    /**
+     *  Recreate a picture that was serialized into a buffer. If the creation requires bitmap
+     *  decoding, the decoder must be set on the SkReadBuffer parameter by calling
+     *  SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer().
+     *  @param SkReadBuffer Serialized picture data.
+     *  @return A new SkPicture representing the serialized data, or NULL if the buffer is
+     *          invalid.
+     */
+    static SkPicture* CreateFromBuffer(SkReadBuffer&);
+
     virtual ~SkPicture();
 
     /**
@@ -187,6 +197,11 @@
     void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
 
     /**
+     *  Serialize to a buffer.
+     */
+    void flatten(SkWriteBuffer&) const;
+
+    /**
      * Returns true if any bitmaps may be produced when this SkPicture
      * is replayed.
      * Returns false if called while still recording.
@@ -223,7 +238,8 @@
     // V17: SkPixelRef now writes SkImageInfo
     // V18: SkBitmap now records x,y for its pixelref origin, instead of offset.
     // V19: encode matrices and regions into the ops stream
-    static const uint32_t PICTURE_VERSION = 19;
+    // V20: added bool to SkPictureImageFilter's serialization (to allow SkPicture serialization)
+    static const uint32_t PICTURE_VERSION = 20;
 
     // fPlayback, fRecord, fWidth & fHeight are protected to allow derived classes to
     // install their own SkPicturePlayback-derived players,SkPictureRecord-derived
@@ -245,7 +261,10 @@
     // will be ready to be parsed to create an SkPicturePlayback.
     // If false is returned, SkPictInfo is unmodified.
     static bool StreamIsSKP(SkStream*, SkPictInfo*);
+    static bool BufferIsSKP(SkReadBuffer&, SkPictInfo*);
 private:
+    void createHeader(void* header) const;
+
     friend class SkFlatPicture;
     friend class SkPicturePlayback;