Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: include/core/SkImageInfo.h

Issue 1889793007: move static arrays into impl, to avoid multiple copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: re-expose globals (since gcc didn't like my hiding trick) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkImageInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageInfo.h
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 4b308c05d88ca736d69451f3b970c1bd71b30b12..1cac7ebc4deb44b1394b391c6151e4240a437478 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -86,42 +86,18 @@ enum SkColorType {
#endif
};
+extern const uint8_t gPrivate_SkColorTypeBytesPerPixel[];
+
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");
-
- SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize));
- return gSize[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) {
« no previous file with comments | « no previous file | src/core/SkImageInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698