Chromium Code Reviews| Index: src/codec/SkCodec_libpng.cpp |
| diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp |
| index 553233de12117ea8ccebcdfd261a720b8e721412..8169cf5bafcaa2dffe1b2384bd47e151971c683c 100644 |
| --- a/src/codec/SkCodec_libpng.cpp |
| +++ b/src/codec/SkCodec_libpng.cpp |
| @@ -474,7 +474,7 @@ SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo, |
| // Create the swizzler. SkPngCodec retains ownership of the color table. |
| const SkPMColor* colors = fColorTable ? fColorTable->readColors() : NULL; |
| fSwizzler.reset(SkSwizzler::CreateSwizzler(fSrcConfig, colors, requestedInfo, |
| - dst, rowBytes, options.fZeroInitialized)); |
| + dst, rowBytes, options.fZeroInitialized, this->getInfo().width())); |
| if (!fSwizzler) { |
| // FIXME: CreateSwizzler could fail for another reason. |
| return kUnimplemented; |
| @@ -597,7 +597,7 @@ public: |
| , fCodec(codec) |
| , fHasAlpha(false) |
| { |
| - fStorage.reset(dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig)); |
| + fStorage.reset(fCodec->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig)); |
| fSrcRow = static_cast<uint8_t*>(fStorage.get()); |
| } |
| @@ -634,6 +634,10 @@ public: |
| bool onReallyHasAlpha() const override { return fHasAlpha; } |
| + bool onIsHardToSample() override { |
| + return false; |
| + } |
| + |
| private: |
| SkAutoTDelete<SkPngCodec> fCodec; |
| bool fHasAlpha; |
| @@ -653,7 +657,7 @@ public: |
| , fCurrentRow(0) |
| , fHeight(dstInfo.height()) |
| { |
| - fSrcRowBytes = dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig); |
| + fSrcRowBytes = codec->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig); |
| fGarbageRow.reset(fSrcRowBytes); |
| fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get()); |
| } |
| @@ -708,6 +712,10 @@ public: |
| bool onReallyHasAlpha() const override { return fHasAlpha; } |
| + bool onIsHardToSample() override { |
| + return true; |
| + } |
| + |
| private: |
| SkAutoTDelete<SkPngCodec> fCodec; |
| bool fHasAlpha; |
| @@ -728,8 +736,16 @@ SkScanlineDecoder* SkPngCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo, |
| return NULL; |
| } |
| // Check to see if scaling was requested. |
| - if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
| - return NULL; |
| + if(dstInfo.dimensions() != this->getInfo().dimensions()) { |
| + // the caller is sampling |
| + // heights must be equal as SkCodec_libpng has no native y sampling |
| + if (dstInfo.height() != this->getInfo().height()) { |
|
scroggo
2015/07/31 13:35:33
Maybe this should be another static method on SkSc
emmaleer
2015/07/31 18:41:56
Acknowledged.
|
| + return NULL; |
| + } |
| + // only support down sampling, dstWidth cannot be larger that srcWidth |
| + if(dstInfo.width() > this->getInfo().width()) { |
| + return NULL; |
| + } |
| } |
| // Create a new SkPngCodec, to be owned by the scanline decoder. |
| SkStream* stream = this->stream()->duplicate(); |