Index: bench/subset/SubsetZoomBench.cpp |
diff --git a/bench/subset/SubsetZoomBench.cpp b/bench/subset/SubsetZoomBench.cpp |
index ffd86703ec2271e40fdc27c1679fe914f4b958ac..b2233c13b6dadb082b4affcfc6bcc8f2ac4154b9 100644 |
--- a/bench/subset/SubsetZoomBench.cpp |
+++ b/bench/subset/SubsetZoomBench.cpp |
@@ -63,7 +63,6 @@ void SubsetZoomBench::onDraw(int n, SkCanvas* canvas) { |
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); |
const int centerX = info.width() / 2; |
const int centerY = info.height() / 2; |
@@ -81,12 +80,40 @@ void SubsetZoomBench::onDraw(int n, SkCanvas* canvas) { |
alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
uint32_t bpp = info.bytesPerPixel(); |
+ |
+ codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
codec->skipScanlines(subsetStartY); |
- for (int y = 0; y < subsetHeight; y++) { |
- codec->getScanlines(row.get(), 1, 0); |
- memcpy(bitmap.getAddr(0, y), row.get() + subsetStartX * bpp, |
- subsetWidth * bpp); |
+ |
+ switch (codec->getScanlineOrder()) { |
+ case SkCodec::kTopDown_SkScanlineOrder: |
+ for (int y = 0; y < subsetHeight; y++) { |
scroggo
2015/10/06 20:36:04
loop should be unchanged
msarett
2015/10/06 21:58:52
Acknowledged.
|
+ codec->getScanlines(row.get(), 1, 0); |
+ memcpy(bitmap.getAddr(0, y), row.get() + subsetStartX * bpp, |
+ subsetWidth * 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(), subsetHeight); |
+ SkBitmap stripeBm; |
+ alloc_pixels(&stripeBm, stripeInfo, colors, colorCount); |
+ |
+ codec->getScanlines(stripeBm.getPixels(), subsetHeight, |
+ stripeBm.rowBytes()); |
+ for (int y = 0; y < subsetHeight; y++) { |
+ memcpy(bitmap.getAddr(0, y), |
+ stripeBm.getAddr(subsetStartX, y), |
+ subsetWidth * 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); |
} |
+ |
w <<= 1; |
h <<= 1; |
} while (w < 2 * info.width() || h < 2 * info.height()); |