Handle recording a bitmap if copy fails.

If SkBitmapHeap::insert() returns INVALID_SLOT, assert at picture
record time so we can debug, but allow it to continue in release
mode, so that we can still capture a picture. At playback time,
print a message so we know that there was an error.

Review URL: https://codereview.appspot.com/6873050

git-svn-id: http://skia.googlecode.com/svn/trunk@6664 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index d6f51e3..270eee5 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -657,7 +657,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
-    addInt(fBitmapHeap->insert(bitmap));
+    const int index = fBitmapHeap->insert(bitmap);
+    // In debug builds, a bad return value from insert() will crash, allowing for debugging. In
+    // release builds, the invalid value will be recorded so that the reader will know that there
+    // was a problem.
+    SkASSERT(index != SkBitmapHeap::INVALID_SLOT);
+    addInt(index);
 }
 
 void SkPictureRecord::addMatrix(const SkMatrix& matrix) {