| 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 "SkBmpStandardCodec.h" | 8 #include "SkBmpStandardCodec.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkScanlineDecoder.h" | 11 #include "SkScanlineDecoder.h" |
| 12 #include "SkStream.h" | 12 #include "SkStream.h" |
| 13 | 13 |
| 14 /* | 14 /* |
| 15 * Checks if the conversion between the input image and the requested output | |
| 16 * image has been implemented | |
| 17 */ | |
| 18 static bool conversion_possible(const SkImageInfo& dst, | |
| 19 const SkImageInfo& src) { | |
| 20 // Ensure that the profile type is unchanged | |
| 21 if (dst.profileType() != src.profileType()) { | |
| 22 return false; | |
| 23 } | |
| 24 | |
| 25 // Ensure the alpha type is valid | |
| 26 if (!valid_alpha(dst.alphaType(), src.alphaType())) { | |
| 27 return false; | |
| 28 } | |
| 29 | |
| 30 // Check for supported color types | |
| 31 switch (dst.colorType()) { | |
| 32 // Allow output to kN32 from any type of input | |
| 33 case kN32_SkColorType: | |
| 34 return true; | |
| 35 // Allow output to kIndex_8 from compatible inputs | |
| 36 case kIndex_8_SkColorType: | |
| 37 return kIndex_8_SkColorType == src.colorType(); | |
| 38 default: | |
| 39 return false; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 /* | |
| 44 * Creates an instance of the decoder | 15 * Creates an instance of the decoder |
| 45 * Called only by NewFromStream | 16 * Called only by NewFromStream |
| 46 */ | 17 */ |
| 47 SkBmpStandardCodec::SkBmpStandardCodec(const SkImageInfo& info, SkStream* stream
, | 18 SkBmpStandardCodec::SkBmpStandardCodec(const SkImageInfo& info, SkStream* stream
, |
| 48 uint16_t bitsPerPixel, uint32_t numColors
, | 19 uint16_t bitsPerPixel, uint32_t numColors
, |
| 49 uint32_t bytesPerColor, uint32_t offset, | 20 uint32_t bytesPerColor, uint32_t offset, |
| 50 SkBmpCodec::RowOrder rowOrder, bool inIco
) | 21 SkBmpCodec::RowOrder rowOrder, bool inIco
) |
| 51 : INHERITED(info, stream, bitsPerPixel, rowOrder) | 22 : INHERITED(info, stream, bitsPerPixel, rowOrder) |
| 52 , fColorTable(NULL) | 23 , fColorTable(NULL) |
| 53 , fNumColors(this->computeNumColors(numColors)) | 24 , fNumColors(this->computeNumColors(numColors)) |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 uint32_t alphaBit = | 323 uint32_t alphaBit = |
| 353 (fSrcBuffer.get()[quotient] >> shift) & 0x1; | 324 (fSrcBuffer.get()[quotient] >> shift) & 0x1; |
| 354 dstRow[x] &= alphaBit - 1; | 325 dstRow[x] &= alphaBit - 1; |
| 355 } | 326 } |
| 356 } | 327 } |
| 357 } | 328 } |
| 358 | 329 |
| 359 // Finished decoding the entire image | 330 // Finished decoding the entire image |
| 360 return kSuccess; | 331 return kSuccess; |
| 361 } | 332 } |
| OLD | NEW |