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

Unified Diff: include/codec/SkScanlineDecoder.h

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 | « include/codec/SkScaledCodec.h ('k') | src/codec/SkBmpStandardCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/codec/SkScanlineDecoder.h
diff --git a/include/codec/SkScanlineDecoder.h b/include/codec/SkScanlineDecoder.h
index c233663dbdb2d216349eed791744e20eec060f3f..c547f6701f667d2ecfd61f7dca2154f164c19242 100644
--- a/include/codec/SkScanlineDecoder.h
+++ b/include/codec/SkScanlineDecoder.h
@@ -46,6 +46,18 @@ public:
virtual ~SkScanlineDecoder() {}
/**
+ * Return a size that approximately supports the desired scale factor.
+ * The codec may not be able to scale efficiently to the exact scale
+ * factor requested, so return a size that approximates that scale.
+ * The returned value is the codec's suggestion for the closest valid
+ * scale that it can natively support
+ * FIXME: share this with SkCodec
+ */
+ SkISize getScaledDimensions(float desiredScale) {
+ return this->onGetScaledDimensions(desiredScale);
+ }
+
+ /**
* Returns the default info, corresponding to the encoded data.
*/
const SkImageInfo& getInfo() { return fSrcInfo; }
@@ -135,14 +147,44 @@ public:
return this->onReallyHasAlpha();
}
+ /**
+ * Format of the encoded data.
+ */
+ SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+
+ /**
+ * returns true if the image must be scaled, in the y direction, after reading, not during.
+ * To scale afterwards, we first decode every line and then sample the lines we want afterwards.
+ * An example is interlaced pngs, where calling getScanlines once (regardless of the count
+ * used) needs to read the entire image, therefore it is inefficient to call
+ * getScanlines more than once. Instead, it should only ever be called with all the
+ * rows needed.
+ */
+ bool requiresPostYSampling() {
+ return this->onRequiresPostYSampling();
+ }
+
protected:
SkScanlineDecoder(const SkImageInfo& srcInfo)
: fSrcInfo(srcInfo)
, fDstInfo()
, fCurrScanline(0) {}
+ virtual SkISize onGetScaledDimensions(float /* desiredScale */) {
+ // By default, scaling is not supported.
+ return this->getInfo().dimensions();
+ }
+
+ virtual SkEncodedFormat onGetEncodedFormat() const = 0;
+
virtual bool onReallyHasAlpha() const { return false; }
+ /**
+ * returns true if the image type is hard to sample and must be scaled after reading, not during
+ * An example is interlaced pngs, where the entire image must be read for each decode
+ */
+ virtual bool onRequiresPostYSampling() { return false; }
+
const SkImageInfo& dstInfo() const { return fDstInfo; }
private:
« no previous file with comments | « include/codec/SkScaledCodec.h ('k') | src/codec/SkBmpStandardCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698