Switch Ops over to using GrRecordingContext

Since, by definition, the ops are created when recording, it makes sense that they should be able to make due with only the GrRecordingContext.

TBR=bsalomon@google.com
Change-Id: If64353aee30b35d0a16401f7de00954f44ed8c59
Reviewed-on: https://skia-review.googlesource.com/c/190670
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index c719101..12142c3 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -8,8 +8,11 @@
 #include "GrRecordingContext.h"
 
 #include "GrCaps.h"
+#include "GrDrawingManager.h"
 #include "GrMemoryPool.h"
+#include "GrProxyProvider.h"
 #include "GrRecordingContextPriv.h"
+#include "GrRenderTargetContext.h"
 #include "GrSkSLFPFactoryCache.h"
 
 GrRecordingContext::GrRecordingContext(GrBackendApi backend,
@@ -40,6 +43,53 @@
     return this->refOpMemoryPool().get();
 }
 
+sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
+                                                        const GrBackendFormat& format,
+                                                        SkBackingFit fit,
+                                                        int width, int height,
+                                                        GrPixelConfig config,
+                                                        sk_sp<SkColorSpace> colorSpace,
+                                                        int sampleCnt,
+                                                        GrMipMapped mipMapped,
+                                                        GrSurfaceOrigin origin,
+                                                        const SkSurfaceProps* surfaceProps,
+                                                        SkBudgeted budgeted) {
+    SkASSERT(sampleCnt > 0);
+    if (this->abandoned()) {
+        return nullptr;
+    }
+
+    GrSurfaceDesc desc;
+    desc.fFlags = kRenderTarget_GrSurfaceFlag;
+    desc.fWidth = width;
+    desc.fHeight = height;
+    desc.fConfig = config;
+    desc.fSampleCnt = sampleCnt;
+
+    sk_sp<GrTextureProxy> rtp;
+    if (GrMipMapped::kNo == mipMapped) {
+        rtp = this->proxyProvider()->createProxy(format, desc, origin, fit, budgeted);
+    } else {
+        rtp = this->proxyProvider()->createMipMapProxy(format, desc, origin, budgeted);
+    }
+    if (!rtp) {
+        return nullptr;
+    }
+
+    // CONTEXT TODO: move GrDrawingManager to GrRecordingContext for real
+    auto drawingManager = this->drawingManager();
+
+    sk_sp<GrRenderTargetContext> renderTargetContext =
+        drawingManager->makeRenderTargetContext(std::move(rtp), std::move(colorSpace),
+                                                surfaceProps);
+    if (!renderTargetContext) {
+        return nullptr;
+    }
+
+    renderTargetContext->discard();
+
+    return renderTargetContext;
+}
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const {
@@ -53,3 +103,19 @@
 sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() {
     return fContext->refOpMemoryPool();
 }
+
+sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
+                                                    const GrBackendFormat& format,
+                                                    SkBackingFit fit,
+                                                    int width, int height,
+                                                    GrPixelConfig config,
+                                                    sk_sp<SkColorSpace> colorSpace,
+                                                    int sampleCnt,
+                                                    GrMipMapped mipMapped,
+                                                    GrSurfaceOrigin origin,
+                                                    const SkSurfaceProps* surfaceProps,
+                                                    SkBudgeted budgeted) {
+    return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config,
+                                                     std::move(colorSpace), sampleCnt, mipMapped,
+                                                     origin, surfaceProps, budgeted);
+}