Make isFormatTexturable take a GrColorType.

Change-Id: I02db9025c49d9ee2d805dd6b48916bcc4136f9a8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225729
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 8d0e7cd..ac353f5 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -158,7 +158,7 @@
 
     virtual bool isFormatSRGB(const GrBackendFormat&) const = 0;
 
-    virtual bool isFormatTexturable(SkColorType, const GrBackendFormat&) const = 0;
+    virtual bool isFormatTexturable(GrColorType, const GrBackendFormat&) const = 0;
     virtual bool isConfigTexturable(GrPixelConfig) const = 0;
 
     // Returns whether a texture of the given config can be copied to a texture of the same config.
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index e8ac761..920d6fb 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -53,6 +53,7 @@
         return SkSurfaceCharacterization(); // return an invalid characterization
     }
 
+    GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
 
     if (!this->caps()->areColorTypeAndFormatCompatible(ii.colorType(), backendFormat)) {
         return SkSurfaceCharacterization(); // return an invalid characterization
@@ -67,7 +68,7 @@
         return SkSurfaceCharacterization(); // return an invalid characterization
     }
 
-    if (isTextureable && !this->caps()->isFormatTexturable(ii.colorType(), backendFormat)) {
+    if (isTextureable && !this->caps()->isFormatTexturable(grColorType, backendFormat)) {
         // Skia doesn't agree that this is textureable.
         return SkSurfaceCharacterization(); // return an invalid characterization
     }
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index d71cf7a..24bcb0a 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -211,13 +211,14 @@
 
     const SkImageInfo& info = srcImage->imageInfo();
     SkColorType ct = info.colorType();
+    GrColorType grCT = SkColorTypeToGrColorType(ct);
 
     GrBackendFormat format = this->caps()->getBackendFormatFromColorType(ct);
     if (!format.isValid()) {
         return nullptr;
     }
 
-    if (!this->caps()->isFormatTexturable(ct, format)) {
+    if (!this->caps()->isFormatTexturable(grCT, format)) {
         SkBitmap copy8888;
         if (!copy8888.tryAllocPixels(info.makeColorType(kRGBA_8888_SkColorType)) ||
             !srcImage->readPixels(copy8888.pixmap(), 0, 0)) {
@@ -331,13 +332,14 @@
     }
 
     SkColorType colorType = bitmap.info().colorType();
+    GrColorType grColorType = SkColorTypeToGrColorType(colorType);
     GrBackendFormat format = this->caps()->getBackendFormatFromColorType(colorType);
     if (!format.isValid()) {
         return nullptr;
     }
     GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
 
-    if (!this->caps()->isFormatTexturable(colorType, format)) {
+    if (!this->caps()->isFormatTexturable(grColorType, format)) {
         SkBitmap copy8888;
         if (!copy8888.tryAllocPixels(bitmap.info().makeColorType(kRGBA_8888_SkColorType)) ||
             !bitmap.readPixels(copy8888.pixmap())) {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 6fc75c0..f28ad2a 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -3612,13 +3612,12 @@
            SkToBool(info.colorTypeFlags(ct) & ColorTypeInfo::kUploadData_Flag);
 }
 
-bool GrGLCaps::isFormatTexturable(SkColorType ct, const GrBackendFormat& format) const {
+bool GrGLCaps::isFormatTexturable(GrColorType ct, const GrBackendFormat& format) const {
     const GrGLenum* glFormat = format.getGLFormat();
     if (!glFormat) {
         return false;
     }
-    GrColorType grCT = SkColorTypeToGrColorType(ct);
-    return this->isGLFormatTexturable(grCT, *glFormat);
+    return this->isGLFormatTexturable(ct, *glFormat);
 }
 
 int GrGLCaps::getRenderTargetSampleCount(int requestedCount, SkColorType skCT,
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index f83b6a1..c6fc099 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -108,7 +108,7 @@
 
     bool isFormatSRGB(const GrBackendFormat& format) const override;
 
-    bool isFormatTexturable(SkColorType, const GrBackendFormat&) const override;
+    bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
 
     bool isConfigTexturable(GrPixelConfig config) const override {
         GrGLenum glFormat = this->configSizedInternalFormat(config);
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 6e88296..91116ab 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -44,7 +44,7 @@
         return kSRGBA_8888_GrPixelConfig == *format.getMockFormat();
     }
 
-    bool isFormatTexturable(SkColorType, const GrBackendFormat& format) const override {
+    bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override {
         if (!format.getMockFormat()) {
             return false;
         }
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 9472416..38b9701 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -28,7 +28,7 @@
 
     bool isFormatSRGB(const GrBackendFormat& format) const override;
 
-    bool isFormatTexturable(SkColorType, const GrBackendFormat&) const override;
+    bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
 
     bool isConfigTexturable(GrPixelConfig config) const override {
         return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index ee21e98..8703117 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -253,8 +253,7 @@
     return format_is_srgb(static_cast<MTLPixelFormat>(*format.getMtlFormat()));
 }
 
-bool GrMtlCaps::isFormatTexturable(SkColorType skCT, const GrBackendFormat& format) const {
-    GrColorType grCT = SkColorTypeToGrColorType(skCT);
+bool GrMtlCaps::isFormatTexturable(GrColorType grCT, const GrBackendFormat& format) const {
     if (GrColorType::kUnknown == grCT) {
         return false;
     }
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index dd868b6..c2df040 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -795,15 +795,15 @@
     return format_is_srgb(*format.getVkFormat());
 }
 
-bool GrVkCaps::isFormatTexturable(SkColorType, const GrBackendFormat& format) const {
+bool GrVkCaps::isFormatTexturable(GrColorType, const GrBackendFormat& format) const {
     if (!format.getVkFormat()) {
         return false;
     }
 
-    return this->isFormatTexturable(*format.getVkFormat());
+    return this->isVkFormatTexturable(*format.getVkFormat());
 }
 
-bool GrVkCaps::isFormatTexturable(VkFormat format) const {
+bool GrVkCaps::isVkFormatTexturable(VkFormat format) const {
     if (!GrVkFormatIsSupported(format)) {
         return false;
     }
@@ -817,7 +817,7 @@
     if (!GrPixelConfigToVkFormat(config, &format)) {
         return false;
     }
-    return this->isFormatTexturable(format);
+    return this->isVkFormatTexturable(format);
 }
 
 bool GrVkCaps::isFormatRenderable(VkFormat format) const {
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index d3873c0..8cb75f4 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -34,8 +34,8 @@
 
     bool isFormatSRGB(const GrBackendFormat& format) const override;
 
-    bool isFormatTexturable(SkColorType, const GrBackendFormat&) const override;
-    bool isFormatTexturable(VkFormat) const;
+    bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
+    bool isVkFormatTexturable(VkFormat) const;
     bool isConfigTexturable(GrPixelConfig config) const override;
 
     bool isFormatCopyable(SkColorType, const GrBackendFormat&) const override { return true; }
@@ -54,7 +54,7 @@
 
     SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override;
 
-    bool isFormatTexturableLinearly(VkFormat format) const {
+    bool isVkFormatTexturableLinearly(VkFormat format) const {
         return SkToBool(FormatInfo::kTextureable_Flag & this->getFormatInfo(format).fLinearFlags);
     }
 
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index c30490b..3533b39 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -725,7 +725,7 @@
         mipLevelCount = 1;
     }
 
-    SkASSERT(this->vkCaps().isFormatTexturable(tex->imageFormat()));
+    SkASSERT(this->vkCaps().isVkFormatTexturable(tex->imageFormat()));
     int bpp = GrColorTypeBytesPerPixel(dataColorType);
 
     // texels is const.
@@ -905,7 +905,7 @@
         return false;
     }
 
-    SkASSERT(this->vkCaps().isFormatTexturable(tex->imageFormat()));
+    SkASSERT(this->vkCaps().isVkFormatTexturable(tex->imageFormat()));
 
     size_t dataSize = GrCompressedDataSize(compressionType, width, height);
 
@@ -1137,12 +1137,12 @@
 
 static bool check_tex_image_info(const GrVkCaps& caps, const GrVkImageInfo& info) {
     if (info.fImageTiling == VK_IMAGE_TILING_OPTIMAL) {
-        if (!caps.isFormatTexturable(info.fFormat)) {
+        if (!caps.isVkFormatTexturable(info.fFormat)) {
             return false;
         }
     } else {
         SkASSERT(info.fImageTiling == VK_IMAGE_TILING_LINEAR);
-        if (!caps.isFormatTexturableLinearly(info.fFormat)) {
+        if (!caps.isVkFormatTexturableLinearly(info.fFormat)) {
             return false;
         }
     }
@@ -1566,7 +1566,7 @@
         return false;
     }
 
-    if (texturable && !fVkCaps->isFormatTexturable(vkFormat)) {
+    if (texturable && !fVkCaps->isVkFormatTexturable(vkFormat)) {
         return false;
     }
 
@@ -1922,7 +1922,7 @@
         return GrBackendTexture();
     }
 
-    if (!caps.isFormatTexturable(*vkFormat)) {
+    if (!caps.isVkFormatTexturable(*vkFormat)) {
         SkDebugf("Config is not texturable\n");
         return GrBackendTexture();
     }
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 9fdc4ae..36c0871 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -407,6 +407,8 @@
 static bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex,
                                      GrPixelConfig* config, int sampleCnt, SkColorType ct,
                                      bool texturable) {
+    GrColorType grCT = SkColorTypeToGrColorType(ct);
+
     if (!tex.isValid()) {
         return false;
     }
@@ -426,7 +428,7 @@
         return false;
     }
 
-    if (texturable && !ctx->priv().caps()->isFormatTexturable(ct, backendFormat)) {
+    if (texturable && !ctx->priv().caps()->isFormatTexturable(grCT, backendFormat)) {
         return false;
     }
     return true;