Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index 88371a8e28fdf68e1e0e5e041588a3a475e4adc1..caa2c7f28384d0b211b16f0006ea4e0f2ebfbc56 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -400,9 +400,6 @@ Error CodecSrc::draw(SkCanvas* canvas) const { |
return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(), |
largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo.height()); |
} |
- const size_t rowBytes = decodeInfo.minRowBytes(); |
- char* buffer = new char[largestSubsetDecodeInfo.height() * rowBytes]; |
- SkAutoTDeleteArray<char> lineDeleter(buffer); |
for (int col = 0; col < divisor; col++) { |
//currentSubsetWidth may be larger than subsetWidth for rightmost subsets |
const int currentSubsetWidth = (col + 1 == divisor) ? |
@@ -414,10 +411,13 @@ Error CodecSrc::draw(SkCanvas* canvas) const { |
subsetHeight + extraY : subsetHeight; |
const int y = row * subsetHeight; |
//create scanline decoder for each subset |
- if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr, |
- colorCountPtr) |
- // TODO (msarett): Support this mode for all scanline orderings. |
- || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) { |
+ SkCodec::Options options; |
+ SkIRect subset = SkIRect::MakeXYWH(x, 0, currentSubsetWidth, h); |
+ options.fSubset = ⊂ |
+ // TODO (msarett): Support this mode for all scanline orderings. |
+ if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &options, |
+ colorPtr, colorCountPtr) || |
+ SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) { |
if (x == 0 && y == 0) { |
//first try, image may not be compatible |
return Error::Nonfatal("Could not start top-down scanline decoder"); |
@@ -436,17 +436,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const { |
SkBitmap subsetBm; |
SkIRect bounds = SkIRect::MakeWH(currentSubsetWidth, currentSubsetHeight); |
SkAssertResult(largestSubsetBm.extractSubset(&subsetBm, bounds)); |
- SkAutoLockPixels autlockSubsetBm(subsetBm, true); |
- codec->getScanlines(buffer, currentSubsetHeight, rowBytes); |
- |
- const size_t bpp = decodeInfo.bytesPerPixel(); |
- char* bufferRow = buffer; |
- for (int subsetY = 0; subsetY < currentSubsetHeight; ++subsetY) { |
- memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp, |
- currentSubsetWidth*bpp); |
- bufferRow += rowBytes; |
- } |
- |
+ SkAutoLockPixels autolock(subsetBm, true); |
+ codec->getScanlines(subsetBm.getAddr(0, 0), currentSubsetHeight, |
+ subsetBm.rowBytes()); |
subsetBm.notifyPixelsChanged(); |
canvas->drawBitmap(subsetBm, SkIntToScalar(x), SkIntToScalar(y)); |
} |