Reland "Reland "Separate compressed and uncompressed texture functions""

This is a reland of c0519233cdd2545a938848336c7d470bfe27fa96

Original change's description:
> Reland "Separate compressed and uncompressed texture functions"
> 
> This is a reland of 9acfb33ad8c6f5fc6097dff57c0de5e51ea590fd
> 
> Original change's description:
> > Separate compressed and uncompressed texture functions
> > 
> > Change-Id: Iccf31e1e4dbebde8aab4bb9b57cfb0341bb05912
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223802
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> 
> Change-Id: I9f212b7d34cf43216f7d2ec63b959b75fd6a71b3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223992
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Change-Id: I0654a49dadfb56ad276051c8632b91da05bf24cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/224181
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 52adb00..6c22e5c 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -15,6 +15,7 @@
 #include "src/gpu/GrAuditTrail.h"
 #include "src/gpu/GrCaps.h"
 #include "src/gpu/GrContextPriv.h"
+#include "src/gpu/GrDataUtils.h"
 #include "src/gpu/GrGpuResourcePriv.h"
 #include "src/gpu/GrMesh.h"
 #include "src/gpu/GrPathRendering.h"
@@ -101,6 +102,10 @@
 sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted,
                                       const GrMipLevel texels[], int mipLevelCount) {
     TRACE_EVENT0("skia.gpu", TRACE_FUNC);
+    if (GrPixelConfigIsCompressed(origDesc.fConfig)) {
+        // Call GrGpu::createCompressedTexture.
+        return nullptr;
+    }
     GrSurfaceDesc desc = origDesc;
 
     GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo;
@@ -119,10 +124,6 @@
         return nullptr;
     }
 
-    // We shouldn't be rendering into compressed textures
-    SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig) || !isRT);
-    SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig) || 1 == desc.fSampleCnt);
-
     this->handleDirtyContext();
     sk_sp<GrTexture> tex = this->onCreateTexture(desc, budgeted, texels, mipLevelCount);
     if (tex) {
@@ -143,6 +144,27 @@
     return this->createTexture(desc, budgeted, nullptr, 0);
 }
 
+sk_sp<GrTexture> GrGpu::createCompressedTexture(int width, int height,
+                                                SkImage::CompressionType compressionType,
+                                                SkBudgeted budgeted, const void* data,
+                                                size_t dataSize) {
+    this->handleDirtyContext();
+    if (width  < 1 || width  > this->caps()->maxTextureSize() ||
+        height < 1 || height > this->caps()->maxTextureSize()) {
+        return nullptr;
+    }
+    if (!data) {
+        return nullptr;
+    }
+    if (!this->caps()->isConfigTexturable(GrCompressionTypePixelConfig(compressionType))) {
+        return nullptr;
+    }
+    if (dataSize < GrCompressedDataSize(compressionType, width, height)) {
+        return nullptr;
+    }
+    return this->onCreateCompressedTexture(width, height, compressionType, budgeted, data);
+}
+
 sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
                                            GrWrapOwnership ownership, GrWrapCacheable cacheable,
                                            GrIOType ioType) {