Chromium Code Reviews| Index: bench/subset/SubsetTranslateBench.cpp |
| diff --git a/bench/subset/SubsetTranslateBench.cpp b/bench/subset/SubsetTranslateBench.cpp |
| index 8f29ba8fa011f25ef74eee4eb09d2ebb09fcb73a..057916feba37b182570ecf8e647cb253fa623712 100644 |
| --- a/bench/subset/SubsetTranslateBench.cpp |
| +++ b/bench/subset/SubsetTranslateBench.cpp |
| @@ -62,8 +62,10 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
| for (int count = 0; count < n; count++) { |
| SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate())); |
| const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
| - SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]); |
| - codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
| + SkAutoTDeleteArray<uint8_t> row(nullptr); |
| + if (codec->getScanlineOrder() == SkCodec::kTopDown_SkScanlineOrder) { |
| + row.reset(new uint8_t[info.minRowBytes()]); |
| + } |
| SkBitmap bitmap; |
| // Note that we use the same bitmap for all of the subsets. |
| @@ -71,20 +73,47 @@ 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) { |
| + codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
|
scroggo
2015/10/06 20:36:04
Here's the bug (unless I'm missing something?): wi
msarett
2015/10/06 21:58:52
Ugh this is an embarrassing bug.
Theoretically, w
scroggo
2015/10/07 19:50:58
Done.
|
| codec->skipScanlines(y); |
| + |
| const uint32_t currSubsetWidth = |
| x + (int) fSubsetWidth > info.width() ? |
| info.width() - x : fSubsetWidth; |
| const uint32_t currSubsetHeight = |
| y + (int) fSubsetHeight > info.height() ? |
| info.height() - y : fSubsetHeight; |
| - const uint32_t bpp = info.bytesPerPixel(); |
| - for (uint32_t y = 0; y < currSubsetHeight; y++) { |
| - codec->getScanlines(row.get(), 1, 0); |
| - memcpy(bitmap.getAddr(0, y), row.get() + x * bpp, |
| - currSubsetWidth * bpp); |
| + |
| + switch (codec->getScanlineOrder()) { |
| + case SkCodec::kTopDown_SkScanlineOrder: |
| + for (uint32_t y = 0; y < currSubsetHeight; y++) { |
|
scroggo
2015/10/06 20:36:04
Again, I think this loop is unchanged.
msarett
2015/10/06 21:58:52
Acknowledged.
|
| + codec->getScanlines(row.get(), 1, 0); |
| + 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); |
| + |
| + codec->getScanlines(stripeBm.getPixels(), currSubsetHeight, |
| + stripeBm.rowBytes()); |
| + 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); |
| } |
| } |
| } |