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

Unified Diff: bench/subset/SubsetZoomBench.cpp

Issue 1390213002: Add subsetting to SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@fill-refactor
Patch Set: Update subset benches 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/SubsetZoomBench.cpp
diff --git a/bench/subset/SubsetZoomBench.cpp b/bench/subset/SubsetZoomBench.cpp
index 3edc17f1cb03064d253630d6207313cb2f7c3843..2ccbd191dc0320a802b110654e79c27298589378 100644
--- a/bench/subset/SubsetZoomBench.cpp
+++ b/bench/subset/SubsetZoomBench.cpp
@@ -72,58 +72,33 @@ void SubsetZoomBench::onDraw(int n, SkCanvas* canvas) {
int w = fSubsetWidth;
int h = fSubsetHeight;
do {
- SkDEBUGCODE(SkCodec::Result result = )
- codec->startScanlineDecode(info, nullptr, colors, &colorCount);
- SkASSERT(SkCodec::kSuccess == result);
-
const int subsetStartX = SkTMax(0, centerX - w / 2);
const int subsetStartY = SkTMax(0, centerY - h / 2);
const int subsetWidth = SkTMin(w, info.width() - subsetStartX);
const int subsetHeight = SkTMin(h, info.height() - subsetStartY);
+
+ // The scanline decoder will handle subsetting in the x-dimension.
+ SkIRect subset = SkIRect::MakeXYWH(subsetStartX, 0, subsetWidth,
+ codec->getInfo().height());
+ SkCodec::Options options;
+ options.fSubset = ⊂
+
+ SkDEBUGCODE(SkCodec::Result result = )
+ codec->startScanlineDecode(info, &options, colors, &colorCount);
+ SkASSERT(SkCodec::kSuccess == result);
+
// Note that if we subsetted and scaled in a single step, we could use the
// same bitmap - as is often done in actual use cases.
SkBitmap bitmap;
SkImageInfo subsetInfo = info.makeWH(subsetWidth, subsetHeight);
alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
- uint32_t bpp = info.bytesPerPixel();
-
- SkDEBUGCODE(int lines = ) codec->skipScanlines(subsetStartY);
- SkASSERT(subsetStartY == lines);
-
- switch (codec->getScanlineOrder()) {
- case SkCodec::kTopDown_SkScanlineOrder:
- for (int y = 0; y < subsetHeight; y++) {
- SkDEBUGCODE(lines = ) codec->getScanlines(row.get(), 1, 0);
- SkASSERT(1 == lines);
-
- 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);
-
- SkDEBUGCODE(lines = ) codec->getScanlines(stripeBm.getPixels(),
- subsetHeight, stripeBm.rowBytes());
- SkASSERT(subsetHeight == lines);
-
- 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);
- }
+ SkDEBUGCODE(bool success = ) codec->skipScanlines(subsetStartY);
+ SkASSERT(success);
+
+ SkDEBUGCODE(int lines = ) codec->getScanlines(bitmap.getPixels(),
+ subsetHeight, bitmap.rowBytes());
+ SkASSERT(subsetHeight == lines);
w <<= 1;
h <<= 1;

Powered by Google App Engine
This is Rietveld 408576698