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

Unified Diff: src/codec/SkCodec_libpng.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove setSampleX(), move IsInterlaced() to scanlineDecoder 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..6012978c38ea27833a29e6333f31bff8d181a91b 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, options.fSampleX));
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,11 @@ public:
bool onReallyHasAlpha() const override { return fHasAlpha; }
+ bool onIsInterlaced() override {
+ return false;
+ }
+
+
private:
SkAutoTDelete<SkPngCodec> fCodec;
bool fHasAlpha;
@@ -653,7 +658,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 +713,10 @@ public:
bool onReallyHasAlpha() const override { return fHasAlpha; }
+ bool onIsInterlaced() override {
+ return true;
+ }
+
private:
SkAutoTDelete<SkPngCodec> fCodec;
bool fHasAlpha;
@@ -728,8 +737,23 @@ 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.fSampleX == 1) {
scroggo 2015/07/28 15:58:10 It would be nice to be able to share this code wit
+ // the caller is not sampling, dimensions must be equal
+ if (dstInfo.dimensions() != this->getInfo().dimensions()) {
+ return NULL;
+ }
+
+ } else {
+ // the caller is sampling
+ // heights must be equal as SkCodec_libpng has no native y sampling
+ if (dstInfo.height() != this->getInfo().height()) {
+ return NULL;
+ }
+ // dstWidth must be srcWidth / sampleX
+ if (dstInfo.width() != this->getInfo().width() / options.fSampleX) {
+ 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