Remove GrCaps isConfigTexturable.

This also makes the isTexturable that takes a color explicitly called
isFormatTexturableAndUploadable. A lot of the uses of isConfigTexturable
were changed to the Uploadable version of the check, even though this is
not where we want to land in the long run. In the long run the uploadability
will be checked via calls to supportedWritePixelsColorType and all the
isTexturable calls should purely be about texturing. However, until those
changes land we keep it safe and keep the same functionality that
isConfigTexturable had by checking uploadability as well.

Bug: skia:6718
Change-Id: I3563f33f49811923da80e676fa3036ae46c4da70
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234323
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a2280b4..0ca7ba3 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1107,7 +1107,7 @@
     // If we're uploading compressed data then we should be using uploadCompressedTexData
     SkASSERT(!GrGLFormatIsCompressed(textureFormat));
 
-    SkASSERT(this->glCaps().isFormatTexturable(textureColorType, textureFormat));
+    SkASSERT(this->glCaps().isFormatTexturable(textureFormat));
     SkDEBUGCODE(
         SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
         SkIRect bounds = SkIRect::MakeWH(texWidth, texHeight);
@@ -1205,22 +1205,21 @@
     return succeeded;
 }
 
-GrGLFormat GrGLGpu::uploadCompressedTexData(SkImage::CompressionType compressionType,
-                                            const SkISize& size,
-                                            GrGLenum target,
-                                            const void* data) {
+bool GrGLGpu::uploadCompressedTexData(GrGLFormat format,
+                                      SkImage::CompressionType compressionType,
+                                      const SkISize& size,
+                                      GrGLenum target,
+                                      const void* data) {
+    SkASSERT(format != GrGLFormat::kUnknown);
     const GrGLCaps& caps = this->glCaps();
 
-    GrPixelConfig config = GrCompressionTypePixelConfig(compressionType);
     // We only need the internal format for compressed 2D textures.
-    GrGLenum internalFormat;
-    if (!caps.getCompressedTexImageFormats(config, &internalFormat)) {
-        return GrGLFormat::kUnknown;
+    GrGLenum internalFormat = caps.getTexImageInternalFormat(format);
+    if (!internalFormat) {
+        return 0;
     }
-    GrGLFormat format = GrGLFormatFromGLEnum(internalFormat);
-    SkASSERT(format != GrGLFormat::kUnknown);
 
-    bool useTexStorage = caps.configSupportsTexStorage(config);
+    bool useTexStorage = caps.formatSupportsTexStorage(format);
 
     static constexpr int kMipLevelCount = 1;
 
@@ -1235,7 +1234,7 @@
                 TexStorage2D(target, kMipLevelCount, internalFormat, size.width(), size.height()));
         GrGLenum error = CHECK_ALLOC_ERROR(this->glInterface());
         if (error != GR_GL_NO_ERROR) {
-            return GrGLFormat::kUnknown;
+            return false;
         }
         GL_CALL(CompressedTexSubImage2D(target,
                                         0,  // level
@@ -1258,10 +1257,10 @@
 
         GrGLenum error = CHECK_ALLOC_ERROR(this->glInterface());
         if (error != GR_GL_NO_ERROR) {
-            return GrGLFormat::kUnknown;
+            return false;
         }
     }
-    return format;
+    return true;
 }
 
 static bool renderbuffer_storage_msaa(const GrGLContext& ctx,
@@ -1503,6 +1502,7 @@
 }
 
 sk_sp<GrTexture> GrGLGpu::onCreateCompressedTexture(int width, int height,
+                                                    const GrBackendFormat& format,
                                                     SkImage::CompressionType compression,
                                                     SkBudgeted budgeted, const void* data) {
     GrGLTextureParameters::SamplerOverriddenState initialState;
@@ -1511,8 +1511,9 @@
     desc.fTarget = GR_GL_TEXTURE_2D;
     desc.fConfig = GrCompressionTypePixelConfig(compression);
     desc.fOwnership = GrBackendObjectOwnership::kOwned;
-    desc.fID = this->createCompressedTexture2D(desc.fSize, compression, &initialState, data,
-                                               &desc.fFormat);
+    desc.fFormat = format.asGLFormat();
+    desc.fID = this->createCompressedTexture2D(desc.fSize, desc.fFormat, compression, &initialState,
+                                               data);
     if (!desc.fID) {
         return nullptr;
     }
@@ -1664,10 +1665,13 @@
 
 GrGLuint GrGLGpu::createCompressedTexture2D(
         const SkISize& size,
+        GrGLFormat format,
         SkImage::CompressionType compression,
         GrGLTextureParameters::SamplerOverriddenState* initialState,
-        const void* data,
-        GrGLFormat* format) {
+        const void* data) {
+    if (format == GrGLFormat::kUnknown) {
+        return 0;
+    }
     GrGLuint id = 0;
     GL_CALL(GenTextures(1, &id));
     if (!id) {
@@ -1678,8 +1682,7 @@
 
     *initialState = set_initial_texture_params(this->glInterface(), GR_GL_TEXTURE_2D);
 
-    *format = this->uploadCompressedTexData(compression, size, GR_GL_TEXTURE_2D, data);
-    if (*format == GrGLFormat::kUnknown) {
+    if (!this->uploadCompressedTexData(format, compression, size, GR_GL_TEXTURE_2D, data)) {
         GL_CALL(DeleteTextures(1, &id));
         return 0;
     }
@@ -3799,7 +3802,9 @@
         return GrBackendTexture();  // invalid
     }
 
-    if (!this->caps()->isConfigTexturable(config)) {
+    auto textureColorType = GrPixelConfigToColorType(config);
+
+    if (!this->caps()->isFormatTexturableAndUploadable(textureColorType, format)) {
         return GrBackendTexture();  // invalid
     }
 
@@ -3838,13 +3843,12 @@
             srcPixels = pixelStorage.reset(size);
             GrFillInCompressedData(compressionType, w, h, (char*)srcPixels, *color);
         }
-        GrGLFormat format;
         info.fID = this->createCompressedTexture2D(
-                {w, h}, compressionType, &initialState, srcPixels, &format);
+                {w, h}, glFormat, compressionType, &initialState, srcPixels);
         if (!info.fID) {
             return GrBackendTexture();
         }
-        info.fFormat = GrGLFormatToEnum(format);
+        info.fFormat = GrGLFormatToEnum(glFormat);
         info.fTarget = GR_GL_TEXTURE_2D;
     } else {
         if (srcPixels) {
@@ -3885,7 +3889,6 @@
         info.fTarget = GR_GL_TEXTURE_2D;
         info.fFormat = GrGLFormatToEnum(glFormat);
         // TODO: Take these as parameters.
-        auto textureColorType = GrPixelConfigToColorType(desc.fConfig);
         auto srcColorType = GrPixelConfigToColorType(desc.fConfig);
         info.fID = this->createTexture2D({desc.fWidth, desc.fHeight},
                                          glFormat,