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 "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return result; | 469 return result; |
470 } | 470 } |
471 | 471 |
472 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 472 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
473 return gif_error("Scaling not supported.\n", kInvalidScale); | 473 return gif_error("Scaling not supported.\n", kInvalidScale); |
474 } | 474 } |
475 | 475 |
476 // Initialize the swizzler | 476 // Initialize the swizzler |
477 if (fFrameIsSubset) { | 477 if (fFrameIsSubset) { |
478 // Fill the background | 478 // Fill the background |
479 SkSampler::Fill(dstInfo, dst, dstRowBytes, | 479 SkSampler::Fill(dstInfo, dst, dstRowBytes, this->getFillValue(dstInfo.co
lorType()), |
480 this->getFillValue(dstInfo.colorType(), dstInfo.alphaType()), | |
481 opts.fZeroInitialized); | 480 opts.fZeroInitialized); |
482 } | 481 } |
483 | 482 |
484 // Iterate over rows of the input | 483 // Iterate over rows of the input |
485 for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) { | 484 for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) { |
486 if (!this->readRow()) { | 485 if (!this->readRow()) { |
487 *rowsDecoded = y; | 486 *rowsDecoded = y; |
488 return gif_error("Could not decode line.\n", kIncompleteInput); | 487 return gif_error("Could not decode line.\n", kIncompleteInput); |
489 } | 488 } |
490 void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanlin
e(y)); | 489 void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanlin
e(y)); |
491 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); | 490 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); |
492 } | 491 } |
493 return kSuccess; | 492 return kSuccess; |
494 } | 493 } |
495 | 494 |
496 // FIXME: This is similar to the implementation for bmp and png. Can we share m
ore code or | 495 // FIXME: This is similar to the implementation for bmp and png. Can we share m
ore code or |
497 // possibly make this non-virtual? | 496 // possibly make this non-virtual? |
498 uint32_t SkGifCodec::onGetFillValue(SkColorType colorType, SkAlphaType alphaType
) const { | 497 uint32_t SkGifCodec::onGetFillValue(SkColorType colorType) const { |
499 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 498 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
500 return get_color_table_fill_value(colorType, colorPtr, fFillIndex); | 499 return get_color_table_fill_value(colorType, colorPtr, fFillIndex); |
501 } | 500 } |
502 | 501 |
503 SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, | 502 SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
504 const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColor
Count) { | 503 const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColor
Count) { |
505 return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->
options()); | 504 return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->
options()); |
506 } | 505 } |
507 | 506 |
508 void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsI
nFrame) { | 507 void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsI
nFrame) { |
(...skipping 22 matching lines...) Expand all Loading... |
531 } | 530 } |
532 | 531 |
533 int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { | 532 int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
534 int rowsBeforeFrame; | 533 int rowsBeforeFrame; |
535 int rowsInFrame; | 534 int rowsInFrame; |
536 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame); | 535 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame); |
537 | 536 |
538 if (fFrameIsSubset) { | 537 if (fFrameIsSubset) { |
539 // Fill the requested rows | 538 // Fill the requested rows |
540 SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), c
ount); | 539 SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), c
ount); |
541 uint32_t fillValue = this->onGetFillValue(this->dstInfo().colorType(), | 540 uint32_t fillValue = this->onGetFillValue(this->dstInfo().colorType()); |
542 this->dstInfo().alphaType()); | |
543 fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZer
oInitialized); | 541 fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZer
oInitialized); |
544 | 542 |
545 // Start to write pixels at the start of the image frame | 543 // Start to write pixels at the start of the image frame |
546 dst = SkTAddOffset<void>(dst, rowBytes * rowsBeforeFrame); | 544 dst = SkTAddOffset<void>(dst, rowBytes * rowsBeforeFrame); |
547 } | 545 } |
548 | 546 |
549 for (int i = 0; i < rowsInFrame; i++) { | 547 for (int i = 0; i < rowsInFrame; i++) { |
550 if (!this->readRow()) { | 548 if (!this->readRow()) { |
551 return i + rowsBeforeFrame; | 549 return i + rowsBeforeFrame; |
552 } | 550 } |
(...skipping 28 matching lines...) Expand all Loading... |
581 int SkGifCodec::onOutputScanline(int inputScanline) const { | 579 int SkGifCodec::onOutputScanline(int inputScanline) const { |
582 if (fGif->Image.Interlace) { | 580 if (fGif->Image.Interlace) { |
583 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { | 581 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { |
584 return inputScanline; | 582 return inputScanline; |
585 } | 583 } |
586 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + | 584 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + |
587 fFrameRect.top(); | 585 fFrameRect.top(); |
588 } | 586 } |
589 return inputScanline; | 587 return inputScanline; |
590 } | 588 } |
OLD | NEW |