Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9093)

Unified Diff: bench/subset/SubsetSingleBench.cpp

Issue 1387233002: Update Subset benches to support interlacing and fix bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@limitScaled
Patch Set: Initialize colorCount before reading from it. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: bench/subset/SubsetSingleBench.cpp
diff --git a/bench/subset/SubsetSingleBench.cpp b/bench/subset/SubsetSingleBench.cpp
index 232c159a0baea1030e442bc2365b6702991126f4..735effa100bad08d9fe453aa2ed47eb06eaac343 100644
--- a/bench/subset/SubsetSingleBench.cpp
+++ b/bench/subset/SubsetSingleBench.cpp
@@ -66,30 +66,65 @@ 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()]);
+
+ SkDEBUGCODE(SkCodec::Result result =)
codec->startScanlineDecode(info, nullptr, colors, &colorCount);
+ SkASSERT(result == SkCodec::kSuccess);
SkBitmap bitmap;
SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
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);
+ SkDEBUGCODE(result = ) codec->skipScanlines(fOffsetTop);
+ SkASSERT(result == SkCodec::kSuccess);
+
+ const uint32_t bpp = info.bytesPerPixel();
+
+ switch (codec->getScanlineOrder()) {
+ case SkCodec::kTopDown_SkScanlineOrder: {
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
+ for (uint32_t y = 0; y < fSubsetHeight; y++) {
+ SkDEBUGCODE(result = ) codec->getScanlines(row.get(), 1, 0);
+ SkASSERT(result == SkCodec::kSuccess);
+
+ 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);
+
+ SkDEBUGCODE(result = ) codec->getScanlines(stripeBm.getPixels(), fSubsetHeight,
+ stripeBm.rowBytes());
+ SkASSERT(result == SkCodec::kSuccess);
+
+ 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 {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
int width, height;
- decoder->buildTileIndex(fStream->duplicate(), &width, &height);
+ SkAssertResult(decoder->buildTileIndex(fStream->duplicate(), &width, &height));
SkBitmap bitmap;
SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWidth,
fSubsetHeight);
- decoder->decodeSubset(&bitmap, rect, fColorType);
+ SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorType));
}
}
}

Powered by Google App Engine
This is Rietveld 408576698