Chromium Code Reviews| Index: src/codec/SkCodecPriv.h |
| diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h |
| index 2596787b9b7aadcf44819e23849467b137c48cc7..450457f630137c98b854be9f2ad8ad963f8c71d0 100644 |
| --- a/src/codec/SkCodecPriv.h |
| +++ b/src/codec/SkCodecPriv.h |
| @@ -53,6 +53,35 @@ static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { |
| } |
| /* |
| + * Most of our codecs support the same conversions: |
| + * - profileType must be the same |
| + * - opaque only to opaque (and 565 only if opaque) |
| + * - premul to unpremul and vice versa |
| + * - always support N32 |
| + * - otherwise match the src color type |
| + */ |
| +static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) { |
|
scroggo_chromium
2015/08/10 17:26:16
This function is a simplified version of the metho
msarett
2015/08/10 17:44:24
Nice! This is a big improvement.
|
| + if (dst.profileType() != src.profileType()) { |
| + return false; |
| + } |
| + |
| + // Ensure the alpha type is valid |
| + if (!valid_alpha(dst.alphaType(), src.alphaType())) { |
| + return false; |
| + } |
| + |
| + // Check for supported color types |
| + switch (dst.colorType()) { |
| + case kN32_SkColorType: |
| + return true; |
| + case kRGB_565_SkColorType: |
|
scroggo_chromium
2015/08/10 17:26:16
This part is different - I've added support for 56
|
| + return src.alphaType() == kOpaque_SkAlphaType; |
| + default: |
| + return dst.colorType() == src.colorType(); |
|
scroggo_chromium
2015/08/10 17:26:16
Some versions of conversion_possible checked speci
|
| + } |
| +} |
| + |
| +/* |
| * If there is a color table, get a pointer to the colors, otherwise return NULL |
| */ |
| static const SkPMColor* get_color_ptr(SkColorTable* colorTable) { |