| 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 "SkBmpMaskCodec.h" | 8 #include "SkBmpMaskCodec.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 | 11 |
| 12 /* | 12 /* |
| 13 * Creates an instance of the decoder | 13 * Creates an instance of the decoder |
| 14 */ | 14 */ |
| 15 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, | 15 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, |
| 16 uint16_t bitsPerPixel, SkMasks* masks, | 16 uint16_t bitsPerPixel, SkMasks* masks, |
| 17 SkCodec::SkScanlineOrder rowOrder) | 17 SkCodec::SkScanlineOrder rowOrder) |
| 18 : INHERITED(info, stream, bitsPerPixel, rowOrder) | 18 : INHERITED(info, stream, bitsPerPixel, rowOrder) |
| 19 , fMasks(masks) | 19 , fMasks(masks) |
| 20 , fMaskSwizzler(nullptr) | 20 , fMaskSwizzler(nullptr) |
| 21 , fSrcRowBytes(SkAlign4(compute_row_bytes(this->getInfo().width(), this->bit
sPerPixel()))) | 21 , fSrcBuffer(new uint8_t [this->srcRowBytes()]) |
| 22 , fSrcBuffer(new uint8_t [fSrcRowBytes]) | |
| 23 {} | 22 {} |
| 24 | 23 |
| 25 /* | 24 /* |
| 26 * Initiates the bitmap decode | 25 * Initiates the bitmap decode |
| 27 */ | 26 */ |
| 28 SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo, | 27 SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo, |
| 29 void* dst, size_t dstRowBytes, | 28 void* dst, size_t dstRowBytes, |
| 30 const Options& opts, | 29 const Options& opts, |
| 31 SkPMColor* inputColorPtr, | 30 SkPMColor* inputColorPtr, |
| 32 int* inputColorCount, | 31 int* inputColorCount, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 * Performs the decoding | 84 * Performs the decoding |
| 86 */ | 85 */ |
| 87 int SkBmpMaskCodec::decodeRows(const SkImageInfo& dstInfo, | 86 int SkBmpMaskCodec::decodeRows(const SkImageInfo& dstInfo, |
| 88 void* dst, size_t dstRowBytes, | 87 void* dst, size_t dstRowBytes, |
| 89 const Options& opts) { | 88 const Options& opts) { |
| 90 // Iterate over rows of the image | 89 // Iterate over rows of the image |
| 91 uint8_t* srcRow = fSrcBuffer.get(); | 90 uint8_t* srcRow = fSrcBuffer.get(); |
| 92 const int height = dstInfo.height(); | 91 const int height = dstInfo.height(); |
| 93 for (int y = 0; y < height; y++) { | 92 for (int y = 0; y < height; y++) { |
| 94 // Read a row of the input | 93 // Read a row of the input |
| 95 if (this->stream()->read(srcRow, fSrcRowBytes) != fSrcRowBytes) { | 94 if (this->stream()->read(srcRow, this->srcRowBytes()) != this->srcRowByt
es()) { |
| 96 SkCodecPrintf("Warning: incomplete input stream.\n"); | 95 SkCodecPrintf("Warning: incomplete input stream.\n"); |
| 97 return y; | 96 return y; |
| 98 } | 97 } |
| 99 | 98 |
| 100 // Decode the row in destination format | 99 // Decode the row in destination format |
| 101 uint32_t row = this->getDstRow(y, height); | 100 uint32_t row = this->getDstRow(y, height); |
| 102 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); | 101 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); |
| 103 fMaskSwizzler->swizzle(dstRow, srcRow); | 102 fMaskSwizzler->swizzle(dstRow, srcRow); |
| 104 } | 103 } |
| 105 | 104 |
| 106 // Finished decoding the entire image | 105 // Finished decoding the entire image |
| 107 return height; | 106 return height; |
| 108 } | 107 } |
| OLD | NEW |