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

Unified Diff: src/codec/SkBmpStandardCodec.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use aligned memory in swizzler test Created 5 years, 2 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
« no previous file with comments | « src/codec/SkBmpStandardCodec.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkBmpStandardCodec.cpp
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 540b9f3b2ba28eb404a845f1cd9f57fb82905530..938fe8c7882b5565dc3951ea39c1471315d2abae 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -36,7 +36,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
void* dst, size_t dstRowBytes,
const Options& opts,
SkPMColor* inputColorPtr,
- int* inputColorCount) {
+ int* inputColorCount,
+ int* rowsDecoded) {
if (opts.fSubset) {
// Subsets are not supported.
return kUnimplemented;
@@ -54,9 +55,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()) {
+ *rowsDecoded = rows;
+ return kIncompleteInput;
}
if (fInIco) {
return this->decodeIcoMask(dstInfo, dst, dstRowBytes);
@@ -227,7 +229,7 @@ SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo,
/*
* Performs the bitmap decoding for standard input format
*/
-SkCodec::Result SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo,
+int SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo,
void* dst, size_t dstRowBytes,
const Options& opts) {
// Iterate over rows of the image
@@ -236,13 +238,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
@@ -253,7 +249,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
@@ -294,3 +290,11 @@ SkCodec::Result SkBmpStandardCodec::decodeIcoMask(const SkImageInfo& dstInfo,
}
return kSuccess;
}
+
+uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType, SkAlphaType alphaType) const {
+ const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
+ if (colorPtr) {
+ return get_color_table_fill_value(colorType, colorPtr, 0);
+ }
+ return INHERITED::onGetFillValue(colorType, alphaType);
+}
« no previous file with comments | « src/codec/SkBmpStandardCodec.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698