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 35 matching lines...) Loading... |
46 break; | 46 break; |
47 default: | 47 default: |
48 // We cannot decode a non-opaque image to opaque (or unknown) | 48 // We cannot decode a non-opaque image to opaque (or unknown) |
49 return false; | 49 return false; |
50 } | 50 } |
51 } | 51 } |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 /* | 55 /* |
| 56 * Most of our codecs support the same conversions: |
| 57 * - profileType must be the same |
| 58 * - opaque only to opaque (and 565 only if opaque) |
| 59 * - premul to unpremul and vice versa |
| 60 * - always support N32 |
| 61 * - otherwise match the src color type |
| 62 */ |
| 63 static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
{ |
| 64 if (dst.profileType() != src.profileType()) { |
| 65 return false; |
| 66 } |
| 67 |
| 68 // Ensure the alpha type is valid |
| 69 if (!valid_alpha(dst.alphaType(), src.alphaType())) { |
| 70 return false; |
| 71 } |
| 72 |
| 73 // Check for supported color types |
| 74 switch (dst.colorType()) { |
| 75 case kN32_SkColorType: |
| 76 return true; |
| 77 case kRGB_565_SkColorType: |
| 78 return src.alphaType() == kOpaque_SkAlphaType; |
| 79 default: |
| 80 return dst.colorType() == src.colorType(); |
| 81 } |
| 82 } |
| 83 |
| 84 /* |
56 * If there is a color table, get a pointer to the colors, otherwise return NULL | 85 * If there is a color table, get a pointer to the colors, otherwise return NULL |
57 */ | 86 */ |
58 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { | 87 static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { |
59 return NULL != colorTable ? colorTable->readColors() : NULL; | 88 return NULL != colorTable ? colorTable->readColors() : NULL; |
60 } | 89 } |
61 | 90 |
62 /* | 91 /* |
63 * | 92 * |
64 * Copy the codec color table back to the client when kIndex8 color type is requ
ested | 93 * Copy the codec color table back to the client when kIndex8 color type is requ
ested |
65 */ | 94 */ |
(...skipping 72 matching lines...) Loading... |
138 #endif | 167 #endif |
139 } | 168 } |
140 | 169 |
141 #ifdef SK_PRINT_CODEC_MESSAGES | 170 #ifdef SK_PRINT_CODEC_MESSAGES |
142 #define SkCodecPrintf SkDebugf | 171 #define SkCodecPrintf SkDebugf |
143 #else | 172 #else |
144 #define SkCodecPrintf(...) | 173 #define SkCodecPrintf(...) |
145 #endif | 174 #endif |
146 | 175 |
147 #endif // SkCodecPriv_DEFINED | 176 #endif // SkCodecPriv_DEFINED |
OLD | NEW |