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/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 79cfbf4..f007304 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -230,23 +230,32 @@
 }
 
 sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
-                                                     int sampleCnt, GrWrapOwnership ownership,
+                                                     int sampleCnt, GrColorType colorType,
+                                                     GrWrapOwnership ownership,
                                                      GrWrapCacheable cacheable) {
     this->handleDirtyContext();
     if (sampleCnt < 1) {
         return nullptr;
     }
-    if (!this->caps()->isConfigTexturable(backendTex.config()) ||
-        !this->caps()->getRenderTargetSampleCount(sampleCnt, backendTex.config())) {
+
+    const GrCaps* caps = this->caps();
+
+    SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+                                          caps->getConfigFromBackendFormat(
+                                                                     backendTex.getBackendFormat(),
+                                                                     colorType)));
+
+    if (!caps->isFormatTexturable(colorType, backendTex.getBackendFormat()) ||
+        !caps->getRenderTargetSampleCount(sampleCnt, colorType, backendTex.getBackendFormat())) {
         return nullptr;
     }
 
-    if (backendTex.width() > this->caps()->maxRenderTargetSize() ||
-        backendTex.height() > this->caps()->maxRenderTargetSize()) {
+    if (backendTex.width() > caps->maxRenderTargetSize() ||
+        backendTex.height() > caps->maxRenderTargetSize()) {
         return nullptr;
     }
-    sk_sp<GrTexture> tex =
-            this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership, cacheable);
+    sk_sp<GrTexture> tex = this->onWrapRenderableBackendTexture(backendTex, sampleCnt, colorType,
+                                                                ownership, cacheable);
     SkASSERT(!tex || tex->asRenderTarget());
     return tex;
 }