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

Unified Diff: src/codec/SkCodec_libpng.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reset fSwizzler in onStart Created 5 years, 4 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 d29ca8a2a300bbc2635a93c05b6b8c33d1fca220..885a242c806e8bd5268003b871036b83ea2055f7 100644
--- a/src/codec/SkCodec_libpng.cpp
+++ b/src/codec/SkCodec_libpng.cpp
@@ -11,6 +11,7 @@
#include "SkColorTable.h"
#include "SkBitmap.h"
#include "SkMath.h"
+#include "SkScaledCodec.h"
#include "SkScanlineDecoder.h"
#include "SkSize.h"
#include "SkStream.h"
@@ -473,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,
- options.fZeroInitialized));
+ options.fZeroInitialized, this->getInfo().width()));
if (!fSwizzler) {
// FIXME: CreateSwizzler could fail for another reason.
return kUnimplemented;
@@ -602,8 +603,7 @@ public:
SkCodec::Result onStart(const SkImageInfo& dstInfo,
const SkCodec::Options& options,
- SkPMColor ctable[], int* ctableCount) override
- {
+ SkPMColor ctable[], int* ctableCount) override {
if (!fCodec->handleRewind()) {
return SkCodec::kCouldNotRewind;
}
@@ -614,7 +614,9 @@ public:
// Check to see if scaling was requested.
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
- return SkCodec::kInvalidScale;
+ if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
scroggo 2015/08/06 20:38:00 Matt has landed wbmp scanline decoding, so please
emmaleer 2015/08/07 18:38:56 Acknowledged.
+ return SkCodec::kInvalidScale;
+ }
}
const SkCodec::Result result = fCodec->initializeSwizzler(dstInfo, options, ctable,
@@ -624,7 +626,7 @@ public:
}
fHasAlpha = false;
- fStorage.reset(dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig));
+ fStorage.reset(this->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig));
fSrcRow = static_cast<uint8_t*>(fStorage.get());
return SkCodec::kSuccess;
@@ -663,6 +665,11 @@ public:
bool onReallyHasAlpha() const override { return fHasAlpha; }
+ SkEncodedFormat onGetEncodedFormat() const override {
+ return kPNG_SkEncodedFormat;
+ }
+
+
private:
SkAutoTDelete<SkPngCodec> fCodec;
bool fHasAlpha;
@@ -693,12 +700,14 @@ public:
}
if (!conversion_possible(dstInfo, this->getInfo())) {
- return SkCodec::kInvalidConversion;
+ return SkCodec::kInvalidConversion;
}
// Check to see if scaling was requested.
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
- return SkCodec::kInvalidScale;
+ if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
+ return SkCodec::kInvalidScale;
+ }
}
const SkCodec::Result result = fCodec->initializeSwizzler(dstInfo, options, ctable,
@@ -710,7 +719,7 @@ public:
fHasAlpha = false;
fCurrentRow = 0;
fHeight = dstInfo.height();
- fSrcRowBytes = dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig);
+ fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(fCodec->fSrcConfig);
fGarbageRow.reset(fSrcRowBytes);
fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get());
fCanSkipRewind = true;
@@ -773,6 +782,14 @@ public:
bool onReallyHasAlpha() const override { return fHasAlpha; }
+ bool onRequiresPostYSampling() override {
+ return true;
+ }
+
+ SkEncodedFormat onGetEncodedFormat() const override {
+ return kPNG_SkEncodedFormat;
+ }
+
private:
SkAutoTDelete<SkPngCodec> fCodec;
bool fHasAlpha;
« no previous file with comments | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkJpegCodec.h » ('j') | src/codec/SkJpegCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698