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: Small 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
« no previous file with comments | « dm/DMSrcSink.cpp ('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 ec4b3e1cc80832090c1389823b7e206ab6e97783..3442e64c92a0b983421699a9d9f55921b23e87fb 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,34 @@ public:
*/
SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+ /**
+ * 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, 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);
reed1 2015/03/24 15:45:20 1. Create a new scanline decoder 2. The decoder is
scroggo 2015/03/24 16:55:47 I have updated the comment. I think it's more clea
+
+ /**
+ * 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 {
+ return this->onReallyHasAlpha();
+ }
+
protected:
SkCodec(const SkImageInfo&, SkStream*);
@@ -71,9 +100,6 @@ protected:
}
#endif
- // Helper for subclasses.
- const SkImageInfo& getOriginalInfo() { return fInfo; }
-
virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
// By default, scaling is not supported.
return fInfo.dimensions();
@@ -82,6 +108,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
@@ -106,9 +149,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 | « dm/DMSrcSink.cpp ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698