Index: src/codec/SkScaledCodec.cpp |
diff --git a/src/codec/SkScaledCodec.cpp b/src/codec/SkScaledCodec.cpp |
index a9e067eaaf6f07a0ba553436f2bda13d7fa0179b..cf678db8565d0b131d359b28ab6256379e825971 100644 |
--- a/src/codec/SkScaledCodec.cpp |
+++ b/src/codec/SkScaledCodec.cpp |
@@ -44,15 +44,6 @@ SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder) |
SkScaledCodec::~SkScaledCodec() {} |
-// returns a scaled dimension based on the original dimension and the sampleSize |
-// NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder |
-static int get_scaled_dimension(int srcDimension, int sampleSize) { |
- if (sampleSize > srcDimension) { |
- return 1; |
- } |
- return srcDimension / sampleSize; |
-} |
- |
static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& nativeDims, |
const SkISize& scaledCodecDims, float desiredScale) { |
if (nativeDims == scaledCodecDims) { |
@@ -197,7 +188,25 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi |
Result result = fScanlineDecoder->start(requestedInfo, &options, ctable, ctableCount); |
if (kSuccess == result) { |
// native decode supported |
- return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBytes); |
+ switch (fScanlineDecoder->getScanlineOrder()) { |
+ case SkScanlineDecoder::kTopDown_SkScanlineOrder: |
+ case SkScanlineDecoder::kBottomUp_SkScanlineOrder: |
+ case SkScanlineDecoder::kNone_SkScanlineOrder: |
+ return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBytes); |
+ case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: { |
+ for (int y = 0; y < requestedInfo.height(); y++) { |
+ int dstY = fScanlineDecoder->getY(); |
+ void* dstPtr = SkTAddOffset<void>(dst, rowBytes * dstY); |
+ result = fScanlineDecoder->getScanlines(dstPtr, 1, rowBytes); |
+ // FIXME (msarett): Make the SkCodec base class take care of filling |
+ // uninitialized pixels so we can return immediately on kIncompleteInput. |
+ if (kSuccess != result && kIncompleteInput != result) { |
+ return result; |
+ } |
+ } |
+ return result; |
+ } |
+ } |
} |
if (kInvalidScale != result) { |
@@ -246,7 +255,7 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi |
} |
dst = SkTAddOffset<void>(dst, rowBytes); |
} |
- return kSuccess; |
+ return result; |
} |
case SkScanlineDecoder::kBottomUp_SkScanlineOrder: |
case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: { |
@@ -265,13 +274,13 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi |
} |
} |
} |
- return kSuccess; |
+ return result; |
} |
case SkScanlineDecoder::kNone_SkScanlineOrder: { |
SkAutoMalloc storage(srcHeight * rowBytes); |
uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); |
result = fScanlineDecoder->getScanlines(storagePtr, srcHeight, rowBytes); |
- if (kSuccess != result) { |
+ if (kSuccess != result && kIncompleteInput != result) { |
return result; |
} |
storagePtr += Y0 * rowBytes; |
@@ -280,7 +289,7 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi |
storagePtr += sampleY * rowBytes; |
dst = SkTAddOffset<void>(dst, rowBytes); |
} |
- return kSuccess; |
+ return result; |
} |
default: |
SkASSERT(false); |