| Index: src/codec/SkCodec_wbmp.cpp
|
| diff --git a/src/codec/SkCodec_wbmp.cpp b/src/codec/SkCodec_wbmp.cpp
|
| index d7f446bb5766558eb2f4e5f91f2f99071ec7f740..ba4dc9af8995f2c9093889158a79b3a8990122d5 100644
|
| --- a/src/codec/SkCodec_wbmp.cpp
|
| +++ b/src/codec/SkCodec_wbmp.cpp
|
| @@ -86,11 +86,8 @@ SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info,
|
| opts.fZeroInitialized);
|
| }
|
|
|
| -SkCodec::Result SkWbmpCodec::readRow(uint8_t* row) {
|
| - if (this->stream()->read(row, fSrcRowBytes) != fSrcRowBytes) {
|
| - return kIncompleteInput;
|
| - }
|
| - return kSuccess;
|
| +bool SkWbmpCodec::readRow(uint8_t* row) {
|
| + return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes;
|
| }
|
|
|
| SkWbmpCodec::SkWbmpCodec(const SkImageInfo& info, SkStream* stream)
|
| @@ -109,7 +106,8 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
|
| size_t rowBytes,
|
| const Options& options,
|
| SkPMColor ctable[],
|
| - int* ctableCount) {
|
| + int* ctableCount,
|
| + int* rowsDecoded) {
|
| if (options.fSubset) {
|
| // Subsets are not supported.
|
| return kUnimplemented;
|
| @@ -123,8 +121,8 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
|
| setup_color_table(info.colorType(), ctable, ctableCount);
|
|
|
| // Initialize the swizzler
|
| - SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, options));
|
| - if (nullptr == swizzler.get()) {
|
| + fSwizzler.reset(this->initializeSwizzler(info, ctable, options));
|
| + if (nullptr == fSwizzler.get()) {
|
| return kInvalidConversion;
|
| }
|
|
|
| @@ -133,11 +131,11 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
|
| SkAutoTMalloc<uint8_t> src(fSrcRowBytes);
|
| void* dstRow = dst;
|
| for (int y = 0; y < size.height(); ++y) {
|
| - Result rowResult = this->readRow(src.get());
|
| - if (kSuccess != rowResult) {
|
| - return rowResult;
|
| + if (!this->readRow(src.get())) {
|
| + *rowsDecoded = y;
|
| + return kIncompleteInput;
|
| }
|
| - swizzler->swizzle(dstRow, src.get());
|
| + fSwizzler->swizzle(dstRow, src.get());
|
| dstRow = SkTAddOffset<void>(dstRow, rowBytes);
|
| }
|
| return kSuccess;
|
| @@ -158,17 +156,16 @@ SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) {
|
| return new SkWbmpCodec(info, streamDeleter.detach());
|
| }
|
|
|
| -SkCodec::Result SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
|
| +int SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
|
| void* dstRow = dst;
|
| for (int y = 0; y < count; ++y) {
|
| - Result rowResult = this->readRow(fSrcBuffer.get());
|
| - if (kSuccess != rowResult) {
|
| - return rowResult;
|
| + if (!this->readRow(fSrcBuffer.get())) {
|
| + return y;
|
| }
|
| fSwizzler->swizzle(dstRow, fSrcBuffer.get());
|
| dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
|
| }
|
| - return kSuccess;
|
| + return count;
|
| }
|
|
|
| SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
|
| @@ -201,4 +198,3 @@ SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
|
|
|
| return kSuccess;
|
| }
|
| -
|
|
|