| 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_libgif.h" | 8 #include "SkCodec_libgif.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || | 23 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || |
| 24 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) | 24 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) |
| 25 { | 25 { |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 /* | 32 /* |
| 33 * Warning reporting function | |
| 34 */ | |
| 35 static void gif_warning(const char* msg) { | |
| 36 SkCodecPrintf("Gif Warning: %s\n", msg); | |
| 37 } | |
| 38 | |
| 39 /* | |
| 40 * Error function | 33 * Error function |
| 41 */ | 34 */ |
| 42 static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCod
ec::kInvalidInput) { | 35 static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCod
ec::kInvalidInput) { |
| 43 SkCodecPrintf("Gif Error: %s\n", msg); | 36 SkCodecPrintf("Gif Error: %s\n", msg); |
| 44 return result; | 37 return result; |
| 45 } | 38 } |
| 46 | 39 |
| 47 | 40 |
| 48 /* | 41 /* |
| 49 * Read function that will be passed to gif_lib | 42 * Read function that will be passed to gif_lib |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return codec; | 223 return codec; |
| 231 } | 224 } |
| 232 return nullptr; | 225 return nullptr; |
| 233 } | 226 } |
| 234 | 227 |
| 235 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType
* gif, | 228 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType
* gif, |
| 236 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset) | 229 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset) |
| 237 : INHERITED(srcInfo, stream) | 230 : INHERITED(srcInfo, stream) |
| 238 , fGif(gif) | 231 , fGif(gif) |
| 239 , fSrcBuffer(new uint8_t[this->getInfo().width()]) | 232 , fSrcBuffer(new uint8_t[this->getInfo().width()]) |
| 233 , fFrameRect(frameRect) |
| 240 // If it is valid, fTransIndex will be used to set fFillIndex. We don't kno
w if | 234 // If it is valid, fTransIndex will be used to set fFillIndex. We don't kno
w if |
| 241 // fTransIndex is valid until we process the color table, since fTransIndex
may | 235 // fTransIndex is valid until we process the color table, since fTransIndex
may |
| 242 // be greater than the size of the color table. | 236 // be greater than the size of the color table. |
| 243 , fTransIndex(transIndex) | 237 , fTransIndex(transIndex) |
| 244 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid,
or if | 238 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid,
or if |
| 245 // there is a valid background color. | 239 // there is a valid background color. |
| 246 , fFillIndex(0) | 240 , fFillIndex(0) |
| 247 , fFrameRect(frameRect) | |
| 248 , fFrameIsSubset(frameIsSubset) | 241 , fFrameIsSubset(frameIsSubset) |
| 242 , fSwizzler(NULL) |
| 249 , fColorTable(NULL) | 243 , fColorTable(NULL) |
| 250 , fSwizzler(NULL) | |
| 251 {} | 244 {} |
| 252 | 245 |
| 253 bool SkGifCodec::onRewind() { | 246 bool SkGifCodec::onRewind() { |
| 254 GifFileType* gifOut = nullptr; | 247 GifFileType* gifOut = nullptr; |
| 255 if (!ReadHeader(this->stream(), nullptr, &gifOut)) { | 248 if (!ReadHeader(this->stream(), nullptr, &gifOut)) { |
| 256 return false; | 249 return false; |
| 257 } | 250 } |
| 258 | 251 |
| 259 SkASSERT(nullptr != gifOut); | 252 SkASSERT(nullptr != gifOut); |
| 260 fGif.reset(gifOut); | 253 fGif.reset(gifOut); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 580 |
| 588 int SkGifCodec::onOutputScanline(int inputScanline) const { | 581 int SkGifCodec::onOutputScanline(int inputScanline) const { |
| 589 if (fGif->Image.Interlace) { | 582 if (fGif->Image.Interlace) { |
| 590 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { | 583 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { |
| 591 return inputScanline; | 584 return inputScanline; |
| 592 } | 585 } |
| 593 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()); | 586 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()); |
| 594 } | 587 } |
| 595 return inputScanline; | 588 return inputScanline; |
| 596 } | 589 } |
| OLD | NEW |