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

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: Build with no-clobbered 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
« no previous file with comments | « gyp/codec.gyp ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/codec/SkCodec.h
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index c3840354f158adc59b8e06c545c7b10407d39596..7337006769e13afdb72d77ccc1f8ea77e1d5c7af 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -11,6 +11,7 @@
#include "SkEncodedFormat.h"
#include "SkImageGenerator.h"
#include "SkImageInfo.h"
+#include "SkScanlineDecoder.h"
#include "SkSize.h"
#include "SkStream.h"
#include "SkTemplates.h"
@@ -56,6 +57,41 @@ public:
*/
SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+ /**
+ * Return an object which can be used to decode individual scanlines.
+ *
+ * This object is owned by the SkCodec, which will handle its lifetime. The
+ * returned object is only valid until the SkCodec is deleted or the next
+ * call to getScanlineDecoder, whichever comes first.
+ *
+ * Calling a second time will rewind and replace the existing one with a
+ * new one. If the stream cannot be rewound, this will delete the existing
+ * one and return NULL.
+ *
+ * @param dstInfo Info of the destination. If the dimensions do not match
+ * those of getInfo, this implies a scale.
+ * @return New SkScanlineDecoder, or NULL on failure.
+ *
+ * NOTE: If any rows were previously decoded, this requires rewinding the
+ * SkStream.
+ *
+ * NOTE: The scanline decoder is owned by the SkCodec and will delete it
+ * when the SkCodec is deleted.
+ */
+ SkScanlineDecoder* getScanlineDecoder(const SkImageInfo& dstInfo);
+
+ /**
+ * 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.
+ * FIXME: see skbug.com/3582.
+ */
+ bool reallyHasAlpha() const {
+ return this->onReallyHasAlpha();
+ }
+
protected:
SkCodec(const SkImageInfo&, SkStream*);
@@ -79,6 +115,23 @@ protected:
virtual SkEncodedFormat onGetEncodedFormat() const = 0;
/**
+ * 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, this implies a scale.
+ * @return New SkScanlineDecoder on success, NULL otherwise. The SkCodec
+ * will take ownership of the returned scanline decoder.
+ */
+ virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo) {
+ return NULL;
+ }
+
+ virtual bool onReallyHasAlpha() const { return false; }
+
+ /**
* If the stream was previously read, attempt to rewind.
* @returns:
* true
@@ -103,9 +156,10 @@ protected:
}
private:
- const SkImageInfo fInfo;
- SkAutoTDelete<SkStream> fStream;
- bool fNeedsRewind;
+ const SkImageInfo fInfo;
+ SkAutoTDelete<SkStream> fStream;
+ bool fNeedsRewind;
+ SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
typedef SkImageGenerator INHERITED;
};
« no previous file with comments | « gyp/codec.gyp ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698