OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 return error_return(*bm, "Sampler failed to begin."); | 410 return error_return(*bm, "Sampler failed to begin."); |
411 } | 411 } |
412 | 412 |
413 // now decode each scanline | 413 // now decode each scanline |
414 if (gif->Image.Interlace) { | 414 if (gif->Image.Interlace) { |
415 // Iterate over the height of the source data. The sampler will | 415 // Iterate over the height of the source data. The sampler will |
416 // take care of skipping unneeded rows. | 416 // take care of skipping unneeded rows. |
417 GifInterlaceIter iter(innerHeight); | 417 GifInterlaceIter iter(innerHeight); |
418 for (int y = 0; y < innerHeight; y++) { | 418 for (int y = 0; y < innerHeight; y++) { |
419 if (DGifGetLine(gif, scanline, innerWidth) == GIF_ERROR) { | 419 if (DGifGetLine(gif, scanline, innerWidth) == GIF_ERROR) { |
| 420 #ifdef SK_DECODE_PARTIAL_IMAGES |
420 gif_warning(*bm, "interlace DGifGetLine"); | 421 gif_warning(*bm, "interlace DGifGetLine"); |
421 memset(scanline, fillIndex, innerWidth); | 422 memset(scanline, fillIndex, innerWidth); |
422 for (; y < innerHeight; y++) { | 423 for (; y < innerHeight; y++) { |
423 sampler.sampleInterlaced(scanline, iter.currY()); | 424 sampler.sampleInterlaced(scanline, iter.currY()); |
424 iter.next(); | 425 iter.next(); |
425 } | 426 } |
426 return true; | 427 return true; |
| 428 #else |
| 429 return error_return(*bm, "interlace DGifGetLine"); |
| 430 #endif |
427 } | 431 } |
428 sampler.sampleInterlaced(scanline, iter.currY()); | 432 sampler.sampleInterlaced(scanline, iter.currY()); |
429 iter.next(); | 433 iter.next(); |
430 } | 434 } |
431 } else { | 435 } else { |
432 // easy, non-interlace case | 436 // easy, non-interlace case |
433 const int outHeight = workingBitmap->height(); | 437 const int outHeight = workingBitmap->height(); |
434 skip_src_rows(gif, scanline, innerWidth, sampler.srcY0()); | 438 skip_src_rows(gif, scanline, innerWidth, sampler.srcY0()); |
435 for (int y = 0; y < outHeight; y++) { | 439 for (int y = 0; y < outHeight; y++) { |
436 if (DGifGetLine(gif, scanline, innerWidth) == GIF_ERROR) { | 440 if (DGifGetLine(gif, scanline, innerWidth) == GIF_ERROR) { |
| 441 #ifdef SK_DECODE_PARTIAL_IMAGES |
437 gif_warning(*bm, "DGifGetLine"); | 442 gif_warning(*bm, "DGifGetLine"); |
438 memset(scanline, fillIndex, innerWidth); | 443 memset(scanline, fillIndex, innerWidth); |
439 for (; y < outHeight; y++) { | 444 for (; y < outHeight; y++) { |
440 sampler.next(scanline); | 445 sampler.next(scanline); |
441 } | 446 } |
442 return true; | 447 return true; |
| 448 #else |
| 449 return error_return(*bm, "DGifGetLine"); |
| 450 #endif |
443 } | 451 } |
444 // scanline now contains the raw data. Sample it. | 452 // scanline now contains the raw data. Sample it. |
445 sampler.next(scanline); | 453 sampler.next(scanline); |
446 if (y < outHeight - 1) { | 454 if (y < outHeight - 1) { |
447 skip_src_rows(gif, scanline, innerWidth, sampler.srcDY()
- 1); | 455 skip_src_rows(gif, scanline, innerWidth, sampler.srcDY()
- 1); |
448 } | 456 } |
449 } | 457 } |
450 // skip the rest of the rows (if any) | 458 // skip the rest of the rows (if any) |
451 int read = (outHeight - 1) * sampler.srcDY() + sampler.srcY0() +
1; | 459 int read = (outHeight - 1) * sampler.srcDY() + sampler.srcY0() +
1; |
452 SkASSERT(read <= innerHeight); | 460 SkASSERT(read <= innerHeight); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); | 535 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); |
528 | 536 |
529 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { | 537 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { |
530 if (is_gif(stream)) { | 538 if (is_gif(stream)) { |
531 return SkImageDecoder::kGIF_Format; | 539 return SkImageDecoder::kGIF_Format; |
532 } | 540 } |
533 return SkImageDecoder::kUnknown_Format; | 541 return SkImageDecoder::kUnknown_Format; |
534 } | 542 } |
535 | 543 |
536 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); | 544 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); |
OLD | NEW |