makeDeferredSurfaceContext -> makeDeferredTextureContext and makeDeferredRenderTargetContext.

Removes some usage of GrSurfaceDesc.

Bug: skia:6718
Change-Id: Icc4f93aba0e5c49a801b4c7bbfcba76a6e30c538
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227776
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index d720771..cac1492 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -163,38 +163,46 @@
     }
 }
 
-sk_sp<GrSurfaceContext> GrRecordingContext::makeDeferredSurfaceContext(
-        const GrBackendFormat& format,
-        const GrSurfaceDesc& dstDesc,
-        GrSurfaceOrigin origin,
-        GrMipMapped mipMapped,
+sk_sp<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
         SkBackingFit fit,
-        SkBudgeted isDstBudgeted,
+        int width,
+        int height,
         GrColorType colorType,
         SkAlphaType alphaType,
         sk_sp<SkColorSpace> colorSpace,
-        const SkSurfaceProps* props) {
-    sk_sp<GrTextureProxy> proxy;
-    if (GrMipMapped::kNo == mipMapped) {
-        proxy = this->proxyProvider()->createProxy(format, dstDesc, origin, fit, isDstBudgeted);
-    } else {
-        SkASSERT(SkBackingFit::kExact == fit);
-        proxy = this->proxyProvider()->createMipMapProxy(format, dstDesc, origin, isDstBudgeted);
+        GrMipMapped mipMapped,
+        GrSurfaceOrigin origin,
+        SkBudgeted budgeted,
+        GrProtected isProtected) {
+    auto format = this->caps()->getBackendFormatFromColorType(colorType);
+    if (!format.isValid()) {
+        return nullptr;
     }
-    if (!proxy) {
+    auto config = this->caps()->getConfigFromBackendFormat(format, colorType);
+    if (config == kUnknown_GrPixelConfig) {
         return nullptr;
     }
 
-    sk_sp<GrSurfaceContext> sContext = this->makeWrappedSurfaceContext(std::move(proxy),
-                                                                       colorType,
-                                                                       alphaType,
-                                                                       std::move(colorSpace),
-                                                                       props);
-    if (sContext && sContext->asRenderTargetContext()) {
-        sContext->asRenderTargetContext()->discard();
+    GrSurfaceDesc desc;
+    desc.fWidth = width;
+    desc.fHeight = height;
+    desc.fIsProtected = isProtected;
+    desc.fConfig = config;
+
+    sk_sp<GrTextureProxy> texture;
+    if (GrMipMapped::kNo == mipMapped) {
+        texture = this->proxyProvider()->createProxy(format, desc, origin, fit, budgeted);
+    } else {
+        texture = this->proxyProvider()->createMipMapProxy(format, desc, origin, budgeted);
+    }
+    if (!texture) {
+        return nullptr;
     }
 
-    return sContext;
+    auto drawingManager = this->drawingManager();
+
+    return drawingManager->makeTextureContext(std::move(texture), colorType, alphaType,
+                                              std::move(colorSpace));
 }
 
 sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
@@ -325,20 +333,20 @@
                                                std::move(colorSpace), props);
 }
 
-sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext(
-        const GrBackendFormat& format,
-        const GrSurfaceDesc& dstDesc,
-        GrSurfaceOrigin origin,
-        GrMipMapped mipMapped,
+sk_sp<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
         SkBackingFit fit,
-        SkBudgeted isDstBudgeted,
+        int width,
+        int height,
         GrColorType colorType,
         SkAlphaType alphaType,
         sk_sp<SkColorSpace> colorSpace,
-        const SkSurfaceProps* props) {
-    return fContext->makeDeferredSurfaceContext(format, dstDesc, origin, mipMapped, fit,
-                                                isDstBudgeted, colorType, alphaType,
-                                                std::move(colorSpace), props);
+        GrMipMapped mipMapped,
+        GrSurfaceOrigin origin,
+        SkBudgeted budgeted,
+        GrProtected isProtected) {
+    return fContext->makeDeferredTextureContext(fit, width, height, colorType, alphaType,
+                                                std::move(colorSpace), mipMapped, origin, budgeted,
+                                                isProtected);
 }
 
 sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(