Index: src/codec/SkCodec_libgif.h |
diff --git a/src/codec/SkCodec_libgif.h b/src/codec/SkCodec_libgif.h |
index 109020b5cf6c06c2f774fcd97f925e383cef4e6e..e918eb03d6a99ff4666b4846c7c807d2cf33c3b8 100644 |
--- a/src/codec/SkCodec_libgif.h |
+++ b/src/codec/SkCodec_libgif.h |
@@ -6,7 +6,10 @@ |
*/ |
#include "SkCodec.h" |
+#include "SkColorTable.h" |
#include "SkImageInfo.h" |
+#include "SkScanlineDecoder.h" |
+#include "SkSwizzler.h" |
#include "gif_lib.h" |
@@ -30,6 +33,7 @@ public: |
*/ |
static SkCodec* NewFromStream(SkStream*); |
+ static SkScanlineDecoder* NewSDFromStream(SkStream* stream); |
protected: |
@@ -52,10 +56,11 @@ protected: |
* Ownership is unchanged when we returned a gifOut. |
* |
*/ |
- static bool ReadHeader(SkStream* stream, SkCodec** codecOut, GifFileType** gifOut); |
+ static bool ReadHeader(SkStream* stream, SkCodec** codecOut, |
+ GifFileType** gifOut); |
/* |
- * Initiates the gif decode |
+ * Performs the full gif decode |
*/ |
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, |
SkPMColor*, int32_t*) override; |
@@ -69,6 +74,52 @@ protected: |
private: |
/* |
+ * A gif can contain multiple image frames. We will only decode the first |
+ * frame. This function reads up to the first image frame, processing |
+ * transparency and/or animation information that comes before the image |
+ * data. |
+ * |
+ * @param transIndex This call will set the transparent index based on the |
+ * extension data. |
+ */ |
+ SkCodec::Result readUpToFirstImage(uint32_t* transIndex); |
+ |
+ /* |
+ * A gif may contain many image frames, all of different sizes. |
+ * This function checks if the frame dimensions are valid and corrects |
+ * them if necessary. It then sets fFrameDims to the corrected |
+ * dimensions. |
+ * |
+ * @param desc The image frame descriptor |
+ */ |
+ bool setFrameDimensions(const GifImageDesc& desc); |
+ |
+ /* |
+ * Initializes the color table that we will use for decoding. |
+ * Sets inputColorCount to 256. Since gifs always contain 8-bit indices, |
scroggo
2015/08/27 16:35:50
It seems weird that we always set this parameter t
msarett
2015/09/01 18:03:59
Sorry forgot this comment. Moving copy_color_tabl
|
+ * we need a 256 entry color table to ensure that indexing is always in |
+ * bounds. |
msarett
2015/08/24 23:20:13
Will improve this comment.
|
+ */ |
+ void initializeColorTable(int* inputColorCount, uint32_t transIndex); |
+ |
+ /* |
+ * Initializes the swizzler. |
+ * |
+ * @param dstInfo Output image information. Dimensions may have been |
+ * adjusted if the image frame size does not match the size |
+ * indicated in the header. |
+ * @param zeroInit Indicates if destination memory is zero initialized. |
+ */ |
+ SkCodec::Result initializeSwizzler(const SkImageInfo& dstInfo, |
+ ZeroInitialized zeroInit); |
+ |
+ /* |
+ * @return kSuccess if the read is successful and kIncompleteInput is the |
scroggo
2015/08/27 16:35:50
if*
msarett
2015/09/01 17:50:16
Done.
|
+ * read fails. |
+ */ |
+ SkCodec::Result readRow(); |
+ |
+ /* |
* This function cleans up the gif object after the decode completes |
* It is used in a SkAutoTCallIProc template |
*/ |
@@ -92,6 +143,14 @@ private: |
SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif); |
SkAutoTCallVProc<GifFileType, CloseGif> fGif; // owned |
+ SkIRect fFrameDims; |
+ uint32_t fFillIndex; |
+ bool fFrameIsSubset; |
+ SkAutoTDelete<SkSwizzler> fSwizzler; |
+ SkAutoTUnref<SkColorTable> fColorTable; |
+ SkAutoTDeleteArray<uint8_t> fSrcBuffer; |
+ |
+ friend class SkGifScanlineDecoder; |
typedef SkCodec INHERITED; |
}; |