| Index: dm/DMSrcSink.cpp
|
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
|
| index e27628ad043aeedc9676dfd1a00187c843ad2fa8..efffc8f06bef6306e702857e39c4848f37fc3cae 100644
|
| --- a/dm/DMSrcSink.cpp
|
| +++ b/dm/DMSrcSink.cpp
|
| @@ -372,54 +372,39 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| canvas->drawBitmap(bitmap, 0, 0);
|
| break;
|
| }
|
| - case kStripe_Mode: {
|
| + case kTile_Mode: {
|
| + const int width = decodeInfo.width();
|
| const int height = decodeInfo.height();
|
| // This value is chosen arbitrarily. We exercise more cases by choosing a value that
|
| // does not align with image blocks.
|
| - const int stripeHeight = 37;
|
| - const int numStripes = (height + stripeHeight - 1) / stripeHeight;
|
| + const int tileSize = 37;
|
| + const int tileWidth = (width + tileSize - 1) / tileSize;
|
| + const int tileHeight = (height + tileSize - 1) / tileSize;
|
|
|
| - // Decode odd stripes
|
| - if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
|
| - colorCountPtr)
|
| - || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
|
| - // This mode was designed to test the new skip scanlines API in libjpeg-turbo.
|
| - // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting
|
| - // 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);
|
| - codec->skipScanlines(linesToSkip);
|
| + SkCodec::Options opts;
|
| + SkIRect subset;
|
| + for (int tileX = 0; tileX < tileWidth; tileX++) {
|
| + const int startX = tileX * tileSize;
|
| + subset = SkIRect::MakeXYWH(startX, 0, SkTMin(tileSize, width - startX), height);
|
| + opts.fSubset = ⊂
|
| + for (int tileY = 0; tileY < tileHeight; tileY++) {
|
| + if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opts,
|
| + colorPtr, colorCountPtr) ||
|
| + SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
|
| + if (0 == tileY && 0 == tileX) {
|
| + return Error::Nonfatal("Could not start top-down scanline decoder");
|
| + }
|
| + return "Could not restart scanline decoder.";
|
| + }
|
|
|
| - // Read a stripe
|
| - const int startY = (i + 1) * stripeHeight;
|
| - const int linesToRead = SkTMin(stripeHeight, height - startY);
|
| - if (linesToRead > 0) {
|
| - codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
|
| + const int startY = tileY * tileSize;
|
| + codec->skipScanlines(startY);
|
| + const int linesToGet = SkTMin(tileSize, height - startY);
|
| + codec->getScanlines(bitmap.getAddr(startX, startY), linesToGet,
|
| + bitmap.rowBytes());
|
| }
|
| }
|
|
|
| - // Decode even stripes
|
| - const SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo, nullptr,
|
| - colorPtr, colorCountPtr);
|
| - if (SkCodec::kSuccess != startResult) {
|
| - return "Failed to restart scanline decoder with same parameters.";
|
| - }
|
| - for (int i = 0; i < numStripes; i += 2) {
|
| - // Read a stripe
|
| - const int startY = i * stripeHeight;
|
| - const int linesToRead = SkTMin(stripeHeight, height - startY);
|
| - codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
|
| -
|
| - // Skip a stripe
|
| - const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
|
| - if (linesToSkip > 0) {
|
| - codec->skipScanlines(linesToSkip);
|
| - }
|
| - }
|
| canvas->drawBitmap(bitmap, 0, 0);
|
| break;
|
| }
|
|
|