Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: src/codec/SkCodec.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index d12de21f515e45c861f6793cdd0b73b4bcc8055f..1e347f7186917cf8a9457e01b3d39f17ae41910a 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -79,6 +79,7 @@ SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
: fInfo(info)
, fStream(stream)
, fNeedsRewind(false)
+ , fIncompleteScanlines(0)
{}
SkCodec::~SkCodec() {}
@@ -142,6 +143,17 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
}
+
+ // A return value of kIncompleteInput generally indicates a truncated image stream.
scroggo 2015/09/22 18:02:48 generally? Is there an exception?
msarett 2015/09/23 13:22:40 Nope. Removing that word.
+ // In this case, we will fill the provided memory with a default value.
+ if (kIncompleteInput == result && 0 != fIncompleteScanlines) {
+ void* fillDst = this->getFillDst(pixels, rowBytes, info.height() - fIncompleteScanlines);
+ const SkImageInfo fillInfo = info.makeWH(info.width(), fIncompleteScanlines);
+ const uint32_t fillValue = this->getFillValue(fillInfo);
+ SkSwizzler::Fill(fillDst, fillInfo, rowBytes, fillValue, options->fZeroInitialized);
+ fIncompleteScanlines = 0;
+ }
+
return result;
}

Powered by Google App Engine
This is Rietveld 408576698