OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
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 #ifndef SkCodecPriv_DEFINED | 8 #ifndef SkCodecPriv_DEFINED |
9 #define SkCodecPriv_DEFINED | 9 #define SkCodecPriv_DEFINED |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define UPDATE_RESULT_ALPHA(alpha) \ | 26 #define UPDATE_RESULT_ALPHA(alpha) \ |
27 zeroAlpha |= (alpha); \ | 27 zeroAlpha |= (alpha); \ |
28 maxAlpha &= (alpha); | 28 maxAlpha &= (alpha); |
29 | 29 |
30 #define COMPUTE_RESULT_ALPHA \ | 30 #define COMPUTE_RESULT_ALPHA \ |
31 SkSwizzler::GetResult(zeroAlpha, maxAlpha); | 31 SkSwizzler::GetResult(zeroAlpha, maxAlpha); |
32 | 32 |
33 static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { | 33 static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { |
34 // Check for supported alpha types | 34 // Check for supported alpha types |
35 if (srcAlpha != dstAlpha) { | 35 if (srcAlpha != dstAlpha) { |
36 if (kOpaque_SkAlphaType == srcAlpha) { | 36 if (kOpaque_SkAlphaType == dstAlpha) { |
37 // If the source is opaque, we must decode to opaque | |
38 return false; | 37 return false; |
39 } | 38 } |
40 | 39 |
41 // The source is not opaque | |
42 switch (dstAlpha) { | 40 switch (dstAlpha) { |
| 41 case kOpaque_SkAlphaType: |
| 42 // If the source is not opaque, we cannot decode to opaque |
| 43 return false; |
43 case kPremul_SkAlphaType: | 44 case kPremul_SkAlphaType: |
44 case kUnpremul_SkAlphaType: | 45 case kUnpremul_SkAlphaType: |
45 // The source is not opaque, so either of these is okay | 46 // Opaque can trivially be treated as both, so no conversion is |
| 47 // actually necessary. |
| 48 // Switching between premul and unpremul is supported. |
46 break; | 49 break; |
47 default: | 50 default: |
48 // We cannot decode a non-opaque image to opaque (or unknown) | 51 // We cannot decode a non-opaque image to opaque (or unknown |
49 return false; | 52 return false; |
50 } | 53 } |
51 } | 54 } |
52 return true; | 55 return true; |
53 } | 56 } |
54 | 57 |
55 /* | 58 /* |
56 * If there is a color table, get a pointer to the colors, otherwise return NULL | 59 * If there is a color table, get a pointer to the colors, otherwise return NULL |
57 */ | 60 */ |
58 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { | 61 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 #endif | 141 #endif |
139 } | 142 } |
140 | 143 |
141 #ifdef SK_PRINT_CODEC_MESSAGES | 144 #ifdef SK_PRINT_CODEC_MESSAGES |
142 #define SkCodecPrintf SkDebugf | 145 #define SkCodecPrintf SkDebugf |
143 #else | 146 #else |
144 #define SkCodecPrintf(...) | 147 #define SkCodecPrintf(...) |
145 #endif | 148 #endif |
146 | 149 |
147 #endif // SkCodecPriv_DEFINED | 150 #endif // SkCodecPriv_DEFINED |
OLD | NEW |