| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return result; | 487 return result; |
| 488 } | 488 } |
| 489 | 489 |
| 490 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 490 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
| 491 return gif_error("Scaling not supported.\n", kInvalidScale); | 491 return gif_error("Scaling not supported.\n", kInvalidScale); |
| 492 } | 492 } |
| 493 | 493 |
| 494 // Initialize the swizzler | 494 // Initialize the swizzler |
| 495 if (fFrameIsSubset) { | 495 if (fFrameIsSubset) { |
| 496 // Fill the background | 496 // Fill the background |
| 497 SkSampler::Fill(dstInfo, dst, dstRowBytes, this->getFillValue(dstInfo.co
lorType()), | 497 SkSampler::Fill(dstInfo, dst, dstRowBytes, this->getFillValue(dstInfo), |
| 498 opts.fZeroInitialized); | 498 opts.fZeroInitialized); |
| 499 } | 499 } |
| 500 | 500 |
| 501 // Iterate over rows of the input | 501 // Iterate over rows of the input |
| 502 for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) { | 502 for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) { |
| 503 if (!this->readRow()) { | 503 if (!this->readRow()) { |
| 504 *rowsDecoded = y; | 504 *rowsDecoded = y; |
| 505 return gif_error("Could not decode line.\n", kIncompleteInput); | 505 return gif_error("Could not decode line.\n", kIncompleteInput); |
| 506 } | 506 } |
| 507 void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanlin
e(y)); | 507 void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanlin
e(y)); |
| 508 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); | 508 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); |
| 509 } | 509 } |
| 510 return kSuccess; | 510 return kSuccess; |
| 511 } | 511 } |
| 512 | 512 |
| 513 // FIXME: This is similar to the implementation for bmp and png. Can we share m
ore code or | 513 // FIXME: This is similar to the implementation for bmp and png. Can we share m
ore code or |
| 514 // possibly make this non-virtual? | 514 // possibly make this non-virtual? |
| 515 uint32_t SkGifCodec::onGetFillValue(SkColorType colorType) const { | 515 uint64_t SkGifCodec::onGetFillValue(const SkImageInfo& dstInfo) const { |
| 516 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 516 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 517 return get_color_table_fill_value(colorType, colorPtr, fFillIndex); | 517 return get_color_table_fill_value(dstInfo.colorType(), dstInfo.alphaType(),
colorPtr, |
| 518 fFillIndex, nullptr); |
| 518 } | 519 } |
| 519 | 520 |
| 520 SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, | 521 SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
| 521 const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColor
Count) { | 522 const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColor
Count) { |
| 522 return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, opts); | 523 return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, opts); |
| 523 } | 524 } |
| 524 | 525 |
| 525 void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsI
nFrame) { | 526 void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsI
nFrame) { |
| 526 if (fFrameIsSubset) { | 527 if (fFrameIsSubset) { |
| 527 const int currRow = this->currScanline(); | 528 const int currRow = this->currScanline(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 548 } | 549 } |
| 549 | 550 |
| 550 int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { | 551 int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
| 551 int rowsBeforeFrame; | 552 int rowsBeforeFrame; |
| 552 int rowsInFrame; | 553 int rowsInFrame; |
| 553 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame); | 554 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame); |
| 554 | 555 |
| 555 if (fFrameIsSubset) { | 556 if (fFrameIsSubset) { |
| 556 // Fill the requested rows | 557 // Fill the requested rows |
| 557 SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), c
ount); | 558 SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), c
ount); |
| 558 uint32_t fillValue = this->onGetFillValue(this->dstInfo().colorType()); | 559 uint64_t fillValue = this->onGetFillValue(this->dstInfo()); |
| 559 fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZer
oInitialized); | 560 fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZer
oInitialized); |
| 560 | 561 |
| 561 // Start to write pixels at the start of the image frame | 562 // Start to write pixels at the start of the image frame |
| 562 dst = SkTAddOffset<void>(dst, rowBytes * rowsBeforeFrame); | 563 dst = SkTAddOffset<void>(dst, rowBytes * rowsBeforeFrame); |
| 563 } | 564 } |
| 564 | 565 |
| 565 for (int i = 0; i < rowsInFrame; i++) { | 566 for (int i = 0; i < rowsInFrame; i++) { |
| 566 if (!this->readRow()) { | 567 if (!this->readRow()) { |
| 567 return i + rowsBeforeFrame; | 568 return i + rowsBeforeFrame; |
| 568 } | 569 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 597 int SkGifCodec::onOutputScanline(int inputScanline) const { | 598 int SkGifCodec::onOutputScanline(int inputScanline) const { |
| 598 if (fGif->Image.Interlace) { | 599 if (fGif->Image.Interlace) { |
| 599 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { | 600 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott
om()) { |
| 600 return inputScanline; | 601 return inputScanline; |
| 601 } | 602 } |
| 602 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + | 603 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram
eRect.height()) + |
| 603 fFrameRect.top(); | 604 fFrameRect.top(); |
| 604 } | 605 } |
| 605 return inputScanline; | 606 return inputScanline; |
| 606 } | 607 } |
| OLD | NEW |