Fixes for piping bitmaps with encoded data.

Similar goals as https://codereview.chromium.org/14437012.

Builds on patch set 1 from that issue
(https://codereview.chromium.org/14437012/#ps1).

Instead of the changes in patch set 2 from that issue, this
changes SkOrderedWriteBuffer::writeBitmap to store whether an
SkBitmapHeap was used when to store the index of the SkBitmap.
SkOrderedReadBuffer::readBitmap now uses that information to
distinguish between using the heap and unflattening.

In addition, writeBitmap now records the width/height first in
all cases. If now SkBitmapHeapReader is attached, but an
SkBitmapHeap was used to record the bitmap, reading will fail
and provide the same red SkBitmap as in the case where the
SkBitmap was encoded but could not be decoded.

Updates the PICTURE_VERSION as well.

The key differences in this CL to look at are in:
SkOrderedWriteBuffer,
SkOrderedReadBuffer,
and SkPicture.

BUG=
R=djsollen@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@8917 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 420b684..f3d6ee8 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -946,7 +946,10 @@
         //@todo thudson 22 April 2011 when can we safely delete [] dst?
         storage.copyTo(dst);
         SkMemoryStream pictReadback(dst, streamSize);
-        SkPicture* retval = new SkPicture (&pictReadback);
+        bool success;
+        // Pass a decoding bitmap function so that the factory GM (which has an SkBitmap with
+        // encoded data) does not fail.
+        SkPicture* retval = new SkPicture (&pictReadback, &success, &SkImageDecoder::DecodeMemory);
         return retval;
     }
 
@@ -1037,7 +1040,9 @@
                 setup_bitmap(gRec, size, &bitmap);
                 SkCanvas canvas(bitmap);
                 installFilter(&canvas);
-                PipeController pipeController(&canvas);
+                // Pass a decoding function so the factory GM (which has an SkBitmap
+                // with encoded data) will not fail playback.
+                PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
                 SkGPipeWriter writer;
                 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
                                                              gPipeWritingFlagCombos[i].flags,
@@ -1076,7 +1081,7 @@
                 setup_bitmap(gRec, size, &bitmap);
                 SkCanvas canvas(bitmap);
                 installFilter(&canvas);
-                TiledPipeController pipeController(bitmap);
+                TiledPipeController pipeController(bitmap, &SkImageDecoder::DecodeMemory);
                 SkGPipeWriter writer;
                 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
                                                              gPipeWritingFlagCombos[i].flags,