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

Unified Diff: src/codec/SkGifCodec.h

Issue 2045293002: Add support for multiple frames in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase; new API Created 4 years, 3 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: src/codec/SkGifCodec.h
diff --git a/src/codec/SkGifCodec.h b/src/codec/SkGifCodec.h
index c56d3719a9e0733acf7d078e49ca889f48727323..8748df74a5bd9a3ef8a38bcb3bae7390d0ad265e 100644
--- a/src/codec/SkGifCodec.h
+++ b/src/codec/SkGifCodec.h
@@ -6,10 +6,12 @@
*/
#include "SkCodec.h"
+#include "SkCodecAnimation.h"
#include "SkColorSpace.h"
#include "SkColorTable.h"
#include "SkImageInfo.h"
#include "SkSwizzler.h"
+#include "../private/SkTArray.h"
struct GifFileType;
struct SavedImage;
@@ -64,25 +66,16 @@ protected:
return kGIF_SkEncodedFormat;
}
- bool onRewind() override;
-
uint64_t onGetFillValue(const SkImageInfo&) const override;
- int onOutputScanline(int inputScanline) const override;
+ size_t onGetFrameCount() override {
+ return (size_t) fFrameInfos.count();
+ }
-private:
+ size_t onGetRequiredFrame(size_t) override;
- /*
- * 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 gif Pointer to the library type that manages the gif decode
- * @param transIndex This call will set the transparent index based on the
- * extension data.
- */
- static Result ReadUpToFirstImage(GifFileType* gif, uint32_t* transIndex);
+ size_t onGetFrameDuration(size_t) override;
+private:
/*
* A gif may contain many image frames, all of different sizes.
@@ -92,12 +85,10 @@ private:
* @param gif Pointer to the library type that manages the gif decode
* @param size Size of the image that we will decode.
* Will be set by this function if the return value is true.
- * @param frameRect Contains the dimenions and offset of the first image frame.
- * Will be set by this function if the return value is true.
*
* @return true on success, false otherwise
*/
- static bool GetDimensions(GifFileType* gif, SkISize* size, SkIRect* frameRect);
+ static bool GetDimensions(GifFileType* gif, SkISize* size);
/*
* Initializes the color table that we will use for decoding.
@@ -122,49 +113,17 @@ private:
int* inputColorCount, const Options& opts);
/*
- * 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 options Informs the swizzler if destination memory is zero initialized.
- * Contains subset information.
- */
- void initializeSwizzler(const SkImageInfo& dstInfo,
- const Options& options);
-
- SkSampler* getSampler(bool createIfNecessary) override {
- SkASSERT(fSwizzler);
- return fSwizzler;
- }
-
- /*
- * @return true if the read is successful and false if the read fails.
- */
- bool readRow();
-
- Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opts,
- SkPMColor inputColorPtr[], int* inputColorCount) override;
-
- int onGetScanlines(void* dst, int count, size_t rowBytes) override;
-
- bool onSkipScanlines(int count) override;
-
- /*
- * For a scanline decode of "count" lines, this function indicates how
- * many of the "count" lines should be skipped until we reach the top of
- * the image frame and how many of the "count" lines are actually inside
- * the image frame.
+ * Recursive function to decode a frame.
*
- * @param count The number of scanlines requested.
- * @param rowsBeforeFrame Output variable. The number of lines before
- * we reach the top of the image frame.
- * @param rowsInFrame Output variable. The number of lines to decode
- * inside the image frame.
+ * If !opts.fHasPriorFrame, and the frame is not independent, it will first
+ * decode the frame that it depends on.
*/
- void handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsInFrame);
+ void decodeFrame(const SkImageInfo& dstInfo, void* pixels, size_t dstRowBytes,
+ const Options& opts);
- SkScanlineOrder onGetScanlineOrder() const override;
+ // FIXME: Old patch deletes this. Was that really necessary?
+ // void initializeSwizzler(const SkImageInfo& dstInfo,
+ // const Options& options);
/*
* This function cleans up the gif object after the decode completes
@@ -190,16 +149,19 @@ private:
* indicates that there is no transparent index.
*/
SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
- GifFileType* gif, uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset);
+ GifFileType* gif, uint32_t transIndex);
+
+
+ struct FrameInfo : public SkCodecAnimation::FrameInfo {
+ uint32_t fTransIndex;
+ };
SkAutoTCallVProc<GifFileType, CloseGif> fGif; // owned
SkAutoTDeleteArray<uint8_t> fSrcBuffer;
- const SkIRect fFrameRect;
- const uint32_t fTransIndex;
uint32_t fFillIndex;
- const bool fFrameIsSubset;
SkAutoTDelete<SkSwizzler> fSwizzler;
SkAutoTUnref<SkColorTable> fColorTable;
+ SkTArray<FrameInfo> fFrameInfos;
typedef SkCodec INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698