diff options
author | Brian Salomon <bsalomon@google.com> | 2018-01-25 14:07:47 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-30 01:59:31 +0000 |
commit | e41e1769e76dcce573038d04d90d62043ece7e4f (patch) | |
tree | 3b27304e9d701ea2e04499a70ce6ed5bb1c58790 /include/core/SkImageInfo.h | |
parent | ecd251bbd28dbf52e465aef47f7062f2bb51e43a (diff) |
Add kRGBX_8888, kRGBA_1010102, and kRGBX_1010102 color types. Unused for now.
BUG= skia:7533
Change-Id: I4b3f6b827fd833ba2d07895884d2abc9a3132366
Reviewed-on: https://skia-review.googlesource.com/99781
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/core/SkImageInfo.h')
-rw-r--r-- | include/core/SkImageInfo.h | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index 24e356b87e..6876c8bb04 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -58,6 +58,9 @@ static inline bool SkAlphaTypeIsValid(unsigned value) { /////////////////////////////////////////////////////////////////////////////// +/** Temporary macro that allows us to add new color types without breaking Chrome compile. */ +#define SK_EXTENDED_COLOR_TYPES + /** * Describes how to interpret the components of a pixel. * @@ -71,7 +74,10 @@ enum SkColorType { kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType, + kRGB_888x_SkColorType, kBGRA_8888_SkColorType, + kRGBA_1010102_SkColorType, + kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType, @@ -87,39 +93,37 @@ enum SkColorType { }; static int SkColorTypeBytesPerPixel(SkColorType ct) { - static const uint8_t gSize[] = { - 0, // Unknown - 1, // Alpha_8 - 2, // RGB_565 - 2, // ARGB_4444 - 4, // RGBA_8888 - 4, // BGRA_8888 - 1, // kGray_8 - 8, // kRGBA_F16 - }; - static_assert(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1), - "size_mismatch_with_SkColorType_enum"); - - SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize)); - return gSize[ct]; + switch (ct) { + case kUnknown_SkColorType: return 0; + case kAlpha_8_SkColorType: return 1; + case kRGB_565_SkColorType: return 2; + case kARGB_4444_SkColorType: return 2; + case kRGBA_8888_SkColorType: return 4; + case kBGRA_8888_SkColorType: return 4; + case kRGB_888x_SkColorType: return 4; + case kRGBA_1010102_SkColorType: return 4; + case kRGB_101010x_SkColorType: return 4; + case kGray_8_SkColorType: return 1; + case kRGBA_F16_SkColorType: return 8; + } + return 0; } 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, // 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]; + switch (ct) { + case kUnknown_SkColorType: return 0; + case kAlpha_8_SkColorType: return 0; + case kRGB_565_SkColorType: return 1; + case kARGB_4444_SkColorType: return 1; + case kRGBA_8888_SkColorType: return 2; + case kRGB_888x_SkColorType: return 2; + case kBGRA_8888_SkColorType: return 2; + case kRGBA_1010102_SkColorType: return 2; + case kRGB_101010x_SkColorType: return 2; + case kGray_8_SkColorType: return 0; + case kRGBA_F16_SkColorType: return 3; + } + return 0; } static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { |