| Index: include/core/SkImageInfo.h | 
| diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h | 
| index c55edd36c2252bc38fa2ad581875e839aa8a0ef5..4b308c05d88ca736d69451f3b970c1bd71b30b12 100644 | 
| --- a/include/core/SkImageInfo.h | 
| +++ b/include/core/SkImageInfo.h | 
| @@ -105,6 +105,25 @@ static int SkColorTypeBytesPerPixel(SkColorType ct) { | 
| return gSize[ct]; | 
| } | 
|  | 
| +static int SkColorTypeShiftPerPixel(SkColorType ct) { | 
| +    static const uint8_t gShift[] = { | 
| +        0,  // Unknown | 
| +        0,  // Alpha_8 | 
| +        1,  // RGB_565 | 
| +        1,  // ARGB_4444 | 
| +        2,  // RGBA_8888 | 
| +        2,  // BGRA_8888 | 
| +        0,  // kIndex_8 | 
| +        0,  // kGray_8 | 
| +        3,  // kRGBA_F16 | 
| +    }; | 
| +    static_assert(SK_ARRAY_COUNT(gShift) == (size_t)(kLastEnum_SkColorType + 1), | 
| +                  "size_mismatch_with_SkColorType_enum"); | 
| + | 
| +    SkASSERT((size_t)ct < SK_ARRAY_COUNT(gShift)); | 
| +    return gShift[ct]; | 
| +} | 
| + | 
| static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { | 
| return width * SkColorTypeBytesPerPixel(ct); | 
| } | 
| @@ -114,15 +133,10 @@ static inline bool SkColorTypeIsValid(unsigned value) { | 
| } | 
|  | 
| static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size_t rowBytes) { | 
| -    int shift = 0; | 
| -    switch (SkColorTypeBytesPerPixel(ct)) { | 
| -        case 8: shift = 3; break; | 
| -        case 4: shift = 2; break; | 
| -        case 2: shift = 1; break; | 
| -        case 1: shift = 0; break; | 
| -        default: return 0; | 
| +    if (kUnknown_SkColorType == ct) { | 
| +        return 0; | 
| } | 
| -    return y * rowBytes + (x << shift); | 
| +    return y * rowBytes + (x << SkColorTypeShiftPerPixel(ct)); | 
| } | 
|  | 
| /////////////////////////////////////////////////////////////////////////////// | 
| @@ -252,9 +266,9 @@ public: | 
| return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType, fProfileType); | 
| } | 
|  | 
| -    int bytesPerPixel() const { | 
| -        return SkColorTypeBytesPerPixel(fColorType); | 
| -    } | 
| +    int bytesPerPixel() const { return SkColorTypeBytesPerPixel(fColorType); } | 
| + | 
| +    int shiftPerPixel() const { return SkColorTypeShiftPerPixel(fColorType); } | 
|  | 
| uint64_t minRowBytes64() const { | 
| return sk_64_mul(fWidth, this->bytesPerPixel()); | 
|  |