| Index: dm/DMSrcSink.cpp
|
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
|
| index 981e47d6c0bf84690c25c8a49392fa2e3abadc18..5a8a071ece41cf8ff67a498801bf1d8bdfa24b04 100644
|
| --- a/dm/DMSrcSink.cpp
|
| +++ b/dm/DMSrcSink.cpp
|
| @@ -352,35 +352,33 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| return Error::Nonfatal("Could not start scanline decoder");
|
| }
|
|
|
| - SkCodec::Result result = SkCodec::kUnimplemented;
|
| + uint32_t linesDecoded = 0;
|
| switch (scanlineDecoder->getScanlineOrder()) {
|
| case SkScanlineDecoder::kTopDown_SkScanlineOrder:
|
| case SkScanlineDecoder::kBottomUp_SkScanlineOrder:
|
| case SkScanlineDecoder::kNone_SkScanlineOrder:
|
| - result = scanlineDecoder->getScanlines(bitmap.getAddr(0, 0),
|
| + linesDecoded = scanlineDecoder->getScanlines(bitmap.getAddr(0, 0),
|
| decodeInfo.height(), bitmap.rowBytes());
|
| break;
|
| case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: {
|
| for (int y = 0; y < decodeInfo.height(); y++) {
|
| int dstY = scanlineDecoder->getY();
|
| void* dstPtr = bitmap.getAddr(0, dstY);
|
| - result = scanlineDecoder->getScanlines(dstPtr, 1, bitmap.rowBytes());
|
| - if (SkCodec::kSuccess != result && SkCodec::kIncompleteInput != result) {
|
| - return SkStringPrintf("%s failed with error message %d",
|
| - fPath.c_str(), (int) result);
|
| + uint32_t line = scanlineDecoder->getScanlines(dstPtr, 1, bitmap.rowBytes());
|
| + if (1 != line) {
|
| + break;
|
| }
|
| + linesDecoded += line;
|
| }
|
| break;
|
| }
|
| }
|
| -
|
| - switch (result) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("%s failed with error message %d",
|
| - fPath.c_str(), (int) result);
|
| + if ((int) linesDecoded < decodeInfo.height()) {
|
| + // We have not implemented a function in SkScanlineDecoder to fill remaining
|
| + // scanlines on an incomplete decode. As long as we are the only client that
|
| + // uses SkScanlineDecoder, I think this is ok. If this changes, maybe we want
|
| + // to consider providing an API for this?
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
| canvas->drawBitmap(bitmap, 0, 0);
|
| break;
|
| @@ -443,14 +441,8 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| }
|
| }
|
| //skip to first line of subset
|
| - const SkCodec::Result skipResult = decoder->skipScanlines(y);
|
| - switch (skipResult) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("%s failed after attempting to skip %d scanlines"
|
| - "with error message %d", fPath.c_str(), y, (int) skipResult);
|
| + if (!decoder->skipScanlines(y)) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
| //create and set size of subsetBm
|
| SkBitmap subsetBm;
|
| @@ -458,15 +450,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| bounds.setXYWH(0, 0, currentSubsetWidth, currentSubsetHeight);
|
| SkAssertResult(largestSubsetBm.extractSubset(&subsetBm, bounds));
|
| SkAutoLockPixels autlockSubsetBm(subsetBm, true);
|
| - const SkCodec::Result subsetResult =
|
| - decoder->getScanlines(buffer, currentSubsetHeight, rowBytes);
|
| - switch (subsetResult) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("%s failed with error message %d",
|
| - fPath.c_str(), (int) subsetResult);
|
| + if ((int) decoder->getScanlines(buffer, currentSubsetHeight, rowBytes) <
|
| + currentSubsetHeight) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
| const size_t bpp = decodeInfo.bytesPerPixel();
|
| /*
|
| @@ -508,30 +494,21 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| // to run this test for image types that do not have this scanline ordering.
|
| return Error::Nonfatal("Could not start top-down scanline decoder");
|
| }
|
| +
|
| for (int i = 0; i < numStripes; i += 2) {
|
| // Skip a stripe
|
| const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
|
| - SkCodec::Result result = decoder->skipScanlines(linesToSkip);
|
| - switch (result) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str());
|
| + if (!decoder->skipScanlines(linesToSkip)) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
|
|
| // Read a stripe
|
| const int startY = (i + 1) * stripeHeight;
|
| const int linesToRead = SkTMin(stripeHeight, height - startY);
|
| if (linesToRead > 0) {
|
| - result = decoder->getScanlines(bitmap.getAddr(0, startY),
|
| - linesToRead, bitmap.rowBytes());
|
| - switch (result) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("Cannot get scanlines for %s.", fPath.c_str());
|
| + if ((int) decoder->getScanlines(bitmap.getAddr(0, startY), linesToRead,
|
| + bitmap.rowBytes()) < linesToRead) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
| }
|
| }
|
| @@ -546,26 +523,16 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| // Read a stripe
|
| const int startY = i * stripeHeight;
|
| const int linesToRead = SkTMin(stripeHeight, height - startY);
|
| - SkCodec::Result result = decoder->getScanlines(bitmap.getAddr(0, startY),
|
| - linesToRead, bitmap.rowBytes());
|
| - switch (result) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("Cannot get scanlines for %s.", fPath.c_str());
|
| + if ((int) decoder->getScanlines(bitmap.getAddr(0, startY), linesToRead,
|
| + bitmap.rowBytes()) < linesToRead) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
|
|
| // Skip a stripe
|
| const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
|
| if (linesToSkip > 0) {
|
| - result = decoder->skipScanlines(linesToSkip);
|
| - switch (result) {
|
| - case SkCodec::kSuccess:
|
| - case SkCodec::kIncompleteInput:
|
| - break;
|
| - default:
|
| - return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str());
|
| + if (!decoder->skipScanlines(linesToSkip)) {
|
| + return Error::Nonfatal("Image is incomplete, could not get scanlines");
|
| }
|
| }
|
| }
|
|
|