Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkCodec.h" | |
| 9 #include "SkImageInfo.h" | |
| 10 | |
| 11 #include "gif_lib.h" | |
| 12 | |
| 13 /* | |
| 14 * | |
| 15 * This class implements the decoding for gif images | |
| 16 * | |
| 17 */ | |
| 18 class SkGifCodec : public SkCodec { | |
| 19 public: | |
| 20 | |
| 21 /* | |
| 22 * Checks the start of the stream to see if the image is a gif | |
| 23 */ | |
| 24 static bool IsGif(SkStream*); | |
| 25 | |
| 26 /* | |
| 27 * Assumes IsGif was called and returned true | |
| 28 * Creates a gif decoder | |
| 29 * Reads enough of the stream to determine the image format | |
| 30 */ | |
| 31 static SkCodec* NewFromStream(SkStream*); | |
| 32 | |
| 33 | |
| 34 protected: | |
| 35 | |
| 36 /* | |
| 37 * Initiates the gif decode | |
| 38 */ | |
| 39 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, | |
| 40 SkPMColor*, int*) SK_OVERRIDE; | |
| 41 | |
| 42 SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { | |
| 43 return kGIF_SkEncodedFormat; | |
| 44 } | |
| 45 | |
| 46 private: | |
| 47 | |
| 48 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
| |
| 49 | |
| 50 /* | |
| 51 * Creates an instance of the decoder | |
| 52 * Called only by NewFromStream | |
| 53 * | |
| 54 * @param srcInfo contains the source width and height | |
| 55 * @param stream the stream of image data | |
| 56 * @param gif pointer to library type that manages gif decode | |
| 57 */ | |
| 58 SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif); | |
| 59 | |
| 60 // Fields | |
| 61 GifFileType* fGif; | |
| 62 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
| |
| 63 | |
| 64 typedef SkCodec INHERITED; | |
| 65 }; | |
| OLD | NEW |