| 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 * Checks if the conversion between the input image and the requested output | |
| 14 * image has been implemented | |
| 15 */ | |
| 16 static bool conversion_possible(const SkImageInfo& dst, | |
| 17 const SkImageInfo& src) { | |
| 18 // Ensure that the profile type is unchanged | |
| 19 if (dst.profileType() != src.profileType()) { | |
| 20 return false; | |
| 21 } | |
| 22 | |
| 23 // Ensure the alpha type is valid | |
| 24 if (!valid_alpha(dst.alphaType(), src.alphaType())) { | |
| 25 return false; | |
| 26 } | |
| 27 | |
| 28 // Check for supported color types | |
| 29 switch (dst.colorType()) { | |
| 30 // Allow output to kN32 | |
| 31 case kN32_SkColorType: | |
| 32 return true; | |
| 33 default: | |
| 34 return false; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 | |
| 39 /* | |
| 40 * Creates an instance of the decoder | 13 * Creates an instance of the decoder |
| 41 */ | 14 */ |
| 42 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, | 15 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, |
| 43 uint16_t bitsPerPixel, SkMasks* masks, | 16 uint16_t bitsPerPixel, SkMasks* masks, |
| 44 SkBmpCodec::RowOrder rowOrder) | 17 SkBmpCodec::RowOrder rowOrder) |
| 45 : INHERITED(info, stream, bitsPerPixel, rowOrder) | 18 : INHERITED(info, stream, bitsPerPixel, rowOrder) |
| 46 , fMasks(masks) | 19 , fMasks(masks) |
| 47 , fMaskSwizzler(NULL) | 20 , fMaskSwizzler(NULL) |
| 48 , fSrcBuffer(NULL) | 21 , fSrcBuffer(NULL) |
| 49 {} | 22 {} |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 101 |
| 129 // Decode the row in destination format | 102 // Decode the row in destination format |
| 130 int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height -
1 - y : y; | 103 int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height -
1 - y : y; |
| 131 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); | 104 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); |
| 132 fMaskSwizzler->swizzle(dstRow, srcRow); | 105 fMaskSwizzler->swizzle(dstRow, srcRow); |
| 133 } | 106 } |
| 134 | 107 |
| 135 // Finished decoding the entire image | 108 // Finished decoding the entire image |
| 136 return kSuccess; | 109 return kSuccess; |
| 137 } | 110 } |
| OLD | NEW |