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

Unified Diff: src/codec/SkCodec_libpng.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stop DM from running large interlaced images on 32-bit Ubuntu GCE bots b/c they are running out of … 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
« no previous file with comments | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkCodec_wbmp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libpng.cpp
diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp
index c94f371399bccb535ce5351919c59d0e9d6d95df..159aecd7efb1f3d9dc8d87f1049a3202853cad0c 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"
@@ -462,7 +463,7 @@ SkCodec::Result SkPngCodec::initializeSwizzler(const SkImageInfo& requestedInfo,
// Create the swizzler. SkPngCodec retains ownership of the color table.
const SkPMColor* colors = get_color_ptr(fColorTable.get());
fSwizzler.reset(SkSwizzler::CreateSwizzler(fSrcConfig, colors, requestedInfo,
- options.fZeroInitialized));
+ options.fZeroInitialized, this->getInfo()));
if (!fSwizzler) {
// FIXME: CreateSwizzler could fail for another reason.
return kUnimplemented;
@@ -582,8 +583,7 @@ public:
SkCodec::Result onStart(const SkImageInfo& dstInfo,
const SkCodec::Options& options,
- SkPMColor ctable[], int* ctableCount) override
- {
+ SkPMColor ctable[], int* ctableCount) override {
if (!fCodec->rewindIfNeeded()) {
return SkCodec::kCouldNotRewind;
}
@@ -594,7 +594,9 @@ public:
// 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,
@@ -604,7 +606,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;
@@ -643,6 +645,11 @@ public:
bool onReallyHasAlpha() const override { return fHasAlpha; }
+ SkEncodedFormat onGetEncodedFormat() const override {
+ return kPNG_SkEncodedFormat;
+ }
+
+
private:
SkAutoTDelete<SkPngCodec> fCodec;
bool fHasAlpha;
@@ -673,12 +680,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,
@@ -690,7 +699,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;
@@ -753,6 +762,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/SkCodec_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698