Pass GrColorType to the GrGpu::wrapRenderableBackendTexture chain of calls (take 2)
This is a step towards reducing our reliance-on/use-of the GrPixelConfig stored in the GrBackendTexture.
TBR=egdaniel@google.com
Bug: skia:6718
Change-Id: I316a98416c51f273e6ab578f9cbaea5f7adfe331
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227639
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 5bd4044..daffcef 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -372,3 +372,43 @@
GrColorType dstColorType) const {
return SupportedRead{GrSwizzle::RGBA(), GrPixelConfigToColorType(config)};
}
+
+#ifdef SK_DEBUG
+bool GrCaps::AreConfigsCompatible(GrPixelConfig genericConfig, GrPixelConfig specificConfig) {
+ bool compatible = false;
+
+ switch (genericConfig) {
+ case kAlpha_8_GrPixelConfig:
+ compatible = kAlpha_8_GrPixelConfig == specificConfig || // here bc of the mock context
+ kAlpha_8_as_Alpha_GrPixelConfig == specificConfig ||
+ kAlpha_8_as_Red_GrPixelConfig == specificConfig;
+ break;
+ case kGray_8_GrPixelConfig:
+ compatible = kGray_8_GrPixelConfig == specificConfig || // here bc of the mock context
+ kGray_8_as_Lum_GrPixelConfig == specificConfig ||
+ kGray_8_as_Red_GrPixelConfig == specificConfig;
+ break;
+ case kAlpha_half_GrPixelConfig:
+ compatible = kAlpha_half_GrPixelConfig == specificConfig || // bc of the mock context
+ kAlpha_half_as_Red_GrPixelConfig == specificConfig;
+ break;
+ case kRGB_888_GrPixelConfig:
+ compatible = kRGB_888_GrPixelConfig == specificConfig ||
+ kRGB_888X_GrPixelConfig == specificConfig;
+ break;
+ case kRGBA_8888_GrPixelConfig:
+ compatible = kRGBA_8888_GrPixelConfig == specificConfig ||
+ kBGRA_8888_GrPixelConfig == specificConfig;
+ break;
+ default:
+ compatible = genericConfig == specificConfig;
+ break;
+ }
+
+ if (!compatible) {
+ SkDebugf("Configs are not compatible: %d %d\n", genericConfig, specificConfig);
+ }
+
+ return compatible;
+}
+#endif