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

Unified Diff: src/codec/SkScaledCodec.cpp

Issue 1305123002: Scanline decoding for gifs (Closed) Base URL: https://skia.googlesource.com/skia.git@real-bmp-scan
Patch Set: Compile fix Created 5 years, 3 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 | « src/codec/SkCodec_libgif.cpp ('k') | src/codec/SkScanlineDecoder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkScaledCodec.cpp
diff --git a/src/codec/SkScaledCodec.cpp b/src/codec/SkScaledCodec.cpp
index a9e067eaaf6f07a0ba553436f2bda13d7fa0179b..cf678db8565d0b131d359b28ab6256379e825971 100644
--- a/src/codec/SkScaledCodec.cpp
+++ b/src/codec/SkScaledCodec.cpp
@@ -44,15 +44,6 @@ SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder)
SkScaledCodec::~SkScaledCodec() {}
-// returns a scaled dimension based on the original dimension and the sampleSize
-// NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
-static int get_scaled_dimension(int srcDimension, int sampleSize) {
- if (sampleSize > srcDimension) {
- return 1;
- }
- return srcDimension / sampleSize;
-}
-
static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& nativeDims,
const SkISize& scaledCodecDims, float desiredScale) {
if (nativeDims == scaledCodecDims) {
@@ -197,7 +188,25 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi
Result result = fScanlineDecoder->start(requestedInfo, &options, ctable, ctableCount);
if (kSuccess == result) {
// native decode supported
- return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBytes);
+ switch (fScanlineDecoder->getScanlineOrder()) {
+ case SkScanlineDecoder::kTopDown_SkScanlineOrder:
+ case SkScanlineDecoder::kBottomUp_SkScanlineOrder:
+ case SkScanlineDecoder::kNone_SkScanlineOrder:
+ return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBytes);
+ case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: {
+ for (int y = 0; y < requestedInfo.height(); y++) {
+ int dstY = fScanlineDecoder->getY();
+ void* dstPtr = SkTAddOffset<void>(dst, rowBytes * dstY);
+ result = fScanlineDecoder->getScanlines(dstPtr, 1, rowBytes);
+ // FIXME (msarett): Make the SkCodec base class take care of filling
+ // uninitialized pixels so we can return immediately on kIncompleteInput.
+ if (kSuccess != result && kIncompleteInput != result) {
+ return result;
+ }
+ }
+ return result;
+ }
+ }
}
if (kInvalidScale != result) {
@@ -246,7 +255,7 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi
}
dst = SkTAddOffset<void>(dst, rowBytes);
}
- return kSuccess;
+ return result;
}
case SkScanlineDecoder::kBottomUp_SkScanlineOrder:
case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: {
@@ -265,13 +274,13 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi
}
}
}
- return kSuccess;
+ return result;
}
case SkScanlineDecoder::kNone_SkScanlineOrder: {
SkAutoMalloc storage(srcHeight * rowBytes);
uint8_t* storagePtr = static_cast<uint8_t*>(storage.get());
result = fScanlineDecoder->getScanlines(storagePtr, srcHeight, rowBytes);
- if (kSuccess != result) {
+ if (kSuccess != result && kIncompleteInput != result) {
return result;
}
storagePtr += Y0 * rowBytes;
@@ -280,7 +289,7 @@ SkCodec::Result SkScaledCodec::onGetPixels(const SkImageInfo& requestedInfo, voi
storagePtr += sampleY * rowBytes;
dst = SkTAddOffset<void>(dst, rowBytes);
}
- return kSuccess;
+ return result;
}
default:
SkASSERT(false);
« no previous file with comments | « src/codec/SkCodec_libgif.cpp ('k') | src/codec/SkScanlineDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698