Chromium Code Reviews| Index: src/codec/SkCodec_libgif.h |
| diff --git a/src/codec/SkCodec_libgif.h b/src/codec/SkCodec_libgif.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c57bb2604b4cf817529551dcb56dc6f311b09a26 |
| --- /dev/null |
| +++ b/src/codec/SkCodec_libgif.h |
| @@ -0,0 +1,65 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "SkCodec.h" |
| +#include "SkImageInfo.h" |
| + |
| +#include "gif_lib.h" |
| + |
| +/* |
| + * |
| + * This class implements the decoding for gif images |
| + * |
| + */ |
| +class SkGifCodec : public SkCodec { |
| +public: |
| + |
| + /* |
| + * Checks the start of the stream to see if the image is a gif |
| + */ |
| + static bool IsGif(SkStream*); |
| + |
| + /* |
| + * Assumes IsGif was called and returned true |
| + * Creates a gif decoder |
| + * Reads enough of the stream to determine the image format |
| + */ |
| + static SkCodec* NewFromStream(SkStream*); |
| + |
| + |
| +protected: |
| + |
| + /* |
| + * Initiates the gif decode |
| + */ |
| + Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, |
| + SkPMColor*, int*) SK_OVERRIDE; |
| + |
| + SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { |
| + return kGIF_SkEncodedFormat; |
| + } |
| + |
| +private: |
| + |
| + static int close_gif(GifFileType* gif); |
|
scroggo
2015/03/25 19:44:49
nit: If part of the header, this should follow a d
msarett
2015/03/26 19:15:57
Per another improvement, this is no longer part of
|
| + |
| + /* |
| + * Creates an instance of the decoder |
| + * Called only by NewFromStream |
| + * |
| + * @param srcInfo contains the source width and height |
| + * @param stream the stream of image data |
| + * @param gif pointer to library type that manages gif decode |
| + */ |
| + SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif); |
| + |
| + // Fields |
| + GifFileType* fGif; |
| + SkAutoTCallIProc<GifFileType, close_gif> fAutoClose; |
|
scroggo
2015/03/25 19:44:49
Is it possible to just store fGif here, and only h
msarett
2015/03/26 19:15:57
Yes it is!
scroggo
2015/03/26 20:03:53
Sorry, I think I was unclear. I definitely want yo
|
| + |
| + typedef SkCodec INHERITED; |
| +}; |