SkImage method for detecting lazy decoding

BUG=skia:4224
R=reed@google.com

Review URL: https://codereview.chromium.org/1305453007
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 9c996dc..715b4f4 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -287,6 +287,10 @@
     return NewFromGenerator(SkImageGenerator::NewFromPicture(dimensions, picture, matrix, paint));
 }
 
+bool SkImage::isLazyGenerated() const {
+    return as_IB(this)->onIsLazyGenerated();
+}
+
 //////////////////////////////////////////////////////////////////////////////////////
 
 #if !SK_SUPPORT_GPU
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 38f9906..46cd3de 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -60,7 +60,7 @@
 
     virtual SkShader* onNewShader(SkShader::TileMode,
                                   SkShader::TileMode,
-                                  const SkMatrix* localMatrix) const { return NULL; };
+                                  const SkMatrix* localMatrix) const { return NULL; }
 
     // newWidth > 0, newHeight > 0, subset either NULL or a proper subset of this bounds
     virtual SkImage* onNewImage(int newWidth, int newHeight, const SkIRect* subset,
@@ -69,6 +69,8 @@
 
     virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const;
 
+    virtual bool onIsLazyGenerated() const { return false; }
+
 private:
     const SkSurfaceProps fProps;
 
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 120c397..51bc6f0 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -93,6 +93,10 @@
         SkASSERT(fBitmap.isImmutable());
     }
 
+    bool onIsLazyGenerated() const override {
+        return fBitmap.pixelRef() && fBitmap.pixelRef()->isLazyGenerated();
+    }
+
 private:
     SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, NULL) {
         fBitmap.setImmutable();
diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h
index 25fde0a..818db22 100644
--- a/src/lazy/SkCachingPixelRef.h
+++ b/src/lazy/SkCachingPixelRef.h
@@ -50,6 +50,8 @@
         return fImageGenerator->refEncodedData();
     }
 
+    bool onIsLazyGenerated() const override { return true; }
+
 private:
     SkImageGenerator* const fImageGenerator;
     bool                    fErrorInDecoding;
diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h
index e8451ee..3b38fa6 100644
--- a/src/lazy/SkDiscardablePixelRef.h
+++ b/src/lazy/SkDiscardablePixelRef.h
@@ -36,6 +36,8 @@
         return fGenerator->refEncodedData();
     }
 
+    bool onIsLazyGenerated() const override { return true; }
+
 private:
     SkImageGenerator* const fGenerator;
     SkDiscardableMemory::Factory* const fDMFactory;