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

Unified Diff: include/codec/SkCodec.h

Issue 1010903003: Add scanline decoding to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanups Created 5 years, 9 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: include/codec/SkCodec.h
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index beb9cb97b32bdb51bed7cc4d76d24b968fe0858d..5b92285059c023b276247a3a4670aea13642cdf5 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -15,6 +15,7 @@
#include "SkTypes.h"
class SkData;
+class SkScanlineDecoder;
class SkStream;
/**
@@ -48,6 +49,39 @@ public:
*/
SkISize getScaledDimensions(float desiredScale) const;
+ /**
+ * Create a new scanline decoder.
+ *
+ * Create a new object which can be used to decode individual scanlines.
+ *
+ * @param dstInfo Info of the destination. If the dimensions do not match
+ * those of getInfo (or origSubset, if provided), this implies a scale.
+ * @param origSubset If non null, represents a subset of the original
+ * unscaled image for the scanline decoder to decode.
+ * @return New SkScanlineDecoder, or NULL on failure.
+ *
+ * NOTE: If any rows were previously decoded, this requires rewinding the
+ * SkStream.
+ *
+ * NOTE: The lifetime of the scanline decoder is tied to the lifetime of
+ * the SkCodec. Do not attempt to use after the SkCodec has been deleted.
+ * Further, the SkScanlineDecoder should be deleted *before* the SkCodec,
+ * in case the implementation depends on the ordering.
+ */
+ SkScanlineDecoder* getScanlineDecoder(const SkImageInfo& dstInfo,
+ const SkIRect* origSubset = NULL);
scroggo 2015/03/18 20:19:06 I haven't yet handled the subset case, but I wante
+
+ /**
+ * Some images may initially report that they have alpha due to the format
+ * of the encoded data, but then never use any colors which have alpha
+ * less than 100%. This function can be called *after* decoding to
+ * determine if such an image truly had alpha. Calling it before decoding
+ * is undefined.
+ */
+ bool reallyHasAlpha() const {
scroggo 2015/03/18 20:19:06 This maybe should have been a separate change, but
+ return this->onReallyHasAlpha();
+ }
+
protected:
SkCodec(const SkImageInfo&, SkStream*);
@@ -70,6 +104,27 @@ protected:
}
/**
+ * Override if your codec supports scanline decoding.
+ *
+ * No need to call rewindIfNeeded(), which will have already been called
+ * by the base class.
+ *
+ * @param dstInfo Info of the destination. If the dimensions do not match
+ * those of getInfo (or origSubset, if different), this implies a
+ * scale.
+ * @param origSubset Subset of the original info to decode. The base class
+ * will have already intersected with getInfo (or set to match if the
+ * caller supplied NULL).
+ * @return New SkScanlineDecoder on success, NULL otherwise.
+ */
+ virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo,
+ const SkIRect& origSubset) {
+ return NULL;
+ }
+
+ virtual bool onReallyHasAlpha() const { return false; }
+
+ /**
* If the stream was previously read, attempt to rewind.
* @returns:
* true

Powered by Google App Engine
This is Rietveld 408576698