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; |
}; |