Chromium Code Reviews| Index: bench/subset/SubsetTranslateBench.cpp |
| diff --git a/bench/subset/SubsetTranslateBench.cpp b/bench/subset/SubsetTranslateBench.cpp |
| index 27c628edde6c1c305241fff34b5cbc8979c5153b..95bd435716c1666e4480ce10073142d334d4ba5c 100644 |
| --- a/bench/subset/SubsetTranslateBench.cpp |
| +++ b/bench/subset/SubsetTranslateBench.cpp |
| @@ -83,17 +83,8 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
| SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| - const uint32_t bpp = info.bytesPerPixel(); |
| - |
| for (int x = 0; x < info.width(); x += fSubsetWidth) { |
| for (int y = 0; y < info.height(); y += fSubsetHeight) { |
| - SkDEBUGCODE(SkCodec::Result result =) |
| - codec->startScanlineDecode(info, nullptr, get_colors(&bitmap), &colorCount); |
| - SkASSERT(SkCodec::kSuccess == result); |
| - |
| - SkDEBUGCODE(int lines =) codec->skipScanlines(y); |
| - SkASSERT(y == lines); |
| - |
| const uint32_t currSubsetWidth = |
| x + (int) fSubsetWidth > info.width() ? |
| info.width() - x : fSubsetWidth; |
| @@ -101,38 +92,22 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
| y + (int) fSubsetHeight > info.height() ? |
| info.height() - y : fSubsetHeight; |
| - switch (codec->getScanlineOrder()) { |
| - case SkCodec::kTopDown_SkScanlineOrder: |
| - for (uint32_t y = 0; y < currSubsetHeight; y++) { |
| - SkDEBUGCODE(lines =) codec->getScanlines(row.get(), 1, 0); |
| - SkASSERT(1 == lines); |
| - |
| - memcpy(bitmap.getAddr(0, y), row.get() + x * bpp, |
| - currSubsetWidth * 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(), currSubsetHeight); |
| - SkBitmap stripeBm; |
| - alloc_pixels(&stripeBm, stripeInfo, colors, colorCount); |
| - |
| - SkDEBUGCODE(lines =) codec->getScanlines(stripeBm.getPixels(), |
| - currSubsetHeight, stripeBm.rowBytes()); |
| - SkASSERT(currSubsetHeight == (uint32_t) lines); |
| - |
| - for (uint32_t subsetY = 0; subsetY < currSubsetHeight; subsetY++) { |
| - memcpy(bitmap.getAddr(0, subsetY), stripeBm.getAddr(x, subsetY), |
| - currSubsetWidth * 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); |
| - } |
| + // The scanline decoder will handle subsetting in the x-dimension. |
| + SkIRect subset = SkIRect::MakeXYWH(x, 0, currSubsetWidth, |
| + codec->getInfo().height()); |
| + SkCodec::Options options; |
| + options.fSubset = ⊂ |
| + |
| + SkDEBUGCODE(SkCodec::Result result =) |
| + codec->startScanlineDecode(info, &options, get_colors(&bitmap), &colorCount); |
| + SkASSERT(SkCodec::kSuccess == result); |
| + |
| + SkDEBUGCODE(bool success =) codec->skipScanlines(y); |
| + SkASSERT(success); |
| + |
| + SkDEBUGCODE(int lines =) codec->getScanlines(bitmap.getPixels(), |
|
scroggo
2015/10/12 16:11:20
Similar to the other one, can we declare this as a
msarett
2015/10/12 17:13:55
Yes.
|
| + currSubsetHeight, bitmap.rowBytes()); |
| + SkASSERT(currSubsetHeight == (uint32_t) lines); |
| } |
| } |
| } |