Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index 2e2255633538b4b4c9317fa76459c48891f5c834..33a6caad7b80d60ee2d210bc93d65d11de3499fe 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -28,6 +28,8 @@ |
#include "SkStream.h" |
#include "SkTLogic.h" |
#include "SkXMLWriter.h" |
+#include "SkScaledCodec.h" |
+#include "SkSwizzler.h" |
DEFINE_bool(multiPage, false, "For document-type backends, render the source" |
" into multiple pages"); |
@@ -340,36 +342,25 @@ Error CodecSrc::draw(SkCanvas* canvas) const { |
return Error::Nonfatal("Could not start scanline decoder"); |
} |
- SkCodec::Result result = SkCodec::kUnimplemented; |
+ void* dst = bitmap.getAddr(0, 0); |
+ size_t rowBytes = bitmap.rowBytes(); |
+ uint32_t height = decodeInfo.height(); |
switch (codec->getScanlineOrder()) { |
case SkCodec::kTopDown_SkScanlineOrder: |
case SkCodec::kBottomUp_SkScanlineOrder: |
case SkCodec::kNone_SkScanlineOrder: |
- result = codec->getScanlines(bitmap.getAddr(0, 0), |
- decodeInfo.height(), bitmap.rowBytes()); |
+ codec->getScanlines(dst, height, rowBytes); |
msarett
2015/10/01 12:44:52
getScanlines() now fills when it cannot get all of
|
break; |
case SkCodec::kOutOfOrder_SkScanlineOrder: { |
for (int y = 0; y < decodeInfo.height(); y++) { |
- int dstY = codec->nextScanline(); |
+ int dstY = codec->nextScanline(y); |
void* dstPtr = bitmap.getAddr(0, dstY); |
- result = codec->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); |
- } |
+ codec->getScanlines(dstPtr, 1, bitmap.rowBytes()); |
scroggo
2015/10/01 14:48:31
Don't we want to break out of the loop if 0 is ret
msarett
2015/10/01 18:14:13
We could do that. But then we need to iterate ove
scroggo
2015/10/01 20:48:57
Oh yeah, now I remember talking about this, but I
msarett
2015/10/01 22:34:51
Acknowledged.
|
} |
break; |
} |
} |
- switch (result) { |
- case SkCodec::kSuccess: |
- case SkCodec::kIncompleteInput: |
- break; |
- default: |
- return SkStringPrintf("%s failed with error message %d", |
- fPath.c_str(), (int) result); |
- } |
canvas->drawBitmap(bitmap, 0, 0); |
break; |
} |
@@ -430,31 +421,18 @@ Error CodecSrc::draw(SkCanvas* canvas) const { |
} |
} |
//skip to first line of subset |
- const SkCodec::Result skipResult = codec->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 (!codec->skipScanlines(y)) { |
+ return Error::Nonfatal("Image is incomplete, could not get scanlines"); |
scroggo
2015/10/01 14:48:31
Since we've returned an error, we will not be able
msarett
2015/10/01 18:14:13
Yeah the way the test is written now, we will only
|
} |
+ |
//create and set size of subsetBm |
SkBitmap subsetBm; |
SkIRect bounds = SkIRect::MakeWH(subsetWidth, subsetHeight); |
bounds.setXYWH(0, 0, currentSubsetWidth, currentSubsetHeight); |
SkAssertResult(largestSubsetBm.extractSubset(&subsetBm, bounds)); |
SkAutoLockPixels autlockSubsetBm(subsetBm, true); |
- const SkCodec::Result subsetResult = |
- codec->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); |
- } |
+ codec->getScanlines(buffer, currentSubsetHeight, rowBytes); |
scroggo
2015/10/01 14:48:31
Note that you do something different if skipScanli
msarett
2015/10/01 18:14:13
Acknowledged.
|
+ |
const size_t bpp = decodeInfo.bytesPerPixel(); |
/* |
* we copy all the lines at once becuase when calling getScanlines for |
scroggo
2015/10/01 14:48:31
This isn't due to your CL, but it seems like this
msarett
2015/10/01 18:14:13
Yeah I'm a bit confused by this comment. Removing
|
@@ -494,30 +472,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 = codec->skipScanlines(linesToSkip); |
- switch (result) { |
- case SkCodec::kSuccess: |
- case SkCodec::kIncompleteInput: |
- break; |
- default: |
- return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str()); |
+ if (!codec->skipScanlines(linesToSkip)) { |
+ return Error::Nonfatal("Image is incomplete, could not get scanlines"); |
scroggo
2015/10/01 14:48:31
Not only was the image incomplete, but it was so i
msarett
2015/10/01 18:14:13
This could be improved as well.
|
} |
// Read a stripe |
const int startY = (i + 1) * stripeHeight; |
const int linesToRead = SkTMin(stripeHeight, height - startY); |
if (linesToRead > 0) { |
- result = codec->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) codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, |
+ bitmap.rowBytes()) < linesToRead) { |
+ return Error::Nonfatal("Image is incomplete, could not get scanlines"); |
} |
} |
} |
@@ -532,26 +501,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 = codec->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) codec->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 = codec->skipScanlines(linesToSkip); |
- switch (result) { |
- case SkCodec::kSuccess: |
- case SkCodec::kIncompleteInput: |
- break; |
- default: |
- return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str()); |
+ if (!codec->skipScanlines(linesToSkip)) { |
+ return Error::Nonfatal("Image is incomplete, could not get scanlines"); |
} |
} |
} |