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

Unified Diff: dm/DMSrcSink.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/SubsetZoomBench.cpp ('k') | include/codec/SkCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 88371a8e28fdf68e1e0e5e041588a3a475e4adc1..caa2c7f28384d0b211b16f0006ea4e0f2ebfbc56 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -400,9 +400,6 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(),
largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo.height());
}
- const size_t rowBytes = decodeInfo.minRowBytes();
- char* buffer = new char[largestSubsetDecodeInfo.height() * rowBytes];
- SkAutoTDeleteArray<char> lineDeleter(buffer);
for (int col = 0; col < divisor; col++) {
//currentSubsetWidth may be larger than subsetWidth for rightmost subsets
const int currentSubsetWidth = (col + 1 == divisor) ?
@@ -414,10 +411,13 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
subsetHeight + extraY : subsetHeight;
const int y = row * subsetHeight;
//create scanline decoder for each subset
- if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
- colorCountPtr)
- // TODO (msarett): Support this mode for all scanline orderings.
- || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
+ SkCodec::Options options;
+ SkIRect subset = SkIRect::MakeXYWH(x, 0, currentSubsetWidth, h);
+ options.fSubset = &subset;
+ // TODO (msarett): Support this mode for all scanline orderings.
+ if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &options,
+ colorPtr, colorCountPtr) ||
+ SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
if (x == 0 && y == 0) {
//first try, image may not be compatible
return Error::Nonfatal("Could not start top-down scanline decoder");
@@ -436,17 +436,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
SkBitmap subsetBm;
SkIRect bounds = SkIRect::MakeWH(currentSubsetWidth, currentSubsetHeight);
SkAssertResult(largestSubsetBm.extractSubset(&subsetBm, bounds));
- SkAutoLockPixels autlockSubsetBm(subsetBm, true);
- codec->getScanlines(buffer, currentSubsetHeight, rowBytes);
-
- const size_t bpp = decodeInfo.bytesPerPixel();
- char* bufferRow = buffer;
- for (int subsetY = 0; subsetY < currentSubsetHeight; ++subsetY) {
- memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp,
- currentSubsetWidth*bpp);
- bufferRow += rowBytes;
- }
-
+ SkAutoLockPixels autolock(subsetBm, true);
+ codec->getScanlines(subsetBm.getAddr(0, 0), currentSubsetHeight,
+ subsetBm.rowBytes());
subsetBm.notifyPixelsChanged();
canvas->drawBitmap(subsetBm, SkIntToScalar(x), SkIntToScalar(y));
}
« no previous file with comments | « bench/subset/SubsetZoomBench.cpp ('k') | include/codec/SkCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698