Chromium Code Reviews| Index: bench/subset/SubsetSingleBench.cpp |
| diff --git a/bench/subset/SubsetSingleBench.cpp b/bench/subset/SubsetSingleBench.cpp |
| index b4e92e4e2257882a6d47178414ead89ba964b269..447e5b1db3c8445c063761140892438fd69ba915 100644 |
| --- a/bench/subset/SubsetSingleBench.cpp |
| +++ b/bench/subset/SubsetSingleBench.cpp |
| @@ -67,54 +67,26 @@ void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) { |
| SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate())); |
| const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
| + // The scanline decoder will handle subsetting in the x-dimension. |
| + SkIRect subset = SkIRect::MakeXYWH(fOffsetLeft, 0, fSubsetWidth, |
| + codec->getInfo().height()); |
| + SkCodec::Options options; |
| + options.fSubset = ⊂ |
| + |
| SkDEBUGCODE(SkCodec::Result result =) |
| - codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
| + codec->startScanlineDecode(info, &options, colors, &colorCount); |
| SkASSERT(result == SkCodec::kSuccess); |
| SkBitmap bitmap; |
| SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| - SkDEBUGCODE(int lines = ) codec->skipScanlines(fOffsetTop); |
| - SkASSERT((uint32_t) lines == fOffsetTop); |
| - |
| - const uint32_t bpp = info.bytesPerPixel(); |
| - |
| - switch (codec->getScanlineOrder()) { |
| - case SkCodec::kTopDown_SkScanlineOrder: { |
| - SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]); |
| - for (uint32_t y = 0; y < fSubsetHeight; y++) { |
| - SkDEBUGCODE(lines = ) codec->getScanlines(row.get(), 1, 0); |
| - SkASSERT(lines == 1); |
| - |
| - memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, |
| - fSubsetWidth * bpp); |
| - } |
| - break; |
| - } |
| - case SkCodec::kNone_SkScanlineOrder: { |
| - // decode all scanlines that intersect the subset, and copy the subset |
| - // into the output. |
| - SkImageInfo stripeInfo = info.makeWH(info.width(), fSubsetHeight); |
| - SkBitmap stripeBm; |
| - alloc_pixels(&stripeBm, stripeInfo, colors, colorCount); |
| - |
| - SkDEBUGCODE(lines = ) codec->getScanlines(stripeBm.getPixels(), fSubsetHeight, |
| - stripeBm.rowBytes()); |
| - SkASSERT((uint32_t) lines == fSubsetHeight); |
| - |
| - for (uint32_t y = 0; y < fSubsetHeight; y++) { |
| - memcpy(bitmap.getAddr(0, y), stripeBm.getAddr(fOffsetLeft, y), |
| - fSubsetWidth * bpp); |
| - } |
| - break; |
| - } |
| - default: |
| - // We currently are only testing kTopDown and kNone, which are the only |
| - // two used by the subsets we care about. skbug.com/4428 |
| - SkASSERT(false); |
| + SkDEBUGCODE(bool success = ) codec->skipScanlines(fOffsetTop); |
| + SkASSERT(success); |
| - } |
| + SkDEBUGCODE(int lines = ) codec->getScanlines(bitmap.getPixels(), fSubsetHeight, |
|
scroggo
2015/10/12 16:11:20
What would happen if you just declared lines as a
msarett
2015/10/12 17:13:55
Yes that will.
|
| + bitmap.rowBytes()); |
| + SkASSERT((uint32_t) lines == fSubsetHeight); |
|
scroggo
2015/10/12 16:11:20
Oh, this is interesting. If I understand correctly
msarett
2015/10/12 17:13:55
It doesn't work for kOutOfOrder. I'll add a check
|
| } |
| } else { |
| for (int count = 0; count < n; count++) { |