Chromium Code Reviews| Index: src/codec/SkCodec_libgif.cpp |
| diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp |
| index 03107aba2ee80d824676b8e92f8f80720575ba6f..f42f1152b79a7d47f7ad884c943be43d6d5c8730 100644 |
| --- a/src/codec/SkCodec_libgif.cpp |
| +++ b/src/codec/SkCodec_libgif.cpp |
| @@ -436,12 +436,18 @@ SkCodec::Result SkGifCodec::prepareToDecode(const SkImageInfo& dstInfo, SkPMColo |
| // Initialize color table and copy to the client if necessary |
| this->initializeColorTable(dstInfo, inputColorPtr, inputColorCount); |
| - return kSuccess; |
| + |
| + return this->initializeSwizzler(dstInfo, opts); |
| } |
| SkCodec::Result SkGifCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) { |
| const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| - fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, colorPtr, dstInfo, opts)); |
| + if (fFrameIsSubset) { |
|
msarett
2015/11/16 23:20:58
This is a just a refactor to share some more code.
scroggo
2015/11/17 14:56:26
+1
What do you think about creating a pointer loc
msarett
2015/11/17 18:00:50
sgtm
|
| + fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, colorPtr, dstInfo, opts, |
| + &fFrameRect)); |
| + } else { |
| + fSwizzler.reset(SkSwizzler::CreateSwizzler(SkSwizzler::kIndex, colorPtr, dstInfo, opts)); |
| + } |
| if (nullptr != fSwizzler.get()) { |
| return kSuccess; |
| } |
| @@ -472,29 +478,14 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo, |
| // Initialize the swizzler |
| if (fFrameIsSubset) { |
| - const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height()); |
| - if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts)) { |
| - return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
| - } |
| - |
| // Fill the background |
| SkSampler::Fill(dstInfo, dst, dstRowBytes, |
| this->getFillValue(dstInfo.colorType(), dstInfo.alphaType()), |
| opts.fZeroInitialized); |
| - |
| - // Modify the dst pointer |
| - const int32_t dstBytesPerPixel = SkColorTypeBytesPerPixel(dstInfo.colorType()); |
| - dst = SkTAddOffset<void*>(dst, dstRowBytes * fFrameRect.top() + |
| - dstBytesPerPixel * fFrameRect.left()); |
| - } else { |
| - if (kSuccess != this->initializeSwizzler(dstInfo, opts)) { |
| - return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
| - } |
| } |
| // Iterate over rows of the input |
| - uint32_t height = fFrameRect.height(); |
| - for (uint32_t y = 0; y < height; y++) { |
| + for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) { |
|
msarett
2015/11/16 23:20:58
Bug fix, so outputScanline(y) gives us the right a
|
| if (!this->readRow()) { |
| *rowsDecoded = y; |
| return gif_error("Could not decode line.\n", kIncompleteInput); |
| @@ -514,25 +505,7 @@ uint32_t SkGifCodec::onGetFillValue(SkColorType colorType, SkAlphaType alphaType |
| SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
| const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColorCount) { |
| - |
| - Result result = this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->options()); |
| - if (kSuccess != result) { |
| - return result; |
| - } |
| - |
| - // Initialize the swizzler |
| - if (fFrameIsSubset) { |
| - const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height()); |
| - if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts)) { |
| - return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
| - } |
| - } else { |
| - if (kSuccess != this->initializeSwizzler(dstInfo, opts)) { |
| - return gif_error("Could not initialize swizzler.\n", kUnimplemented); |
| - } |
| - } |
| - |
| - return kSuccess; |
| + return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->options()); |
| } |
| int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
| @@ -544,7 +517,7 @@ int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
| SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), count); |
| uint32_t fillValue = this->onGetFillValue(this->dstInfo().colorType(), |
| this->dstInfo().alphaType()); |
| - SkSampler::Fill(fillInfo, dst, rowBytes, fillValue, this->options().fZeroInitialized); |
| + fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZeroInitialized); |
| // Do nothing for rows before the image frame |
| rowsBeforeFrame = SkTMax(0, fFrameRect.top() - this->INHERITED::nextScanline()); |
| @@ -555,10 +528,6 @@ int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
| rowsAfterFrame = SkTMax(0, |
| this->INHERITED::nextScanline() + rowsInFrame - fFrameRect.bottom()); |
| rowsInFrame = SkTMax(0, rowsInFrame - rowsAfterFrame); |
| - |
|
msarett
2015/11/16 23:20:58
We handle this inside the swizzler now. If we try
|
| - // Adjust dst pointer for left offset |
| - int offset = SkColorTypeBytesPerPixel(this->dstInfo().colorType()) * fFrameRect.left(); |
| - dst = SkTAddOffset<void>(dst, offset); |
| } |
| for (int i = 0; i < rowsInFrame; i++) { |
| @@ -584,7 +553,8 @@ int SkGifCodec::onOutputScanline(int inputScanline) const { |
| if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bottom()) { |
| return inputScanline; |
| } |
| - return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFrameRect.height()); |
| + return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFrameRect.height()) + |
| + fFrameRect.top(); |
|
msarett
2015/11/16 23:20:58
Bug fix.
|
| } |
| return inputScanline; |
| } |