Index: src/codec/SkBmpStandardCodec.cpp |
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp |
index 59bc917481698fb0a3caf5dab456312ac85631d7..fdbf30a169d6c5849ea07b940673f1154e94a9d1 100644 |
--- a/src/codec/SkBmpStandardCodec.cpp |
+++ b/src/codec/SkBmpStandardCodec.cpp |
@@ -37,7 +37,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, |
void* dst, size_t dstRowBytes, |
const Options& opts, |
SkPMColor* inputColorPtr, |
- int* inputColorCount) { |
+ int* inputColorCount, |
+ int* incompleteScanlines) { |
if (!this->rewindIfNeeded()) { |
return kCouldNotRewind; |
} |
@@ -58,9 +59,10 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, |
if (kSuccess != result) { |
return result; |
} |
- result = this->decodeRows(dstInfo, dst, dstRowBytes, opts); |
- if (kSuccess != result) { |
- return result; |
+ uint32_t rows = this->decodeRows(dstInfo, dst, dstRowBytes, opts); |
+ if (rows != dstInfo.height()) { |
+ *incompleteScanlines = dstInfo.height() - rows; |
+ return kIncompleteInput; |
} |
if (fInIco) { |
return this->decodeIcoMask(dstInfo, dst, dstRowBytes); |
@@ -231,7 +233,7 @@ SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, |
/* |
* Performs the bitmap decoding for standard input format |
*/ |
-SkCodec::Result SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, |
+uint32_t SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, |
void* dst, size_t dstRowBytes, |
const Options& opts) { |
// Iterate over rows of the image |
@@ -240,13 +242,7 @@ SkCodec::Result SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, |
// Read a row of the input |
if (this->stream()->read(fSrcBuffer.get(), fSrcRowBytes) != fSrcRowBytes) { |
SkCodecPrintf("Warning: incomplete input stream.\n"); |
- // Fill the destination image on failure |
- void* dstStart = this->getDstStartRow(dst, dstRowBytes, y); |
- const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
- uint32_t fillColorOrIndex = get_fill_color_or_index(dstInfo.alphaType()); |
- SkSwizzler::Fill(dstStart, dstInfo, dstRowBytes, dstInfo.height() - y, |
- fillColorOrIndex, colorPtr, opts.fZeroInitialized); |
- return kIncompleteInput; |
+ return y; |
} |
// Decode the row in destination format |
@@ -257,7 +253,7 @@ SkCodec::Result SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, |
} |
// Finished decoding the entire image |
- return kSuccess; |
+ return height; |
} |
// TODO (msarett): This function will need to be modified in order to perform row by row decodes |
@@ -298,3 +294,11 @@ SkCodec::Result SkBmpStandardCodec::decodeIcoMask(const SkImageInfo& dstInfo, |
} |
return kSuccess; |
} |
+ |
+uint32_t SkBmpStandardCodec::onGetFillValue(const SkImageInfo& dstInfo) const { |
+ const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
+ if (colorPtr) { |
+ return get_color_table_fill_value(dstInfo.colorType(), colorPtr, 0); |
+ } |
+ return INHERITED::onGetFillValue(dstInfo); |
+} |