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

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: Response to comments 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
« no previous file with comments | « bench/subset/SubsetTranslateBench.cpp ('k') | dm/DMSrcSink.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/subset/SubsetZoomBench.cpp
diff --git a/bench/subset/SubsetZoomBench.cpp b/bench/subset/SubsetZoomBench.cpp
index 3edc17f1cb03064d253630d6207313cb2f7c3843..f17a97c26b49d4bbaaceae5369d273520e1fbdef 100644
--- a/bench/subset/SubsetZoomBench.cpp
+++ b/bench/subset/SubsetZoomBench.cpp
@@ -61,69 +61,41 @@ void SubsetZoomBench::onDraw(int n, SkCanvas* canvas) {
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);
- SkAutoTDeleteArray<uint8_t> row(nullptr);
- if (codec->getScanlineOrder() == SkCodec::kTopDown_SkScanlineOrder) {
- row.reset(new uint8_t[info.minRowBytes()]);
- }
const int centerX = info.width() / 2;
const int centerY = info.height() / 2;
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 = &subset;
+
+ 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;
« no previous file with comments | « bench/subset/SubsetTranslateBench.cpp ('k') | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698