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

Unified Diff: bench/subset/SubsetTranslateBench.cpp

Issue 1430493005: Delete dead subset benches from nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Build fix: delete unused fUseCodec Created 5 years, 1 month 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
« no previous file with comments | « bench/subset/SubsetTranslateBench.h ('k') | bench/subset/SubsetZoomBench.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/subset/SubsetTranslateBench.cpp
diff --git a/bench/subset/SubsetTranslateBench.cpp b/bench/subset/SubsetTranslateBench.cpp
index d8da6db566686376688a435088c07dc93eba17e3..bcf1227454057b48a596d55a36d7dca388e8cd2d 100644
--- a/bench/subset/SubsetTranslateBench.cpp
+++ b/bench/subset/SubsetTranslateBench.cpp
@@ -24,12 +24,10 @@
SubsetTranslateBench::SubsetTranslateBench(const SkString& path,
SkColorType colorType,
uint32_t subsetWidth,
- uint32_t subsetHeight,
- bool useCodec)
+ uint32_t subsetHeight)
: fColorType(colorType)
, fSubsetWidth(subsetWidth)
, fSubsetHeight(subsetHeight)
- , fUseCodec(useCodec)
{
// Parse the filename
SkString baseName = SkOSPath::Basename(path.c_str());
@@ -37,7 +35,7 @@ SubsetTranslateBench::SubsetTranslateBench(const SkString& path,
// Choose an informative color name
const char* colorName = color_type_to_str(fColorType);
- fName.printf("%sSubsetTranslate_%dx%d_%s_%s", fUseCodec ? "Codec" : "Image", fSubsetWidth,
+ fName.printf("CodecSubsetTranslate_%dx%d_%s_%s", fSubsetWidth,
fSubsetHeight, baseName.c_str(), colorName);
// Perform the decode setup
@@ -68,76 +66,42 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) {
// used, it will be initialized by the codec.
int colorCount = 256;
SkPMColor colors[256];
- if (fUseCodec) {
- for (int count = 0; count < n; count++) {
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate()));
- SkASSERT(SkCodec::kOutOfOrder_SkScanlineOrder != codec->getScanlineOrder());
- const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
-
- SkBitmap bitmap;
- // Note that we use the same bitmap for all of the subsets.
- // It might be larger than necessary for the end subsets.
- SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
- alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
-
- for (int x = 0; x < info.width(); x += fSubsetWidth) {
- for (int y = 0; y < info.height(); y += fSubsetHeight) {
- 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;
-
- // The scanline decoder will handle subsetting in the x-dimension.
- SkIRect subset = SkIRect::MakeXYWH(x, 0, currSubsetWidth,
- codec->getInfo().height());
- SkCodec::Options options;
- options.fSubset = &subset;
-
- SkDEBUGCODE(SkCodec::Result result =)
- codec->startScanlineDecode(info, &options, get_colors(&bitmap), &colorCount);
- SkASSERT(SkCodec::kSuccess == result);
-
- SkDEBUGCODE(bool success =) codec->skipScanlines(y);
- SkASSERT(success);
-
- SkDEBUGCODE(uint32_t lines =) codec->getScanlines(bitmap.getPixels(),
- currSubsetHeight, bitmap.rowBytes());
- SkASSERT(currSubsetHeight == lines);
- }
- }
- }
- } else {
- // We create a color table here to satisfy allocPixels() when the output
- // type is kIndex8. It's okay that this is uninitialized since we never
- // use it.
- SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, 0));
- for (int count = 0; count < n; count++) {
- int width, height;
- SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
- 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.
- // If we do not include this step, decodeSubset() would allocate space
- // for the pixels automatically, but this would not allow us to reuse the
- // same bitmap as the other subsets. We want to reuse the same bitmap
- // because it gives a more fair comparison with SkCodec and is a common
- // use case of BitmapRegionDecoder.
- bitmap.allocPixels(SkImageInfo::Make(fSubsetWidth, fSubsetHeight,
- fColorType, kOpaque_SkAlphaType), nullptr, colorTable);
-
- for (int x = 0; x < width; x += fSubsetWidth) {
- for (int y = 0; y < height; y += fSubsetHeight) {
- const uint32_t currSubsetWidth = x + (int) fSubsetWidth > width ?
- width - x : fSubsetWidth;
- const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ?
- height - y : fSubsetHeight;
- SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth,
- currSubsetHeight);
- SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorType));
- }
+ for (int count = 0; count < n; count++) {
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate()));
+ SkASSERT(SkCodec::kOutOfOrder_SkScanlineOrder != codec->getScanlineOrder());
+ const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
+
+ SkBitmap bitmap;
+ // Note that we use the same bitmap for all of the subsets.
+ // It might be larger than necessary for the end subsets.
+ SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
+ alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
+
+ for (int x = 0; x < info.width(); x += fSubsetWidth) {
+ for (int y = 0; y < info.height(); y += fSubsetHeight) {
+ 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;
+
+ // The scanline decoder will handle subsetting in the x-dimension.
+ SkIRect subset = SkIRect::MakeXYWH(x, 0, currSubsetWidth,
+ codec->getInfo().height());
+ SkCodec::Options options;
+ options.fSubset = &subset;
+
+ SkDEBUGCODE(SkCodec::Result result =)
+ codec->startScanlineDecode(info, &options, get_colors(&bitmap), &colorCount);
+ SkASSERT(SkCodec::kSuccess == result);
+
+ SkDEBUGCODE(bool success =) codec->skipScanlines(y);
+ SkASSERT(success);
+
+ SkDEBUGCODE(uint32_t lines =) codec->getScanlines(bitmap.getPixels(),
+ currSubsetHeight, bitmap.rowBytes());
+ SkASSERT(currSubsetHeight == lines);
}
}
}
« no previous file with comments | « bench/subset/SubsetTranslateBench.h ('k') | bench/subset/SubsetZoomBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698