| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkImageInfo.h" | 9 #include "SkImageInfo.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * Assumes IsGif was called and returned true | 27 * Assumes IsGif was called and returned true |
| 28 * Creates a gif decoder | 28 * Creates a gif decoder |
| 29 * Reads enough of the stream to determine the image format | 29 * Reads enough of the stream to determine the image format |
| 30 */ | 30 */ |
| 31 static SkCodec* NewFromStream(SkStream*); | 31 static SkCodec* NewFromStream(SkStream*); |
| 32 | 32 |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 | 35 |
| 36 /* | 36 /* |
| 37 * Read enough of the stream to initialize the SkGifCodec. |
| 38 * Returns a bool representing success or failure. |
| 39 * |
| 40 * @param codecOut |
| 41 * If it returned true, and codecOut was not NULL, |
| 42 * codecOut will be set to a new SkGifCodec. |
| 43 * |
| 44 * @param gifOut |
| 45 * If it returned true, and codecOut was NULL, |
| 46 * gifOut must be non-NULL and gifOut will be set to a new |
| 47 * GifFileType pointer. |
| 48 * |
| 49 * @param stream |
| 50 * Deleted on failure. |
| 51 * codecOut will take ownership of it in the case where we created a codec. |
| 52 * Ownership is unchanged when we returned a gifOut. |
| 53 * |
| 54 */ |
| 55 static bool ReadHeader(SkStream* stream, SkCodec** codecOut, GifFileType** g
ifOut); |
| 56 |
| 57 /* |
| 37 * Initiates the gif decode | 58 * Initiates the gif decode |
| 38 */ | 59 */ |
| 39 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, | 60 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, |
| 40 SkPMColor*, int32_t*) override; | 61 SkPMColor*, int32_t*) override; |
| 41 | 62 |
| 42 SkEncodedFormat onGetEncodedFormat() const override { | 63 SkEncodedFormat onGetEncodedFormat() const override { |
| 43 return kGIF_SkEncodedFormat; | 64 return kGIF_SkEncodedFormat; |
| 44 } | 65 } |
| 45 | 66 |
| 46 private: | 67 private: |
| 47 | 68 |
| 48 /* | 69 /* |
| 49 * This function cleans up the gif object after the decode completes | 70 * This function cleans up the gif object after the decode completes |
| 50 * It is used in a SkAutoTCallIProc template | 71 * It is used in a SkAutoTCallIProc template |
| 51 */ | 72 */ |
| 52 static int32_t CloseGif(GifFileType* gif); | 73 static void CloseGif(GifFileType* gif); |
| 53 | 74 |
| 54 /* | 75 /* |
| 55 * Frees any extension data used in the decode | 76 * Frees any extension data used in the decode |
| 56 * Used in a SkAutoTCallVProc | 77 * Used in a SkAutoTCallVProc |
| 57 */ | 78 */ |
| 58 static void FreeExtension(SavedImage* image); | 79 static void FreeExtension(SavedImage* image); |
| 59 | 80 |
| 60 /* | 81 /* |
| 61 * Creates an instance of the decoder | 82 * Creates an instance of the decoder |
| 62 * Called only by NewFromStream | 83 * Called only by NewFromStream |
| 63 * | 84 * |
| 64 * @param srcInfo contains the source width and height | 85 * @param srcInfo contains the source width and height |
| 65 * @param stream the stream of image data | 86 * @param stream the stream of image data |
| 66 * @param gif pointer to library type that manages gif decode | 87 * @param gif pointer to library type that manages gif decode |
| 67 * takes ownership | 88 * takes ownership |
| 68 */ | 89 */ |
| 69 SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif); | 90 SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif); |
| 70 | 91 |
| 71 SkAutoTCallIProc<GifFileType, CloseGif> fGif; // owned | 92 SkAutoTCallVProc<GifFileType, CloseGif> fGif; // owned |
| 72 | 93 |
| 73 typedef SkCodec INHERITED; | 94 typedef SkCodec INHERITED; |
| 74 }; | 95 }; |
| OLD | NEW |