| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
| 9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) | 80 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
| 81 kN32_SkColorType = kBGRA_8888_SkColorType, | 81 kN32_SkColorType = kBGRA_8888_SkColorType, |
| 82 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 82 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
| 83 kN32_SkColorType = kRGBA_8888_SkColorType, | 83 kN32_SkColorType = kRGBA_8888_SkColorType, |
| 84 #else | 84 #else |
| 85 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" | 85 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" |
| 86 #endif | 86 #endif |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 extern const uint8_t gPrivate_SkColorTypeBytesPerPixel[]; |
| 90 |
| 89 static int SkColorTypeBytesPerPixel(SkColorType ct) { | 91 static int SkColorTypeBytesPerPixel(SkColorType ct) { |
| 90 static const uint8_t gSize[] = { | 92 SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType); |
| 91 0, // Unknown | 93 return gPrivate_SkColorTypeBytesPerPixel[ct]; |
| 92 1, // Alpha_8 | |
| 93 2, // RGB_565 | |
| 94 2, // ARGB_4444 | |
| 95 4, // RGBA_8888 | |
| 96 4, // BGRA_8888 | |
| 97 1, // kIndex_8 | |
| 98 1, // kGray_8 | |
| 99 8, // kRGBA_F16 | |
| 100 }; | |
| 101 static_assert(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1), | |
| 102 "size_mismatch_with_SkColorType_enum"); | |
| 103 | |
| 104 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize)); | |
| 105 return gSize[ct]; | |
| 106 } | 94 } |
| 107 | 95 |
| 96 extern const uint8_t gPrivate_SkColorTypeShiftPerPixel[]; |
| 97 |
| 108 static int SkColorTypeShiftPerPixel(SkColorType ct) { | 98 static int SkColorTypeShiftPerPixel(SkColorType ct) { |
| 109 static const uint8_t gShift[] = { | 99 SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType); |
| 110 0, // Unknown | 100 return gPrivate_SkColorTypeShiftPerPixel[ct]; |
| 111 0, // Alpha_8 | |
| 112 1, // RGB_565 | |
| 113 1, // ARGB_4444 | |
| 114 2, // RGBA_8888 | |
| 115 2, // BGRA_8888 | |
| 116 0, // kIndex_8 | |
| 117 0, // kGray_8 | |
| 118 3, // kRGBA_F16 | |
| 119 }; | |
| 120 static_assert(SK_ARRAY_COUNT(gShift) == (size_t)(kLastEnum_SkColorType + 1), | |
| 121 "size_mismatch_with_SkColorType_enum"); | |
| 122 | |
| 123 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gShift)); | |
| 124 return gShift[ct]; | |
| 125 } | 101 } |
| 126 | 102 |
| 127 static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { | 103 static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { |
| 128 return width * SkColorTypeBytesPerPixel(ct); | 104 return width * SkColorTypeBytesPerPixel(ct); |
| 129 } | 105 } |
| 130 | 106 |
| 131 static inline bool SkColorTypeIsValid(unsigned value) { | 107 static inline bool SkColorTypeIsValid(unsigned value) { |
| 132 return value <= kLastEnum_SkColorType; | 108 return value <= kLastEnum_SkColorType; |
| 133 } | 109 } |
| 134 | 110 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 312 |
| 337 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi
leType pt) { | 313 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi
leType pt) { |
| 338 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; | 314 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; |
| 339 } | 315 } |
| 340 | 316 |
| 341 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { | 317 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { |
| 342 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType()
); | 318 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType()
); |
| 343 } | 319 } |
| 344 | 320 |
| 345 #endif | 321 #endif |
| OLD | NEW |