Index: bench/subset/SubsetTranslateBench.cpp |
diff --git a/bench/subset/SubsetTranslateBench.cpp b/bench/subset/SubsetTranslateBench.cpp |
index 8f29ba8fa011f25ef74eee4eb09d2ebb09fcb73a..66fac56c5f39a8e40db7de4213303b096688cc50 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,55 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
scroggo
2015/10/08 18:29:08
The bots caught me - "colorCount" is now unitializ
|
+ 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->skipScanlines(y); |
+ SkDEBUGCODE(SkCodec::Result result =) |
+ codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
+ SkASSERT(SkCodec::kSuccess == result); |
+ |
+ SkDEBUGCODE(result =) codec->skipScanlines(y); |
+ SkASSERT(SkCodec::kSuccess == result); |
+ |
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++) { |
+ SkDEBUGCODE(result =) codec->getScanlines(row.get(), 1, 0); |
+ SkASSERT(SkCodec::kSuccess == result); |
+ |
+ 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(result =) codec->getScanlines(stripeBm.getPixels(), |
+ currSubsetHeight, stripeBm.rowBytes()); |
+ SkASSERT(SkCodec::kSuccess == result); |
+ |
+ 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); |
} |
} |
} |
@@ -97,7 +134,7 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
for (int count = 0; count < n; count++) { |
int width, height; |
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream)); |
- decoder->buildTileIndex(fStream->duplicate(), &width, &height); |
+ SkAssertResult(decoder->buildTileIndex(fStream->duplicate(), &width, &height)); |
SkBitmap bitmap; |
// Note that we use the same bitmap for all of the subsets. |
// It might be larger than necessary for the end subsets. |
@@ -117,7 +154,7 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) { |
height - y : fSubsetHeight; |
SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
currSubsetHeight); |
- decoder->decodeSubset(&bitmap, rect, fColorType); |
+ SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorType)); |
} |
} |
} |