| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Return false on edge cases | 68 // Return false on edge cases |
| 69 if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaled
Dim) { | 69 if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaled
Dim) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Every sampleFactor rows are necessary | 73 // Every sampleFactor rows are necessary |
| 74 return ((srcCoord - startCoord) % sampleFactor) == 0; | 74 return ((srcCoord - startCoord) % sampleFactor) == 0; |
| 75 } | 75 } |
| 76 | 76 |
| 77 inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { | 77 inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) { |
| 78 // Check for supported alpha types | 78 if (kUnknown_SkAlphaType == dstAlpha) { |
| 79 return false; |
| 80 } |
| 81 |
| 79 if (srcAlpha != dstAlpha) { | 82 if (srcAlpha != dstAlpha) { |
| 80 if (kOpaque_SkAlphaType == srcAlpha) { | 83 if (kOpaque_SkAlphaType == srcAlpha) { |
| 81 // If the source is opaque, we must decode to opaque | 84 // If the source is opaque, we can support any. |
| 82 return false; | 85 return true; |
| 83 } | 86 } |
| 84 | 87 |
| 85 // The source is not opaque | 88 // The source is not opaque |
| 86 switch (dstAlpha) { | 89 switch (dstAlpha) { |
| 87 case kPremul_SkAlphaType: | 90 case kPremul_SkAlphaType: |
| 88 case kUnpremul_SkAlphaType: | 91 case kUnpremul_SkAlphaType: |
| 89 // The source is not opaque, so either of these is okay | 92 // The source is not opaque, so either of these is okay |
| 90 break; | 93 break; |
| 91 default: | 94 default: |
| 92 // We cannot decode a non-opaque image to opaque (or unknown) | 95 // We cannot decode a non-opaque image to opaque (or unknown) |
| 93 return false; | 96 return false; |
| 94 } | 97 } |
| 95 } | 98 } |
| 96 return true; | 99 return true; |
| 97 } | 100 } |
| 98 | 101 |
| 99 /* | 102 /* |
| 100 * Most of our codecs support the same conversions: | 103 * Most of our codecs support the same conversions: |
| 101 * - profileType must be the same | 104 * - profileType must be the same |
| 102 * - opaque only to opaque (and 565 only if opaque) | 105 * - opaque to any alpha type |
| 106 * - 565 only if opaque |
| 103 * - premul to unpremul and vice versa | 107 * - premul to unpremul and vice versa |
| 104 * - always support N32 | 108 * - always support N32 |
| 105 * - otherwise match the src color type | 109 * - otherwise match the src color type |
| 106 */ | 110 */ |
| 107 inline bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
{ | 111 inline bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src)
{ |
| 108 if (dst.profileType() != src.profileType()) { | 112 if (dst.profileType() != src.profileType()) { |
| 109 return false; | 113 return false; |
| 110 } | 114 } |
| 111 | 115 |
| 112 // Ensure the alpha type is valid | 116 // Ensure the alpha type is valid |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 #endif | 234 #endif |
| 231 } | 235 } |
| 232 | 236 |
| 233 #ifdef SK_PRINT_CODEC_MESSAGES | 237 #ifdef SK_PRINT_CODEC_MESSAGES |
| 234 #define SkCodecPrintf SkDebugf | 238 #define SkCodecPrintf SkDebugf |
| 235 #else | 239 #else |
| 236 #define SkCodecPrintf(...) | 240 #define SkCodecPrintf(...) |
| 237 #endif | 241 #endif |
| 238 | 242 |
| 239 #endif // SkCodecPriv_DEFINED | 243 #endif // SkCodecPriv_DEFINED |
| OLD | NEW |