move static arrays into impl, to avoid multiple copies
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1889793007 Review URL: https://codereview.chromium.org/1889793007
This commit is contained in:
parent
6b13473dd4
commit
6d7cd1f421
@ -86,42 +86,18 @@ enum SkColorType {
|
||||
#endif
|
||||
};
|
||||
|
||||
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, // kIndex_8
|
||||
1, // kGray_8
|
||||
8, // kRGBA_F16
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1),
|
||||
"size_mismatch_with_SkColorType_enum");
|
||||
extern const uint8_t gPrivate_SkColorTypeBytesPerPixel[];
|
||||
|
||||
SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize));
|
||||
return gSize[ct];
|
||||
static int SkColorTypeBytesPerPixel(SkColorType ct) {
|
||||
SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType);
|
||||
return gPrivate_SkColorTypeBytesPerPixel[ct];
|
||||
}
|
||||
|
||||
extern const uint8_t gPrivate_SkColorTypeShiftPerPixel[];
|
||||
|
||||
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];
|
||||
SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType);
|
||||
return gPrivate_SkColorTypeShiftPerPixel[ct];
|
||||
}
|
||||
|
||||
static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) {
|
||||
|
@ -9,6 +9,34 @@
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
const uint8_t gPrivate_SkColorTypeBytesPerPixel[] = {
|
||||
0, // Unknown
|
||||
1, // Alpha_8
|
||||
2, // RGB_565
|
||||
2, // ARGB_4444
|
||||
4, // RGBA_8888
|
||||
4, // BGRA_8888
|
||||
1, // kIndex_8
|
||||
1, // kGray_8
|
||||
8, // kRGBA_F16
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeBytesPerPixel) == (size_t)(kLastEnum_SkColorType + 1),
|
||||
"size_mismatch_with_SkColorType_enum");
|
||||
|
||||
const uint8_t gPrivate_SkColorTypeShiftPerPixel[] = {
|
||||
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(gPrivate_SkColorTypeShiftPerPixel) == (size_t)(kLastEnum_SkColorType + 1),
|
||||
"size_mismatch_with_SkColorType_enum");
|
||||
|
||||
static bool profile_type_is_valid(SkColorProfileType profileType) {
|
||||
return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user