msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkBmpStandardCodec.h" |
| 9 | #include "SkCodecPriv.h" |
| 10 | #include "SkColorPriv.h" |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 11 | #include "SkStream.h" |
| 12 | |
| 13 | /* |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 14 | * Creates an instance of the decoder |
| 15 | * Called only by NewFromStream |
| 16 | */ |
msarett | c30c418 | 2016-04-20 11:53:35 -0700 | [diff] [blame] | 17 | SkBmpStandardCodec::SkBmpStandardCodec(int width, int height, const SkEncodedInfo& info, |
| 18 | SkStream* stream, uint16_t bitsPerPixel, uint32_t numColors, |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 19 | uint32_t bytesPerColor, uint32_t offset, |
msarett | f4004f9 | 2016-02-11 10:49:31 -0800 | [diff] [blame] | 20 | SkCodec::SkScanlineOrder rowOrder, |
| 21 | bool isOpaque, bool inIco) |
msarett | c30c418 | 2016-04-20 11:53:35 -0700 | [diff] [blame] | 22 | : INHERITED(width, height, info, stream, bitsPerPixel, rowOrder) |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 23 | , fColorTable(nullptr) |
benjaminwagner | 886e5e4 | 2015-12-04 08:48:26 -0800 | [diff] [blame] | 24 | , fNumColors(numColors) |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 25 | , fBytesPerColor(bytesPerColor) |
| 26 | , fOffset(offset) |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 27 | , fSwizzler(nullptr) |
msarett | 9b9497e | 2016-02-11 13:29:36 -0800 | [diff] [blame] | 28 | , fSrcBuffer(new uint8_t [this->srcRowBytes()]) |
msarett | f4004f9 | 2016-02-11 10:49:31 -0800 | [diff] [blame] | 29 | , fIsOpaque(isOpaque) |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 30 | , fInIco(inIco) |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 31 | , fAndMaskRowBytes(fInIco ? SkAlign4(compute_row_bytes(this->getInfo().width(), 1)) : 0) |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 32 | {} |
| 33 | |
| 34 | /* |
| 35 | * Initiates the bitmap decode |
| 36 | */ |
| 37 | SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, |
| 38 | void* dst, size_t dstRowBytes, |
| 39 | const Options& opts, |
| 40 | SkPMColor* inputColorPtr, |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 41 | int* inputColorCount, |
| 42 | int* rowsDecoded) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 43 | if (opts.fSubset) { |
| 44 | // Subsets are not supported. |
| 45 | return kUnimplemented; |
| 46 | } |
| 47 | if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
| 48 | SkCodecPrintf("Error: scaling not supported.\n"); |
| 49 | return kInvalidScale; |
| 50 | } |
| 51 | if (!conversion_possible(dstInfo, this->getInfo())) { |
| 52 | SkCodecPrintf("Error: cannot convert input type to output type.\n"); |
| 53 | return kInvalidConversion; |
| 54 | } |
| 55 | |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 56 | Result result = this->prepareToDecode(dstInfo, opts, inputColorPtr, inputColorCount); |
| 57 | if (kSuccess != result) { |
| 58 | return result; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 59 | } |
msarett | f724b99 | 2015-10-15 06:41:06 -0700 | [diff] [blame] | 60 | int rows = this->decodeRows(dstInfo, dst, dstRowBytes, opts); |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 61 | if (rows != dstInfo.height()) { |
| 62 | *rowsDecoded = rows; |
| 63 | return kIncompleteInput; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 64 | } |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 65 | return kSuccess; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Process the color table for the bmp input |
| 70 | */ |
msarett | 34e0ec4 | 2016-04-22 16:27:24 -0700 | [diff] [blame] | 71 | bool SkBmpStandardCodec::createColorTable(SkColorType dstColorType, SkAlphaType dstAlphaType, |
| 72 | int* numColors) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 73 | // Allocate memory for color table |
| 74 | uint32_t colorBytes = 0; |
| 75 | SkPMColor colorTable[256]; |
| 76 | if (this->bitsPerPixel() <= 8) { |
| 77 | // Inform the caller of the number of colors |
| 78 | uint32_t maxColors = 1 << this->bitsPerPixel(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 79 | if (nullptr != numColors) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 80 | // We set the number of colors to maxColors in order to ensure |
| 81 | // safe memory accesses. Otherwise, an invalid pixel could |
| 82 | // access memory outside of our color table array. |
| 83 | *numColors = maxColors; |
| 84 | } |
benjaminwagner | 886e5e4 | 2015-12-04 08:48:26 -0800 | [diff] [blame] | 85 | // Don't bother reading more than maxColors. |
| 86 | const uint32_t numColorsToRead = |
| 87 | fNumColors == 0 ? maxColors : SkTMin(fNumColors, maxColors); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 88 | |
| 89 | // Read the color table from the stream |
benjaminwagner | 886e5e4 | 2015-12-04 08:48:26 -0800 | [diff] [blame] | 90 | colorBytes = numColorsToRead * fBytesPerColor; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 91 | SkAutoTDeleteArray<uint8_t> cBuffer(new uint8_t[colorBytes]); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 92 | if (stream()->read(cBuffer.get(), colorBytes) != colorBytes) { |
| 93 | SkCodecPrintf("Error: unable to read color table.\n"); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | // Choose the proper packing function |
msarett | 34e0ec4 | 2016-04-22 16:27:24 -0700 | [diff] [blame] | 98 | bool isPremul = (kPremul_SkAlphaType == dstAlphaType) && !fIsOpaque; |
| 99 | PackColorProc packARGB = choose_pack_color_proc(isPremul, dstColorType); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 100 | |
| 101 | // Fill in the color table |
| 102 | uint32_t i = 0; |
benjaminwagner | 886e5e4 | 2015-12-04 08:48:26 -0800 | [diff] [blame] | 103 | for (; i < numColorsToRead; i++) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 104 | uint8_t blue = get_byte(cBuffer.get(), i*fBytesPerColor); |
| 105 | uint8_t green = get_byte(cBuffer.get(), i*fBytesPerColor + 1); |
| 106 | uint8_t red = get_byte(cBuffer.get(), i*fBytesPerColor + 2); |
| 107 | uint8_t alpha; |
msarett | f4004f9 | 2016-02-11 10:49:31 -0800 | [diff] [blame] | 108 | if (fIsOpaque) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 109 | alpha = 0xFF; |
| 110 | } else { |
| 111 | alpha = get_byte(cBuffer.get(), i*fBytesPerColor + 3); |
| 112 | } |
| 113 | colorTable[i] = packARGB(alpha, red, green, blue); |
| 114 | } |
| 115 | |
| 116 | // To avoid segmentation faults on bad pixel data, fill the end of the |
| 117 | // color table with black. This is the same the behavior as the |
| 118 | // chromium decoder. |
| 119 | for (; i < maxColors; i++) { |
| 120 | colorTable[i] = SkPackARGB32NoCheck(0xFF, 0, 0, 0); |
| 121 | } |
| 122 | |
| 123 | // Set the color table |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 124 | fColorTable.reset(new SkColorTable(colorTable, maxColors)); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | // Bmp-in-Ico files do not use an offset to indicate where the pixel data |
| 128 | // begins. Pixel data always begins immediately after the color table. |
| 129 | if (!fInIco) { |
| 130 | // Check that we have not read past the pixel array offset |
| 131 | if(fOffset < colorBytes) { |
| 132 | // This may occur on OS 2.1 and other old versions where the color |
| 133 | // table defaults to max size, and the bmp tries to use a smaller |
| 134 | // color table. This is invalid, and our decision is to indicate |
| 135 | // an error, rather than try to guess the intended size of the |
| 136 | // color table. |
| 137 | SkCodecPrintf("Error: pixel data offset less than color table size.\n"); |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | // After reading the color table, skip to the start of the pixel array |
| 142 | if (stream()->skip(fOffset - colorBytes) != fOffset - colorBytes) { |
| 143 | SkCodecPrintf("Error: unable to skip to image data.\n"); |
| 144 | return false; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Return true on success |
| 149 | return true; |
| 150 | } |
| 151 | |
msarett | b30d698 | 2016-02-15 10:18:45 -0800 | [diff] [blame] | 152 | void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) { |
msarett | 3e375b0 | 2016-05-04 13:03:48 -0700 | [diff] [blame] | 153 | // In the case of bmp-in-icos, we will report BGRA to the client, |
| 154 | // since we may be required to apply an alpha mask after the decode. |
| 155 | // However, the swizzler needs to know the actual format of the bmp. |
msarett | a45a668 | 2016-04-22 13:18:37 -0700 | [diff] [blame] | 156 | SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); |
msarett | 3e375b0 | 2016-05-04 13:03:48 -0700 | [diff] [blame] | 157 | if (fInIco) { |
| 158 | if (this->bitsPerPixel() <= 8) { |
| 159 | swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, |
| 160 | swizzlerInfo.alpha(), this->bitsPerPixel()); |
| 161 | } else if (this->bitsPerPixel() == 24) { |
| 162 | swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kBGR_Color, |
| 163 | SkEncodedInfo::kOpaque_Alpha, 8); |
| 164 | } |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | // Get a pointer to the color table if it exists |
| 168 | const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 169 | |
| 170 | // Create swizzler |
msarett | a45a668 | 2016-04-22 13:18:37 -0700 | [diff] [blame] | 171 | fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo, opts)); |
msarett | b30d698 | 2016-02-15 10:18:45 -0800 | [diff] [blame] | 172 | SkASSERT(fSwizzler); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 173 | } |
| 174 | |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 175 | SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, |
| 176 | const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { |
| 177 | // Create the color table if necessary and prepare the stream for decode |
| 178 | // Note that if it is non-NULL, inputColorCount will be modified |
msarett | 34e0ec4 | 2016-04-22 16:27:24 -0700 | [diff] [blame] | 179 | if (!this->createColorTable(dstInfo.colorType(), dstInfo.alphaType(), inputColorCount)) { |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 180 | SkCodecPrintf("Error: could not create color table.\n"); |
| 181 | return SkCodec::kInvalidInput; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 182 | } |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 183 | |
| 184 | // Copy the color table to the client if necessary |
| 185 | copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount); |
| 186 | |
msarett | b30d698 | 2016-02-15 10:18:45 -0800 | [diff] [blame] | 187 | // Initialize a swizzler |
| 188 | this->initializeSwizzler(dstInfo, options); |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 189 | return SkCodec::kSuccess; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /* |
| 193 | * Performs the bitmap decoding for standard input format |
| 194 | */ |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 195 | int SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, |
| 196 | const Options& opts) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 197 | // Iterate over rows of the image |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 198 | const int height = dstInfo.height(); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 199 | for (int y = 0; y < height; y++) { |
| 200 | // Read a row of the input |
msarett | 9b9497e | 2016-02-11 13:29:36 -0800 | [diff] [blame] | 201 | if (this->stream()->read(fSrcBuffer.get(), this->srcRowBytes()) != this->srcRowBytes()) { |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 202 | SkCodecPrintf("Warning: incomplete input stream.\n"); |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 203 | return y; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | // Decode the row in destination format |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 207 | uint32_t row = this->getDstRow(y, dstInfo.height()); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 208 | |
| 209 | void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); |
| 210 | fSwizzler->swizzle(dstRow, fSrcBuffer.get()); |
| 211 | } |
| 212 | |
msarett | 1088db9 | 2016-03-22 08:58:35 -0700 | [diff] [blame] | 213 | if (fInIco && fIsOpaque) { |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 214 | const int startScanline = this->currScanline(); |
| 215 | if (startScanline < 0) { |
| 216 | // We are not performing a scanline decode. |
| 217 | // Just decode the entire ICO mask and return. |
| 218 | decodeIcoMask(this->stream(), dstInfo, dst, dstRowBytes); |
| 219 | return height; |
| 220 | } |
| 221 | |
| 222 | // In order to perform a scanline ICO decode, we must be able |
| 223 | // to skip ahead in the stream in order to apply the AND mask |
| 224 | // to the requested scanlines. |
| 225 | // We will do this by taking advantage of the fact that |
| 226 | // SkIcoCodec always uses a SkMemoryStream as its underlying |
| 227 | // representation of the stream. |
| 228 | const void* memoryBase = this->stream()->getMemoryBase(); |
| 229 | SkASSERT(nullptr != memoryBase); |
| 230 | SkASSERT(this->stream()->hasLength()); |
| 231 | SkASSERT(this->stream()->hasPosition()); |
| 232 | |
| 233 | const size_t length = this->stream()->getLength(); |
| 234 | const size_t currPosition = this->stream()->getPosition(); |
| 235 | |
| 236 | // Calculate how many bytes we must skip to reach the AND mask. |
| 237 | const int remainingScanlines = this->getInfo().height() - startScanline - height; |
msarett | 9b9497e | 2016-02-11 13:29:36 -0800 | [diff] [blame] | 238 | const size_t bytesToSkip = remainingScanlines * this->srcRowBytes() + |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 239 | startScanline * fAndMaskRowBytes; |
| 240 | const size_t subStreamStartPosition = currPosition + bytesToSkip; |
| 241 | if (subStreamStartPosition >= length) { |
| 242 | // FIXME: How can we indicate that this decode was actually incomplete? |
| 243 | return height; |
| 244 | } |
| 245 | |
| 246 | // Create a subStream to pass to decodeIcoMask(). It is useful to encapsulate |
| 247 | // the memory base into a stream in order to safely handle incomplete images |
| 248 | // without reading out of bounds memory. |
| 249 | const void* subStreamMemoryBase = SkTAddOffset<const void>(memoryBase, |
| 250 | subStreamStartPosition); |
| 251 | const size_t subStreamLength = length - subStreamStartPosition; |
| 252 | // This call does not transfer ownership of the subStreamMemoryBase. |
| 253 | SkMemoryStream subStream(subStreamMemoryBase, subStreamLength, false); |
| 254 | |
| 255 | // FIXME: If decodeIcoMask does not succeed, is there a way that we can |
| 256 | // indicate the decode was incomplete? |
| 257 | decodeIcoMask(&subStream, dstInfo, dst, dstRowBytes); |
| 258 | } |
| 259 | |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 260 | return height; |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 261 | } |
scroggo | cc2feb1 | 2015-08-14 08:32:46 -0700 | [diff] [blame] | 262 | |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 263 | void SkBmpStandardCodec::decodeIcoMask(SkStream* stream, const SkImageInfo& dstInfo, |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 264 | void* dst, size_t dstRowBytes) { |
| 265 | // BMP in ICO have transparency, so this cannot be 565, and this mask |
| 266 | // prevents us from using kIndex8. The below code depends on the output |
| 267 | // being an SkPMColor. |
msarett | 34e0ec4 | 2016-04-22 16:27:24 -0700 | [diff] [blame] | 268 | SkASSERT(kRGBA_8888_SkColorType == dstInfo.colorType() || |
| 269 | kBGRA_8888_SkColorType == dstInfo.colorType()); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 270 | |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 271 | // If we are sampling, make sure that we only mask the sampled pixels. |
| 272 | // We do not need to worry about sampling in the y-dimension because that |
| 273 | // should be handled by SkSampledCodec. |
| 274 | const int sampleX = fSwizzler->sampleX(); |
| 275 | const int sampledWidth = get_scaled_dimension(this->getInfo().width(), sampleX); |
| 276 | const int srcStartX = get_start_coord(sampleX); |
| 277 | |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 278 | |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 279 | SkPMColor* dstPtr = (SkPMColor*) dst; |
| 280 | for (int y = 0; y < dstInfo.height(); y++) { |
| 281 | // The srcBuffer will at least be large enough |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 282 | if (stream->read(fSrcBuffer.get(), fAndMaskRowBytes) != fAndMaskRowBytes) { |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 283 | SkCodecPrintf("Warning: incomplete AND mask for bmp-in-ico.\n"); |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 284 | return; |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 285 | } |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 286 | |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 287 | int row = this->getDstRow(y, dstInfo.height()); |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 288 | |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 289 | SkPMColor* dstRow = |
| 290 | SkTAddOffset<SkPMColor>(dstPtr, row * dstRowBytes); |
| 291 | |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 292 | int srcX = srcStartX; |
| 293 | for (int dstX = 0; dstX < sampledWidth; dstX++) { |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 294 | int quotient; |
| 295 | int modulus; |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 296 | SkTDivMod(srcX, 8, "ient, &modulus); |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 297 | uint32_t shift = 7 - modulus; |
msarett | be8216a | 2015-12-04 08:00:50 -0800 | [diff] [blame] | 298 | uint32_t alphaBit = (fSrcBuffer.get()[quotient] >> shift) & 0x1; |
| 299 | dstRow[dstX] &= alphaBit - 1; |
| 300 | srcX += sampleX; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 301 | } |
| 302 | } |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 303 | } |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 304 | |
scroggo | c5560be | 2016-02-03 09:42:42 -0800 | [diff] [blame] | 305 | uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 306 | const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 307 | if (colorPtr) { |
| 308 | return get_color_table_fill_value(colorType, colorPtr, 0); |
| 309 | } |
scroggo | c5560be | 2016-02-03 09:42:42 -0800 | [diff] [blame] | 310 | return INHERITED::onGetFillValue(colorType); |
msarett | e6dd004 | 2015-10-09 11:07:34 -0700 | [diff] [blame] | 311 | } |