Index: src/core/SkPictureData.cpp |
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp |
index 9d497f676aba19faf14579eb2e42f05a4c679a6d..9ed98cf4ff9e0ccc1f33c9760a1feab57312cda1 100644 |
--- a/src/core/SkPictureData.cpp |
+++ b/src/core/SkPictureData.cpp |
@@ -434,44 +434,8 @@ bool SkPictureData::parseStreamTag(SkStream* stream, |
return true; // success |
} |
-namespace { |
- |
-// This generator intentionally should always fail on all attempts to get its pixels, |
-// simulating a bad or empty codec stream. |
-class EmptyImageGenerator final : public SkImageGenerator { |
-public: |
- EmptyImageGenerator(const SkImageInfo& info) : INHERITED(info) { } |
- |
-private: |
- typedef SkImageGenerator INHERITED; |
-}; |
- |
-} // anonymous namespace |
- |
static const SkImage* create_image_from_buffer(SkReadBuffer& buffer) { |
- int width = buffer.read32(); |
- int height = buffer.read32(); |
- if (width <= 0 || height <= 0) { // SkImage never has a zero dimension |
- buffer.validate(false); |
- return nullptr; |
- } |
- |
- SkAutoTUnref<SkData> encoded(buffer.readByteArrayAsData()); |
- if (encoded->size() == 0) { |
- // The image could not be encoded at serialization time - return an empty placeholder. |
- return SkImage::NewFromGenerator( |
- new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height))); |
- } |
- |
- int originX = buffer.read32(); |
- int originY = buffer.read32(); |
- if (originX < 0 || originY < 0) { |
- buffer.validate(false); |
- return nullptr; |
- } |
- |
- const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); |
- return SkImage::NewFromEncoded(encoded, &subset); |
+ return buffer.readImage(); |
} |
// Need a shallow wrapper to return const SkPicture* to match the other factories, |