Cleanup GrPixelConfig helper functions
Remove unused functions, and convert another to switch style.
BUG=skia:
Change-Id: I93edbece54f147d868801bb008e6f935a8cb997f
Reviewed-on: https://skia-review.googlesource.com/6947
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index 0403e48..cebceea 100644
--- a/include/gpu/GrColor.h
+++ b/include/gpu/GrColor.h
@@ -267,63 +267,4 @@
GR_MAKE_BITFIELD_OPS(GrColorComponentFlags)
-static inline char GrColorComponentFlagToChar(GrColorComponentFlags component) {
- SkASSERT(SkIsPow2(component));
- switch (component) {
- case kR_GrColorComponentFlag:
- return 'r';
- case kG_GrColorComponentFlag:
- return 'g';
- case kB_GrColorComponentFlag:
- return 'b';
- case kA_GrColorComponentFlag:
- return 'a';
- default:
- SkFAIL("Invalid color component flag.");
- return '\0';
- }
-}
-
-static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
- static const uint32_t kFlags[] = {
- 0, // kUnknown_GrPixelConfig
- kA_GrColorComponentFlag, // kAlpha_8_GrPixelConfig
- kRGB_GrColorComponentFlags, // kGray_8_GrPixelConfig
- kRGB_GrColorComponentFlags, // kRGB_565_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kRGBA_4444_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kRGBA_8888_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kBGRA_8888_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kSRGBA_8888_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kSBGRA_8888_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kRGBA_8888_sint_GrPixelConfig
- kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig
- kA_GrColorComponentFlag, // kLATC_GrPixelConfig
- kA_GrColorComponentFlag, // kR11_EAC_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kASTC_12x12_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kRGBA_float_GrPixelConfig
- kA_GrColorComponentFlag, // kAlpha_16_GrPixelConfig
- kRGBA_GrColorComponentFlags, // kRGBA_half_GrPixelConfig
- };
- return kFlags[config];
-
- GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
- GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
- GR_STATIC_ASSERT(2 == kGray_8_GrPixelConfig);
- GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
- GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
- GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
- GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
- GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
- GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
-}
-
#endif
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 02b50c2..1256058 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -679,45 +679,19 @@
}
static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
- static const GrPixelConfig kFallback[] = {
- kUnknown_GrPixelConfig, // kUnknown_GrPixelConfig
- kRGBA_8888_GrPixelConfig, // kAlpha_8_GrPixelConfig
- kUnknown_GrPixelConfig, // kGray_8_GrPixelConfig
- kRGBA_8888_GrPixelConfig, // kRGB_565_GrPixelConfig
- kRGBA_8888_GrPixelConfig, // kRGBA_4444_GrPixelConfig
- kUnknown_GrPixelConfig, // kRGBA_8888_GrPixelConfig
- kRGBA_8888_GrPixelConfig, // kBGRA_8888_GrPixelConfig
- kUnknown_GrPixelConfig, // kSRGBA_8888_GrPixelConfig
- kSRGBA_8888_GrPixelConfig, // kSBGRA_8888_GrPixelConfig
- kUnknown_GrPixelConfig, // kRGBA_8888_sint_GrPixelConfig
- kUnknown_GrPixelConfig, // kETC1_GrPixelConfig
- kUnknown_GrPixelConfig, // kLATC_GrPixelConfig
- kUnknown_GrPixelConfig, // kR11_EAC_GrPixelConfig
- kUnknown_GrPixelConfig, // kASTC_12x12_GrPixelConfig
- kUnknown_GrPixelConfig, // kRGBA_float_GrPixelConfig
- kRGBA_half_GrPixelConfig, // kAlpha_half_GrPixelConfig
- kUnknown_GrPixelConfig, // kRGBA_half_GrPixelConfig
- };
- return kFallback[config];
-
- GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
- GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
- GR_STATIC_ASSERT(2 == kGray_8_GrPixelConfig);
- GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
- GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
- GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
- GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
- GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
- GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFallback) == kGrPixelConfigCnt);
+ switch (config) {
+ case kAlpha_8_GrPixelConfig:
+ case kRGB_565_GrPixelConfig:
+ case kRGBA_4444_GrPixelConfig:
+ case kBGRA_8888_GrPixelConfig:
+ return kRGBA_8888_GrPixelConfig;
+ case kSBGRA_8888_GrPixelConfig:
+ return kSRGBA_8888_GrPixelConfig;
+ case kAlpha_half_GrPixelConfig:
+ return kRGBA_half_GrPixelConfig;
+ default:
+ return kUnknown_GrPixelConfig;
+ }
}
sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContextWithFallback(