fix images in multi-thread by doing shallow-copies

BUG=skia:
TBR=mtklein@google.com

Review URL: https://codereview.chromium.org/791473006
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
index ed099a0..c85c567 100644
--- a/src/core/SkMultiPictureDraw.cpp
+++ b/src/core/SkMultiPictureDraw.cpp
@@ -84,13 +84,22 @@
     ~AutoMPDReset() { fMPD->reset(); }
 };
 
+//#define FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
+
 void SkMultiPictureDraw::draw() {
     AutoMPDReset mpdreset(this);
+
+#ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
+    for (int i = 0; i < fThreadSafeDrawData.count(); ++i) {
+        DrawData* dd = &fThreadSafeDrawData.begin()[i];
+        dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint);
+    }
+#else
     // we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData
     // objects until after we're finished the tasks (which have pointers to the data).
-
     SkTaskGroup group;
     group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData.count());
+#endif
     // we deliberately don't call wait() here, since the destructor will do that, this allows us
     // to continue processing gpu-data without having to wait on the cpu tasks.
 
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 24b971a..a06cca6 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -131,12 +131,14 @@
 }
 
 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const {
-    canvas->drawBitmap(fBitmap, x, y, paint);
+    SkBitmap shallowCopy(fBitmap);
+    canvas->drawBitmap(shallowCopy, x, y, paint);
 }
 
 void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
                                       const SkPaint* paint) const {
-    canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
+    SkBitmap shallowCopy(fBitmap);
+    canvas->drawBitmapRectToRect(shallowCopy, src, dst, paint);
 }
 
 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) const {
@@ -145,7 +147,8 @@
 
 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
                                   int srcX, int srcY) const {
-    return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
+    SkBitmap shallowCopy(fBitmap);
+    return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
 }
 
 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesPtr) const {