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

Unified Diff: src/codec/SkCodec_libpng.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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: src/codec/SkCodec_libpng.cpp
diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp
index 553233de12117ea8ccebcdfd261a720b8e721412..ca7c73fb0bb0012595ee2316d2aec05a9f2321fd 100644
--- a/src/codec/SkCodec_libpng.cpp
+++ b/src/codec/SkCodec_libpng.cpp
@@ -424,6 +424,14 @@ static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
}
}
+bool SkPngCodec::onIsInterlaced() {
+ if (1 == png_set_interlace_handling(fPng_ptr)){
scroggo 2015/07/27 15:09:19 You actually do not need a conditional here. You c
emmaleer 2015/07/27 18:31:38 Acknowledged.
+ return false;
+ } else {
+ return true;
+ }
+}
+
SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo,
void* dst, size_t rowBytes,
const Options& options,
@@ -593,14 +601,19 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
class SkPngScanlineDecoder : public SkScanlineDecoder {
public:
SkPngScanlineDecoder(const SkImageInfo& dstInfo, SkPngCodec* codec)
- : INHERITED(dstInfo)
+ : INHERITED(dstInfo, codec->getInfo())
, 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());
}
+ bool onSetSampleX(int sampleX) override {
+ fCodec->fSwizzler->setSampleX(sampleX);
+ return true;
+ }
+
SkCodec::Result onGetScanlines(void* dst, int count, size_t rowBytes) override {
if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) {
SkCodecPrintf("setjmp long jump!\n");
@@ -647,17 +660,22 @@ private:
class SkPngInterlacedScanlineDecoder : public SkScanlineDecoder {
public:
SkPngInterlacedScanlineDecoder(const SkImageInfo& dstInfo, SkPngCodec* codec)
- : INHERITED(dstInfo)
+ : INHERITED(dstInfo, codec->getInfo())
, fCodec(codec)
, fHasAlpha(false)
, 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());
}
+ bool onSetSampleX(int sampleX) override {
+ fCodec->fSwizzler->setSampleX(sampleX);
+ return true;
+ }
+
SkCodec::Result onGetScanlines(void* dst, int count, size_t dstRowBytes) override {
//rewind stream if have previously called onGetScanlines,
//since we need entire progressive image to get scanlines
@@ -728,8 +746,10 @@ SkScanlineDecoder* SkPngCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo,
return NULL;
}
// Check to see if scaling was requested.
- if (dstInfo.dimensions() != this->getInfo().dimensions()) {
- return NULL;
+ if(options.fScaled == false) {
scroggo 2015/07/27 15:09:19 Please add a comment explaining this. Something li
emmaleer 2015/07/27 18:31:38 Changed to fSampled. For normal images the dstHei
scroggo 2015/07/27 19:29:56 Does the SkCodec need to know that dstHeight is sm
emmaleer 2015/07/28 14:19:16 Yes, I have changed the height to be the original
+ if (dstInfo.dimensions() != this->getInfo().dimensions()) {
+ return NULL;
+ }
}
// Create a new SkPngCodec, to be owned by the scanline decoder.
SkStream* stream = this->stream()->duplicate();

Powered by Google App Engine
This is Rietveld 408576698