| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkMovie.h" | 10 #include "SkMovie.h" |
| 11 #include "SkColor.h" | 11 #include "SkColor.h" |
| 12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
| 13 #include "SkStream.h" | 13 #include "SkStream.h" |
| 14 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
| 15 #include "SkUtils.h" | 15 #include "SkUtils.h" |
| 16 | 16 |
| 17 #include "gif_lib.h" | 17 #include "gif_lib.h" |
| 18 | 18 |
| 19 #if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0) |
| 20 #define DGifCloseFile(a, b) DGifCloseFile(a) |
| 21 #endif |
| 22 |
| 19 class SkGIFMovie : public SkMovie { | 23 class SkGIFMovie : public SkMovie { |
| 20 public: | 24 public: |
| 21 SkGIFMovie(SkStream* stream); | 25 SkGIFMovie(SkStream* stream); |
| 22 virtual ~SkGIFMovie(); | 26 virtual ~SkGIFMovie(); |
| 23 | 27 |
| 24 protected: | 28 protected: |
| 25 virtual bool onGetInfo(Info*); | 29 virtual bool onGetInfo(Info*); |
| 26 virtual bool onSetTime(SkMSec); | 30 virtual bool onSetTime(SkMSec); |
| 27 virtual bool onGetBitmap(SkBitmap*); | 31 virtual bool onGetBitmap(SkBitmap*); |
| 28 | 32 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 #if GIFLIB_MAJOR < 5 | 47 #if GIFLIB_MAJOR < 5 |
| 44 fGIF = DGifOpen( stream, Decode ); | 48 fGIF = DGifOpen( stream, Decode ); |
| 45 #else | 49 #else |
| 46 fGIF = DGifOpen( stream, Decode, NULL ); | 50 fGIF = DGifOpen( stream, Decode, NULL ); |
| 47 #endif | 51 #endif |
| 48 if (NULL == fGIF) | 52 if (NULL == fGIF) |
| 49 return; | 53 return; |
| 50 | 54 |
| 51 if (DGifSlurp(fGIF) != GIF_OK) | 55 if (DGifSlurp(fGIF) != GIF_OK) |
| 52 { | 56 { |
| 53 DGifCloseFile(fGIF); | 57 DGifCloseFile(fGIF, NULL); |
| 54 fGIF = NULL; | 58 fGIF = NULL; |
| 55 } | 59 } |
| 56 fCurrIndex = -1; | 60 fCurrIndex = -1; |
| 57 fLastDrawIndex = -1; | 61 fLastDrawIndex = -1; |
| 58 } | 62 } |
| 59 | 63 |
| 60 SkGIFMovie::~SkGIFMovie() | 64 SkGIFMovie::~SkGIFMovie() |
| 61 { | 65 { |
| 62 if (fGIF) | 66 if (fGIF) |
| 63 DGifCloseFile(fGIF); | 67 DGifCloseFile(fGIF, NULL); |
| 64 } | 68 } |
| 65 | 69 |
| 66 static SkMSec savedimage_duration(const SavedImage* image) | 70 static SkMSec savedimage_duration(const SavedImage* image) |
| 67 { | 71 { |
| 68 for (int j = 0; j < image->ExtensionBlockCount; j++) | 72 for (int j = 0; j < image->ExtensionBlockCount; j++) |
| 69 { | 73 { |
| 70 if (image->ExtensionBlocks[j].Function == GRAPHICS_EXT_FUNC_CODE) | 74 if (image->ExtensionBlocks[j].Function == GRAPHICS_EXT_FUNC_CODE) |
| 71 { | 75 { |
| 72 SkASSERT(image->ExtensionBlocks[j].ByteCount >= 4); | 76 SkASSERT(image->ExtensionBlocks[j].ByteCount >= 4); |
| 73 const uint8_t* b = (const uint8_t*)image->ExtensionBlocks[j].Bytes; | 77 const uint8_t* b = (const uint8_t*)image->ExtensionBlocks[j].Bytes; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { | 442 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { |
| 439 // must rewind here, since our construct wants to re-read the data | 443 // must rewind here, since our construct wants to re-read the data |
| 440 stream->rewind(); | 444 stream->rewind(); |
| 441 return SkNEW_ARGS(SkGIFMovie, (stream)); | 445 return SkNEW_ARGS(SkGIFMovie, (stream)); |
| 442 } | 446 } |
| 443 } | 447 } |
| 444 return NULL; | 448 return NULL; |
| 445 } | 449 } |
| 446 | 450 |
| 447 static SkTRegistry<SkMovie*(*)(SkStreamRewindable*)> gReg(Factory); | 451 static SkTRegistry<SkMovie*(*)(SkStreamRewindable*)> gReg(Factory); |
| OLD | NEW |