| 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" |
| 11 #include "SkColorTable.h" | 11 #include "SkColorTable.h" |
| 12 #include "SkStream.h" | 12 #include "SkStream.h" |
| 13 #include "SkSwizzler.h" | 13 #include "SkSwizzler.h" |
| 14 #include "SkUtils.h" | 14 #include "SkUtils.h" |
| 15 | 15 |
| 16 /* | 16 /* |
| 17 * Checks the start of the stream to see if the image is a gif | 17 * Checks the start of the stream to see if the image is a gif |
| 18 */ | 18 */ |
| 19 bool SkGifCodec::IsGif(SkStream* stream) { | 19 bool SkGifCodec::IsGif(const char* buf, size_t bytesRead) { |
| 20 char buf[GIF_STAMP_LEN]; | 20 if (bytesRead >= GIF_STAMP_LEN) { |
| 21 if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) { | |
| 22 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || | 21 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || |
| 23 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || | 22 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || |
| 24 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) | 23 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) |
| 25 { | 24 { |
| 26 return true; | 25 return true; |
| 27 } | 26 } |
| 28 } | 27 } |
| 29 return false; | 28 return false; |
| 30 } | 29 } |
| 31 | 30 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 int SkGifCodec::onOutputScanline(int inputScanline) const { | 581 int SkGifCodec::onOutputScanline(int inputScanline) const { |
| 583 if (fGif->Image.Interlace) { | 582 if (fGif->Image.Interlace) { |
| 584 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { | 583 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { |
| 585 return inputScanline; | 584 return inputScanline; |
| 586 } | 585 } |
| 587 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + | 586 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + |
| 588 fFrameRect.top(); | 587 fFrameRect.top(); |
| 589 } | 588 } |
| 590 return inputScanline; | 589 return inputScanline; |
| 591 } | 590 } |
| OLD | NEW |