Index: bench/subset/SubsetSingleBench.cpp |
diff --git a/bench/subset/SubsetSingleBench.cpp b/bench/subset/SubsetSingleBench.cpp |
index 232c159a0baea1030e442bc2365b6702991126f4..3ec12f5e3388eb664c163925d41e13c0506782da 100644 |
--- a/bench/subset/SubsetSingleBench.cpp |
+++ b/bench/subset/SubsetSingleBench.cpp |
@@ -66,7 +66,6 @@ void SubsetSingleBench::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); |
SkBitmap bitmap; |
@@ -74,11 +73,38 @@ void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) { |
alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
codec->skipScanlines(fOffsetTop); |
- uint32_t bpp = info.bytesPerPixel(); |
- for (uint32_t y = 0; y < fSubsetHeight; y++) { |
- codec->getScanlines(row.get(), 1, 0); |
- memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, |
- fSubsetWidth * bpp); |
+ |
+ const uint32_t bpp = info.bytesPerPixel(); |
+ |
+ switch (codec->getScanlineOrder()) { |
+ case SkCodec::kTopDown_SkScanlineOrder: { |
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]); |
scroggo
2015/10/06 20:36:04
This got moved because it's not needed for kNone.
msarett
2015/10/06 21:58:52
Acknowledged.
|
+ for (uint32_t y = 0; y < fSubsetHeight; y++) { |
scroggo
2015/10/06 20:36:04
This code should be unchanged; it's just now insid
msarett
2015/10/06 21:58:52
Acknowledged.
|
+ codec->getScanlines(row.get(), 1, 0); |
+ 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); |
+ |
+ codec->getScanlines(stripeBm.getPixels(), fSubsetHeight, stripeBm.rowBytes()); |
+ 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); |
+ |
} |
} |
} else { |