GrSurfaceContext not ref counted.

Also don't specify redundant width/height to SkGpuDevice.

Change-Id: I389df5c4b073c2c05632ba6b7c95b02a22dfaf98
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235824
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index a173e56..92749da 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -878,17 +878,16 @@
     // If we're doing a normal blur, we can clobber the pathTexture in the
     // gaussianBlur.  Otherwise, we need to save it for later compositing.
     bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-              SkGpuBlurUtils::GaussianBlur(context,
-                                           srcProxy,
-                                           SkIPoint::Make(0, 0),
-                                           nullptr,
-                                           clipRect,
-                                           SkIRect::EmptyIRect(),
-                                           xformedSigma,
-                                           xformedSigma,
-                                           GrTextureDomain::kIgnore_Mode,
-                                           kPremul_SkAlphaType));
+    auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(context,
+                                                            srcProxy,
+                                                            SkIPoint::Make(0, 0),
+                                                            nullptr,
+                                                            clipRect,
+                                                            SkIRect::EmptyIRect(),
+                                                            xformedSigma,
+                                                            xformedSigma,
+                                                            GrTextureDomain::kIgnore_Mode,
+                                                            kPremul_SkAlphaType);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index a4ebb59..d198843 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -185,14 +185,14 @@
         return false;
     }
 
-    sk_sp<GrSurfaceContext> c = fContext->priv().makeWrappedSurfaceContext(
-            std::move(proxy),
-            grColorType,
-            kPremul_SkAlphaType,
-            fCharacterization.refColorSpace(),
-            &fCharacterization.surfaceProps());
-    fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(),
-                                                      sk_ref_sp(c->asRenderTargetContext()));
+    auto c = fContext->priv().makeWrappedSurfaceContext(std::move(proxy),
+                                                        grColorType,
+                                                        kPremul_SkAlphaType,
+                                                        fCharacterization.refColorSpace(),
+                                                        &fCharacterization.surfaceProps());
+    SkASSERT(c->asRenderTargetContext());
+    std::unique_ptr<GrRenderTargetContext> rtc(c.release()->asRenderTargetContext());
+    fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(), std::move(rtc));
     return SkToBool(fSurface.get());
 }
 
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 8f6f309..4ee12e3 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -105,24 +105,23 @@
     return GrPixelConfigToColorType(config);
 }
 
-static sk_sp<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* context,
-                                                         sk_sp<GrTextureProxy> proxy,
-                                                         const SkIRect& srcBounds,
-                                                         const SkIPoint& srcOffset,
-                                                         int radiusX,
-                                                         int radiusY,
-                                                         SkScalar sigmaX,
-                                                         SkScalar sigmaY,
-                                                         GrTextureDomain::Mode mode,
-                                                         int finalW,
-                                                         int finalH,
-                                                         sk_sp<SkColorSpace> finalCS,
-                                                         SkBackingFit dstFit) {
+static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* context,
+                                                                   sk_sp<GrTextureProxy> proxy,
+                                                                   const SkIRect& srcBounds,
+                                                                   const SkIPoint& srcOffset,
+                                                                   int radiusX,
+                                                                   int radiusY,
+                                                                   SkScalar sigmaX,
+                                                                   SkScalar sigmaY,
+                                                                   GrTextureDomain::Mode mode,
+                                                                   int finalW,
+                                                                   int finalH,
+                                                                   sk_sp<SkColorSpace> finalCS,
+                                                                   SkBackingFit dstFit) {
     // TODO: Once GrPixelConfig is gone, we need will need the source's color type.
     GrColorType colorType = get_blur_color_type(proxy.get());
 
-    sk_sp<GrRenderTargetContext> renderTargetContext;
-    renderTargetContext = context->priv().makeDeferredRenderTargetContext(
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
             dstFit,
             finalW,
             finalH,
@@ -162,27 +161,26 @@
 // (which do impact destination decisions). Both functions incorporate the proxy offset into the
 // geometry they submit or before calling convolve_gaussian_1d.
 
-static sk_sp<GrRenderTargetContext> convolve_gaussian(GrRecordingContext* context,
-                                                      sk_sp<GrTextureProxy> proxy,
-                                                      const SkIPoint& proxyOffset,
-                                                      const SkIRect& srcRect,
-                                                      const SkIPoint& srcOffset,
-                                                      Direction direction,
-                                                      int radius,
-                                                      float sigma,
-                                                      SkIRect* contentRect,
-                                                      GrTextureDomain::Mode mode,
-                                                      int finalW,
-                                                      int finalH,
-                                                      sk_sp<SkColorSpace> finalCS,
-                                                      SkBackingFit fit) {
+static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingContext* context,
+                                                                sk_sp<GrTextureProxy> proxy,
+                                                                const SkIPoint& proxyOffset,
+                                                                const SkIRect& srcRect,
+                                                                const SkIPoint& srcOffset,
+                                                                Direction direction,
+                                                                int radius,
+                                                                float sigma,
+                                                                SkIRect* contentRect,
+                                                                GrTextureDomain::Mode mode,
+                                                                int finalW,
+                                                                int finalH,
+                                                                sk_sp<SkColorSpace> finalCS,
+                                                                SkBackingFit fit) {
     SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH);
 
     // TODO: Once GrPixelConfig is gone we'll need the source's color type here.
     GrColorType colorType = get_blur_color_type(proxy.get());
 
-    sk_sp<GrRenderTargetContext> dstRenderTargetContext;
-    dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
+    auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
             fit,
             srcRect.width(),
             srcRect.height(),
@@ -308,7 +306,7 @@
 
     SkIRect dstRect(srcRect);
 
-    sk_sp<GrRenderTargetContext> dstRenderTargetContext;
+    std::unique_ptr<GrRenderTargetContext> dstRenderTargetContext;
 
     for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
         shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
@@ -404,15 +402,16 @@
 // Expand the contents of 'srcRenderTargetContext' to fit in 'dstII'. At this point, we are
 // expanding an intermediate image, so there's no need to account for a proxy offset from the
 // original input.
-static sk_sp<GrRenderTargetContext> reexpand(GrRecordingContext* context,
-                                             sk_sp<GrRenderTargetContext> srcRenderTargetContext,
-                                             const SkIRect& localSrcBounds,
-                                             int scaleFactorX, int scaleFactorY,
-                                             GrTextureDomain::Mode mode,
-                                             int finalW,
-                                             int finalH,
-                                             sk_sp<SkColorSpace> finalCS,
-                                             SkBackingFit fit) {
+static std::unique_ptr<GrRenderTargetContext> reexpand(
+        GrRecordingContext* context,
+        std::unique_ptr<GrRenderTargetContext> srcRenderTargetContext,
+        const SkIRect& localSrcBounds,
+        int scaleFactorX, int scaleFactorY,
+        GrTextureDomain::Mode mode,
+        int finalW,
+        int finalH,
+        sk_sp<SkColorSpace> finalCS,
+        SkBackingFit fit) {
     const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(),
                                             srcRenderTargetContext->height());
 
@@ -434,10 +433,9 @@
     // TODO: Once GrPixelConfig is gone we'll need the source's color type here.
     GrColorType colorType = get_blur_color_type(srcProxy.get());
 
-    sk_sp<GrRenderTargetContext> dstRenderTargetContext =
-            context->priv().makeDeferredRenderTargetContext(fit, finalW, finalH, colorType,
-                                                            std::move(finalCS), 1, GrMipMapped::kNo,
-                                                            srcProxy->origin());
+    auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
+            fit, finalW, finalH, colorType, std::move(finalCS), 1, GrMipMapped::kNo,
+            srcProxy->origin());
     if (!dstRenderTargetContext) {
         return nullptr;
     }
@@ -476,17 +474,17 @@
 
 namespace SkGpuBlurUtils {
 
-sk_sp<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
-                                          sk_sp<GrTextureProxy> srcProxy,
-                                          const SkIPoint& proxyOffset,
-                                          sk_sp<SkColorSpace> colorSpace,
-                                          const SkIRect& dstBounds,
-                                          const SkIRect& srcBounds,
-                                          float sigmaX,
-                                          float sigmaY,
-                                          GrTextureDomain::Mode mode,
-                                          SkAlphaType at,
-                                          SkBackingFit fit) {
+std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
+                                                    sk_sp<GrTextureProxy> srcProxy,
+                                                    const SkIPoint& proxyOffset,
+                                                    sk_sp<SkColorSpace> colorSpace,
+                                                    const SkIRect& dstBounds,
+                                                    const SkIRect& srcBounds,
+                                                    float sigmaX,
+                                                    float sigmaY,
+                                                    GrTextureDomain::Mode mode,
+                                                    SkAlphaType at,
+                                                    SkBackingFit fit) {
     SkASSERT(context);
 
     TRACE_EVENT2("skia.gpu", "GaussianBlur", "sigmaX", sigmaX, "sigmaY", sigmaY);
@@ -537,7 +535,7 @@
         }
     }
 
-    sk_sp<GrRenderTargetContext> dstRenderTargetContext;
+    std::unique_ptr<GrRenderTargetContext> dstRenderTargetContext;
 
     auto srcRect = SkIRect::MakeWH(finalW, finalH);
     scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
@@ -598,7 +596,6 @@
     SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin());
     return dstRenderTargetContext;
 }
-
 }
 
 #endif
diff --git a/src/core/SkGpuBlurUtils.h b/src/core/SkGpuBlurUtils.h
index 62da591..2184f02 100644
--- a/src/core/SkGpuBlurUtils.h
+++ b/src/core/SkGpuBlurUtils.h
@@ -42,18 +42,17 @@
     * @param fit             backing fit for the returned render target context
     * @return                The renderTargetContext containing the blurred result.
     */
-    sk_sp<GrRenderTargetContext> GaussianBlur(
-            GrRecordingContext* context,
-            sk_sp<GrTextureProxy> src,
-            const SkIPoint& proxyOffset,
-            sk_sp<SkColorSpace> colorSpace,
-            const SkIRect& dstBounds,
-            const SkIRect& srcBounds,
-            float sigmaX,
-            float sigmaY,
-            GrTextureDomain::Mode mode,
-            SkAlphaType at,
-            SkBackingFit fit = SkBackingFit::kApprox);
+std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
+                                                    sk_sp<GrTextureProxy> src,
+                                                    const SkIPoint& proxyOffset,
+                                                    sk_sp<SkColorSpace> colorSpace,
+                                                    const SkIRect& dstBounds,
+                                                    const SkIRect& srcBounds,
+                                                    float sigmaX,
+                                                    float sigmaY,
+                                                    GrTextureDomain::Mode mode,
+                                                    SkAlphaType at,
+                                                    SkBackingFit fit = SkBackingFit::kApprox);
 };
 
 #endif
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index e7d841b..36e9db9 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -413,19 +413,18 @@
     paint.addColorFragmentProcessor(std::move(fp));
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kApprox,
-                    bounds.width(),
-                    bounds.height(),
-                    SkColorTypeToGrColorType(colorType),
-                    sk_ref_sp(colorSpace),
-                    1,
-                    GrMipMapped::kNo,
-                    kBottomLeft_GrSurfaceOrigin,
-                    nullptr,
-                    SkBudgeted::kYes,
-                    isProtected));
+    auto renderTargetContext =
+            context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+                                                            bounds.width(),
+                                                            bounds.height(),
+                                                            SkColorTypeToGrColorType(colorType),
+                                                            sk_ref_sp(colorSpace),
+                                                            1,
+                                                            GrMipMapped::kNo,
+                                                            kBottomLeft_GrSurfaceOrigin,
+                                                            nullptr,
+                                                            SkBudgeted::kYes,
+                                                            isProtected);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 5de3e04..56d69ed 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -434,7 +434,7 @@
         if (!rec) {
             return false;
         }
-        sk_sp<GrSurfaceContext> sContext = fContext->priv().makeWrappedSurfaceContext(
+        auto sContext = fContext->priv().makeWrappedSurfaceContext(
                 fTextureProxy, GrPixelConfigToColorType(fTextureProxy->config()), this->alphaType(),
                 fColorSpace);
         if (!sContext) {
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 64b3e3b..2f6076f 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -117,54 +117,46 @@
 
 #if SK_SUPPORT_GPU
 ///////////////////////////////////////////////////////////////////////////////
-#include "include/gpu/GrBackendSurface.h"
 #include "include/private/GrRecordingContext.h"
+#include "src/core/SkMakeUnique.h"
 #include "src/gpu/GrRecordingContextPriv.h"
 #include "src/gpu/SkGpuDevice.h"
 
 class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
 public:
     SkSpecialSurface_Gpu(GrRecordingContext* context,
-                         sk_sp<GrRenderTargetContext> renderTargetContext,
+                         std::unique_ptr<GrRenderTargetContext> renderTargetContext,
                          int width, int height, const SkIRect& subset)
-        : INHERITED(subset, &renderTargetContext->surfaceProps())
-        , fRenderTargetContext(std::move(renderTargetContext)) {
-
+            : INHERITED(subset, &renderTargetContext->surfaceProps())
+            , fProxy(renderTargetContext->asTextureProxyRef()) {
         // CONTEXT TODO: remove this use of 'backdoor' to create an SkGpuDevice
-        sk_sp<SkBaseDevice> device(SkGpuDevice::Make(context->priv().backdoor(),
-                                                     fRenderTargetContext, width, height,
-                                                     SkGpuDevice::kUninit_InitContents));
+        auto device = SkGpuDevice::Make(context->priv().backdoor(), std::move(renderTargetContext),
+                                        SkGpuDevice::kUninit_InitContents);
         if (!device) {
             return;
         }
 
-        fCanvas.reset(new SkCanvas(device));
+        fCanvas.reset(new SkCanvas(std::move(device)));
         fCanvas->clipRect(SkRect::Make(subset));
 #ifdef SK_IS_BOT
         fCanvas->clear(SK_ColorRED);  // catch any imageFilter sloppiness
 #endif
     }
 
-    ~SkSpecialSurface_Gpu() override { }
-
     sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
-        if (!fRenderTargetContext->asTextureProxy()) {
+        if (!fProxy) {
             return nullptr;
         }
-        sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeDeferredFromGpu(
-                fCanvas->getGrContext(),
-                this->subset(),
-                kNeedNewImageUniqueID_SpecialImage,
-                fRenderTargetContext->asTextureProxyRef(),
-                fRenderTargetContext->colorSpaceInfo().refColorSpace(),
-                &this->props()));
-        fRenderTargetContext = nullptr;
-        return tmp;
+        return SkSpecialImage::MakeDeferredFromGpu(fCanvas->getGrContext(),
+                                                   this->subset(),
+                                                   kNeedNewImageUniqueID_SpecialImage,
+                                                   std::move(fProxy),
+                                                   fCanvas->imageInfo().refColorSpace(),
+                                                   &this->props());
     }
 
 private:
-    sk_sp<GrRenderTargetContext> fRenderTargetContext;
-
+    sk_sp<GrTextureProxy> fProxy;
     typedef SkSpecialSurface_Base INHERITED;
 };
 
@@ -176,10 +168,9 @@
     if (!context) {
         return nullptr;
     }
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1,
-                    GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props));
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
+            SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1,
+            GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index 9e506cd..a9337a0 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -103,10 +103,8 @@
 sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
                                                                     const SkMatrix& inMatrix,
                                                                     const SkIRect& bounds) const {
-    sk_sp<GrRenderTargetContext> rtContext(
-            context->priv().makeDeferredRenderTargetContextWithFallback(
-                    SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8,
-                    nullptr));
+    auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8, nullptr);
     if (!rtContext) {
         return nullptr;
     }
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 740af12..f473294 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -401,19 +401,18 @@
 
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kApprox,
-                    bounds.width(),
-                    bounds.height(),
-                    ctx.grColorType(),
-                    ctx.refColorSpace(),
-                    1,
-                    GrMipMapped::kNo,
-                    kBottomLeft_GrSurfaceOrigin,
-                    nullptr,
-                    SkBudgeted::kYes,
-                    isProtected));
+    auto renderTargetContext =
+            context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+                                                            bounds.width(),
+                                                            bounds.height(),
+                                                            ctx.grColorType(),
+                                                            ctx.refColorSpace(),
+                                                            1,
+                                                            GrMipMapped::kNo,
+                                                            kBottomLeft_GrSurfaceOrigin,
+                                                            nullptr,
+                                                            SkBudgeted::kYes,
+                                                            isProtected);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/effects/imagefilters/SkBlurImageFilter.cpp b/src/effects/imagefilters/SkBlurImageFilter.cpp
index 67aa3dc..df058c1 100644
--- a/src/effects/imagefilters/SkBlurImageFilter.cpp
+++ b/src/effects/imagefilters/SkBlurImageFilter.cpp
@@ -649,17 +649,17 @@
     }
 
     // TODO (michaelludwig) - The color space choice is odd, should it just be ctx.refColorSpace()?
-    sk_sp<GrRenderTargetContext> renderTargetContext(SkGpuBlurUtils::GaussianBlur(
-                            context,
-                            std::move(inputTexture),
-                            input->subset().topLeft(),
-                            ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
-                            dstBounds,
-                            inputBounds,
-                            sigma.x(),
-                            sigma.y(),
-                            to_texture_domain_mode(fTileMode),
-                            input->alphaType()));
+    auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(
+            context,
+            std::move(inputTexture),
+            input->subset().topLeft(),
+            ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
+            dstBounds,
+            inputBounds,
+            sigma.x(),
+            sigma.y(),
+            to_texture_domain_mode(fTileMode),
+            input->alphaType());
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 8aea375..595fa89 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -363,7 +363,7 @@
         SkMatrix matrix;
         matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
 
-        sk_sp<GrRenderTargetContext> renderTargetContext(
+        auto renderTargetContext =
                 context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
                                                                 bounds.width(),
                                                                 bounds.height(),
@@ -374,7 +374,7 @@
                                                                 kBottomLeft_GrSurfaceOrigin,
                                                                 nullptr,
                                                                 SkBudgeted::kYes,
-                                                                isProtected));
+                                                                isProtected);
         if (!renderTargetContext) {
             return nullptr;
         }
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 28b34df..db5aac4 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -480,19 +480,18 @@
     sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
     SkASSERT(inputProxy);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kApprox,
-                    offsetBounds.width(),
-                    offsetBounds.height(),
-                    ctx.grColorType(),
-                    ctx.refColorSpace(),
-                    1,
-                    GrMipMapped::kNo,
-                    kBottomLeft_GrSurfaceOrigin,
-                    nullptr,
-                    SkBudgeted::kYes,
-                    inputProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo));
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
+            SkBackingFit::kApprox,
+            offsetBounds.width(),
+            offsetBounds.height(),
+            ctx.grColorType(),
+            ctx.refColorSpace(),
+            1,
+            GrMipMapped::kNo,
+            kBottomLeft_GrSurfaceOrigin,
+            nullptr,
+            SkBudgeted::kYes,
+            inputProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 4ffda89..2f1a008 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -559,7 +559,7 @@
     SkASSERT(radius.width() > 0 || radius.height() > 0);
 
     if (radius.fWidth > 0) {
-        sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
+        auto dstRTContext = context->priv().makeDeferredRenderTargetContext(
                 SkBackingFit::kApprox,
                 rect.width(),
                 rect.height(),
@@ -570,7 +570,7 @@
                 kBottomLeft_GrSurfaceOrigin,
                 nullptr,
                 SkBudgeted::kYes,
-                srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
+                srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo);
         if (!dstRTContext) {
             return nullptr;
         }
@@ -587,7 +587,7 @@
         srcRect = dstRect;
     }
     if (radius.fHeight > 0) {
-        sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
+        auto dstRTContext = context->priv().makeDeferredRenderTargetContext(
                 SkBackingFit::kApprox,
                 rect.width(),
                 rect.height(),
@@ -598,7 +598,7 @@
                 kBottomLeft_GrSurfaceOrigin,
                 nullptr,
                 SkBudgeted::kYes,
-                srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
+                srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo);
         if (!dstRTContext) {
             return nullptr;
         }
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index 1a07ab6..24ecf58 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -305,10 +305,9 @@
 
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(),
-                    ctx.refColorSpace()));
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
+            SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(),
+            ctx.refColorSpace());
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index d6353ab..e84f6b8 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -174,11 +174,9 @@
                                              const SkMatrix& origViewMatrix,
                                              const GrShape& shape,
                                              int sampleCnt) {
-    sk_sp<GrRenderTargetContext> rtContext(
-            context->priv().makeDeferredRenderTargetContextWithFallback(
-                    SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
-                    GrColorType::kAlpha_8, nullptr, sampleCnt, GrMipMapped::kNo,
-                    kTopLeft_GrSurfaceOrigin));
+    auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kApprox, maskRect.width(), maskRect.height(), GrColorType::kAlpha_8,
+            nullptr, sampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
     if (!rtContext) {
         return nullptr;
     }
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 90c3e64..07470ce 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -356,18 +356,17 @@
     }
 
     auto isProtected = proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo;
-    sk_sp<GrRenderTargetContext> rtc(
-            context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
-                                                                        reducedClip.width(),
-                                                                        reducedClip.height(),
-                                                                        GrColorType::kAlpha_8,
-                                                                        nullptr,
-                                                                        1,
-                                                                        GrMipMapped::kNo,
-                                                                        kTopLeft_GrSurfaceOrigin,
-                                                                        nullptr,
-                                                                        SkBudgeted::kYes,
-                                                                        isProtected));
+    auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
+                                                                           reducedClip.width(),
+                                                                           reducedClip.height(),
+                                                                           GrColorType::kAlpha_8,
+                                                                           nullptr,
+                                                                           1,
+                                                                           GrMipMapped::kNo,
+                                                                           kTopLeft_GrSurfaceOrigin,
+                                                                           nullptr,
+                                                                           SkBudgeted::kYes,
+                                                                           isProtected);
     if (!rtc) {
         return nullptr;
     }
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index 78a41d2..d6188dc 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -48,31 +48,33 @@
     fContext->addOnFlushCallbackObject(onFlushCBObject);
 }
 
-sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
-                                                                 GrColorType colorType,
-                                                                 SkAlphaType alphaType,
-                                                                 sk_sp<SkColorSpace> colorSpace,
-                                                                 const SkSurfaceProps* props) {
+std::unique_ptr<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(
+        sk_sp<GrSurfaceProxy> proxy,
+        GrColorType colorType,
+        SkAlphaType alphaType,
+        sk_sp<SkColorSpace> colorSpace,
+        const SkSurfaceProps* props) {
     return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType,
                                                std::move(colorSpace), props);
 }
 
-sk_sp<GrTextureContext> GrContextPriv::makeDeferredTextureContext(SkBackingFit fit,
-                                                                  int width,
-                                                                  int height,
-                                                                  GrColorType colorType,
-                                                                  SkAlphaType alphaType,
-                                                                  sk_sp<SkColorSpace> colorSpace,
-                                                                  GrMipMapped mipMapped,
-                                                                  GrSurfaceOrigin origin,
-                                                                  SkBudgeted budgeted,
-                                                                  GrProtected isProtected) {
+std::unique_ptr<GrTextureContext> GrContextPriv::makeDeferredTextureContext(
+        SkBackingFit fit,
+        int width,
+        int height,
+        GrColorType colorType,
+        SkAlphaType alphaType,
+        sk_sp<SkColorSpace> colorSpace,
+        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> GrContextPriv::makeDeferredRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
         SkBackingFit fit,
         int width,
         int height,
@@ -89,7 +91,7 @@
                                                      origin, surfaceProps, budgeted, isProtected);
 }
 
-sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
+std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
         SkBackingFit fit, int width, int height, GrColorType colorType,
         sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
         GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted) {
@@ -98,11 +100,12 @@
             surfaceProps, budgeted);
 }
 
-sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
-                                                                 GrSurfaceOrigin origin,
-                                                                 GrColorType colorType,
-                                                                 SkAlphaType alphaType,
-                                                                 sk_sp<SkColorSpace> colorSpace) {
+std::unique_ptr<GrTextureContext> GrContextPriv::makeBackendTextureContext(
+        const GrBackendTexture& tex,
+        GrSurfaceOrigin origin,
+        GrColorType colorType,
+        SkAlphaType alphaType,
+        sk_sp<SkColorSpace> colorSpace) {
     ASSERT_SINGLE_OWNER
 
     sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
@@ -115,7 +118,7 @@
                                                       std::move(colorSpace));
 }
 
-sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
         const GrBackendTexture& tex,
         GrSurfaceOrigin origin,
         int sampleCnt,
@@ -138,7 +141,7 @@
                                                            std::move(colorSpace), props);
 }
 
-sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
         const GrBackendRenderTarget& backendRT,
         GrSurfaceOrigin origin,
         GrColorType colorType,
@@ -158,13 +161,13 @@
                                                            std::move(colorSpace), surfaceProps);
 }
 
-sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRenderTargetContext(
-        const GrBackendTexture& tex,
-        GrSurfaceOrigin origin,
-        int sampleCnt,
-        GrColorType colorType,
-        sk_sp<SkColorSpace> colorSpace,
-        const SkSurfaceProps* props) {
+std::unique_ptr<GrRenderTargetContext>
+GrContextPriv::makeBackendTextureAsRenderTargetRenderTargetContext(const GrBackendTexture& tex,
+                                                                   GrSurfaceOrigin origin,
+                                                                   int sampleCnt,
+                                                                   GrColorType colorType,
+                                                                   sk_sp<SkColorSpace> colorSpace,
+                                                                   const SkSurfaceProps* props) {
     ASSERT_SINGLE_OWNER
     SkASSERT(sampleCnt > 0);
     sk_sp<GrSurfaceProxy> proxy(
@@ -178,7 +181,7 @@
                                                            std::move(colorSpace), props);
 }
 
-sk_sp<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
         const SkImageInfo& imageInfo, const GrVkDrawableInfo& vkInfo, const SkSurfaceProps* props) {
     ASSERT_SINGLE_OWNER
     sk_sp<GrSurfaceProxy> proxy(
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 10f18de..13502d5 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -73,14 +73,14 @@
      */
     void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
 
-    sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
-                                                      GrColorType,
-                                                      SkAlphaType,
-                                                      sk_sp<SkColorSpace> = nullptr,
-                                                      const SkSurfaceProps* = nullptr);
+    std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
+                                                                GrColorType,
+                                                                SkAlphaType,
+                                                                sk_sp<SkColorSpace> = nullptr,
+                                                                const SkSurfaceProps* = nullptr);
 
     /** Create a new texture context backed by a deferred-style GrTextureProxy. */
-    sk_sp<GrTextureContext> makeDeferredTextureContext(
+    std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
             SkBackingFit,
             int width,
             int height,
@@ -97,7 +97,7 @@
      * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
      * renderTargetContexts created via this entry point.
      */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext(
             SkBackingFit fit,
             int width,
             int height,
@@ -116,7 +116,7 @@
      * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
      * SRGB-ness will be preserved.
      */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
+    std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
             SkBackingFit fit,
             int width,
             int height,
@@ -135,17 +135,17 @@
      */
     static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&);
 
-    sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&,
-                                                      GrSurfaceOrigin,
-                                                      GrColorType,
-                                                      SkAlphaType,
-                                                      sk_sp<SkColorSpace>);
+    std::unique_ptr<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&,
+                                                                GrSurfaceOrigin,
+                                                                GrColorType,
+                                                                SkAlphaType,
+                                                                sk_sp<SkColorSpace>);
 
     // These match the definitions in SkSurface & GrSurface.h, for whence they came
     typedef void* ReleaseContext;
     typedef void (*ReleaseProc)(ReleaseContext);
 
-    sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
             const GrBackendTexture& tex,
             GrSurfaceOrigin origin,
             int sampleCnt,
@@ -155,7 +155,7 @@
             ReleaseProc = nullptr,
             ReleaseContext = nullptr);
 
-    sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
             const GrBackendRenderTarget&,
             GrSurfaceOrigin origin,
             GrColorType,
@@ -164,7 +164,7 @@
             ReleaseProc = nullptr,
             ReleaseContext = nullptr);
 
-    sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
             const GrBackendTexture& tex,
             GrSurfaceOrigin origin,
             int sampleCnt,
@@ -172,7 +172,7 @@
             sk_sp<SkColorSpace> colorSpace,
             const SkSurfaceProps* = nullptr);
 
-    sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
             const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr);
 
     /**
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 62dfe44..3017d4f 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -281,11 +281,11 @@
     if (!fOnFlushCBObjects.empty()) {
         fDAG.gatherIDs(&fFlushingRenderTaskIDs);
 
-        SkSTArray<4, sk_sp<GrRenderTargetContext>> renderTargetContexts;
+        SkSTArray<4, std::unique_ptr<GrRenderTargetContext>> renderTargetContexts;
         for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
             onFlushCBObject->preFlush(&onFlushProvider, fFlushingRenderTaskIDs.begin(),
                                       fFlushingRenderTaskIDs.count(), &renderTargetContexts);
-            for (const sk_sp<GrRenderTargetContext>& rtc : renderTargetContexts) {
+            for (const auto& rtc : renderTargetContexts) {
                 sk_sp<GrRenderTargetOpList> onFlushOpList = sk_ref_sp(rtc->getRTOpList());
                 if (!onFlushOpList) {
                     continue;   // Odd - but not a big deal
@@ -794,7 +794,7 @@
     }
 }
 
-sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
         sk_sp<GrSurfaceProxy> sProxy,
         GrColorType colorType,
         sk_sp<SkColorSpace> colorSpace,
@@ -813,18 +813,20 @@
 
     sk_sp<GrRenderTargetProxy> renderTargetProxy(sk_ref_sp(sProxy->asRenderTargetProxy()));
 
-    return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext,
-                                                                  std::move(renderTargetProxy),
-                                                                  colorType,
-                                                                  std::move(colorSpace),
-                                                                  surfaceProps,
-                                                                  managedOpList));
+    return std::unique_ptr<GrRenderTargetContext>(
+            new GrRenderTargetContext(fContext,
+                                      std::move(renderTargetProxy),
+                                      colorType,
+                                      std::move(colorSpace),
+                                      surfaceProps,
+                                      managedOpList));
 }
 
-sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
-                                                             GrColorType colorType,
-                                                             SkAlphaType alphaType,
-                                                             sk_sp<SkColorSpace> colorSpace) {
+std::unique_ptr<GrTextureContext> GrDrawingManager::makeTextureContext(
+        sk_sp<GrSurfaceProxy> sProxy,
+        GrColorType colorType,
+        SkAlphaType alphaType,
+        sk_sp<SkColorSpace> colorSpace) {
     if (this->wasAbandoned() || !sProxy->asTextureProxy()) {
         return nullptr;
     }
@@ -841,9 +843,6 @@
 
     sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
 
-    return sk_sp<GrTextureContext>(new GrTextureContext(fContext,
-                                                        std::move(textureProxy),
-                                                        colorType,
-                                                        alphaType,
-                                                        std::move(colorSpace)));
+    return std::unique_ptr<GrTextureContext>(new GrTextureContext(
+            fContext, std::move(textureProxy), colorType, alphaType, std::move(colorSpace)));
 }
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 13e2f55..5fd27bd 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -37,15 +37,15 @@
 
     void freeGpuResources();
 
-    sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+    std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+                                                                   GrColorType,
+                                                                   sk_sp<SkColorSpace>,
+                                                                   const SkSurfaceProps*,
+                                                                   bool managedOpList = true);
+    std::unique_ptr<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
                                                          GrColorType,
-                                                         sk_sp<SkColorSpace>,
-                                                         const SkSurfaceProps*,
-                                                         bool managedOpList = true);
-    sk_sp<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
-                                               GrColorType,
-                                               SkAlphaType,
-                                               sk_sp<SkColorSpace>);
+                                                         SkAlphaType,
+                                                         sk_sp<SkColorSpace>);
 
     // A managed opList is controlled by the drawing manager (i.e., sorted & flushed with the
     // others). An unmanaged one is created and used by the onFlushCallback.
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 244a0db..32c6585 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -15,7 +15,7 @@
 #include "src/gpu/GrRenderTargetContext.h"
 #include "src/gpu/GrSurfaceProxy.h"
 
-sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
         sk_sp<GrSurfaceProxy> proxy,
         GrColorType colorType,
         sk_sp<SkColorSpace> colorSpace,
@@ -27,8 +27,8 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(fDrawingMgr->makeRenderTargetContext(
-            std::move(proxy), colorType, std::move(colorSpace), props, false));
+    auto renderTargetContext = fDrawingMgr->makeRenderTargetContext(
+            std::move(proxy), colorType, std::move(colorSpace), props, false);
 
     if (!renderTargetContext) {
         return nullptr;
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index 40a8afd..cc36c10 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -37,9 +37,8 @@
      * callback. The callback should return the render target contexts used to render the atlases
      * in 'results'.
      */
-    virtual void preFlush(GrOnFlushResourceProvider*,
-                          const uint32_t* opListIDs, int numOpListIDs,
-                          SkTArray<sk_sp<GrRenderTargetContext>>* results) = 0;
+    virtual void preFlush(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs,
+                          SkTArray<std::unique_ptr<GrRenderTargetContext>>* results) = 0;
 
     /**
      * Called once flushing is complete and all ops indicated by preFlush have been executed and
@@ -66,10 +65,10 @@
 public:
     explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
 
-    sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
-                                                         GrColorType,
-                                                         sk_sp<SkColorSpace>,
-                                                         const SkSurfaceProps*);
+    std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+                                                                   GrColorType,
+                                                                   sk_sp<SkColorSpace>,
+                                                                   const SkSurfaceProps*);
 
     // Proxy unique key management. See GrProxyProvider.h.
     bool assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index 0959dfe..58544ed 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -143,7 +143,7 @@
     this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject);
 }
 
-sk_sp<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
+std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
         sk_sp<GrSurfaceProxy> proxy,
         GrColorType colorType,
         SkAlphaType alphaType,
@@ -165,7 +165,7 @@
     }
 }
 
-sk_sp<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
+std::unique_ptr<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
         SkBackingFit fit,
         int width,
         int height,
@@ -208,7 +208,7 @@
                                               std::move(colorSpace));
 }
 
-sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
         SkBackingFit fit,
         int width,
         int height,
@@ -253,7 +253,7 @@
 
     auto drawingManager = this->drawingManager();
 
-    sk_sp<GrRenderTargetContext> renderTargetContext = drawingManager->makeRenderTargetContext(
+    auto renderTargetContext = drawingManager->makeRenderTargetContext(
             std::move(rtp), colorType, std::move(colorSpace), surfaceProps);
     if (!renderTargetContext) {
         return nullptr;
@@ -285,20 +285,20 @@
     }
 }
 
-sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback(
-        SkBackingFit fit,
-        int width,
-        int height,
-        GrColorType colorType,
-        sk_sp<SkColorSpace> colorSpace,
-        int sampleCnt,
-        GrMipMapped mipMapped,
-        GrSurfaceOrigin origin,
-        const SkSurfaceProps* surfaceProps,
-        SkBudgeted budgeted,
-        GrProtected isProtected) {
+std::unique_ptr<GrRenderTargetContext>
+GrRecordingContext::makeDeferredRenderTargetContextWithFallback(SkBackingFit fit,
+                                                                int width,
+                                                                int height,
+                                                                GrColorType colorType,
+                                                                sk_sp<SkColorSpace> colorSpace,
+                                                                int sampleCnt,
+                                                                GrMipMapped mipMapped,
+                                                                GrSurfaceOrigin origin,
+                                                                const SkSurfaceProps* surfaceProps,
+                                                                SkBudgeted budgeted,
+                                                                GrProtected isProtected) {
     SkASSERT(sampleCnt > 0);
-    sk_sp<GrRenderTargetContext> rtc;
+    std::unique_ptr<GrRenderTargetContext> rtc;
     do {
         rtc = this->makeDeferredRenderTargetContext(fit, width, height, colorType, colorSpace,
                                                     sampleCnt, mipMapped, origin, surfaceProps,
@@ -325,7 +325,7 @@
     fContext->addOnFlushCallbackObject(onFlushCBObject);
 }
 
-sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
+std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
         sk_sp<GrSurfaceProxy> proxy,
         GrColorType colorType,
         SkAlphaType alphaType,
@@ -335,7 +335,7 @@
                                                std::move(colorSpace), props);
 }
 
-sk_sp<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
+std::unique_ptr<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
         SkBackingFit fit,
         int width,
         int height,
@@ -351,7 +351,7 @@
                                                 isProtected);
 }
 
-sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
         SkBackingFit fit,
         int width,
         int height,
@@ -368,7 +368,8 @@
                                                      origin, surfaceProps, budgeted, isProtected);
 }
 
-sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
+std::unique_ptr<GrRenderTargetContext>
+GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
         SkBackingFit fit,
         int width,
         int height,
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index 62ec136..2987778 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -57,14 +57,14 @@
      */
     void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
 
-    sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
-                                                      GrColorType,
-                                                      SkAlphaType,
-                                                      sk_sp<SkColorSpace> = nullptr,
-                                                      const SkSurfaceProps* = nullptr);
+    std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
+                                                                GrColorType,
+                                                                SkAlphaType,
+                                                                sk_sp<SkColorSpace> = nullptr,
+                                                                const SkSurfaceProps* = nullptr);
 
     /** Create a new texture context backed by a deferred-style GrTextureProxy. */
-    sk_sp<GrTextureContext> makeDeferredTextureContext(
+    std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
             SkBackingFit,
             int width,
             int height,
@@ -81,7 +81,7 @@
      * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
      * renderTargetContexts created via this entry point.
      */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
+    std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext(
             SkBackingFit fit,
             int width,
             int height,
@@ -100,7 +100,7 @@
      * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
      * SRGB-ness will be preserved.
      */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
+    std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
             SkBackingFit fit,
             int width,
             int height,
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index ae38228..8dda267 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1602,17 +1602,17 @@
         return;
     }
 
-    sk_sp<GrRenderTargetContext> rtc;
+    std::unique_ptr<GrRenderTargetContext> tempRTC;
     int x = srcRect.fLeft;
     int y = srcRect.fTop;
     if (needsRescale) {
-        rtc = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
-        if (!rtc) {
+        tempRTC = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
+        if (!tempRTC) {
             callback(context, nullptr, 0);
             return;
         }
-        SkASSERT(SkColorSpace::Equals(rtc->colorSpaceInfo().colorSpace(), info.colorSpace()));
-        SkASSERT(rtc->origin() == kTopLeft_GrSurfaceOrigin);
+        SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
+        SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
         x = y = 0;
     } else {
         sk_sp<GrColorSpaceXform> xform =
@@ -1640,24 +1640,23 @@
                 }
                 srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height());
             }
-            rtc = direct->priv().makeDeferredRenderTargetContext(
+            tempRTC = direct->priv().makeDeferredRenderTargetContext(
                     SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
                     this->colorSpaceInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo,
                     kTopLeft_GrSurfaceOrigin);
-            if (!rtc) {
+            if (!tempRTC) {
                 callback(context, nullptr, 0);
                 return;
             }
-            rtc->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
-                             SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
-                             SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
-                             GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
-                             std::move(xform));
+            tempRTC->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
+                                 SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
+                                 SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
+                                 GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
+                                 SkMatrix::I(), std::move(xform));
             x = y = 0;
-        } else {
-            rtc = sk_ref_sp(this);
         }
     }
+    auto rtc = tempRTC ? tempRTC.get() : this;
     return rtc->asyncReadPixels(SkIRect::MakeXYWH(x, y, info.width(), info.height()),
                                 info.colorType(), callback, context);
 }
@@ -1740,20 +1739,20 @@
     }
     int x = srcRect.fLeft;
     int y = srcRect.fTop;
-    auto rtc = sk_ref_sp(this);
+    std::unique_ptr<GrRenderTargetContext> tempRTC;
     bool needsRescale = srcRect.width() != dstW || srcRect.height() != dstH;
     if (needsRescale) {
         // We assume the caller wants kPremul. There is no way to indicate a preference.
         auto info = SkImageInfo::Make(dstW, dstH, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
                                       dstColorSpace);
         // TODO: Incorporate the YUV conversion into last pass of rescaling.
-        rtc = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
-        if (!rtc) {
+        tempRTC = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
+        if (!tempRTC) {
             callback(context, nullptr, nullptr);
             return;
         }
-        SkASSERT(SkColorSpace::Equals(rtc->colorSpaceInfo().colorSpace(), info.colorSpace()));
-        SkASSERT(rtc->origin() == kTopLeft_GrSurfaceOrigin);
+        SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
+        SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
         x = y = 0;
     } else {
         // We assume the caller wants kPremul. There is no way to indicate a preference.
@@ -1768,22 +1767,22 @@
                 return;
             }
             SkRect srcRectToDraw = SkRect::Make(srcRect);
-            rtc = direct->priv().makeDeferredRenderTargetContext(
+            tempRTC = direct->priv().makeDeferredRenderTargetContext(
                     SkBackingFit::kApprox, dstW, dstH, this->colorSpaceInfo().colorType(),
                     dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
-            if (!rtc) {
+            if (!tempRTC) {
                 callback(context, nullptr, nullptr);
                 return;
             }
-            rtc->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
-                             SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
-                             SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
-                             GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
-                             std::move(xform));
+            tempRTC->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
+                                 SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
+                                 SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
+                                 GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
+                                 SkMatrix::I(), std::move(xform));
             x = y = 0;
         }
     }
-    auto srcProxy = rtc->asTextureProxyRef();
+    auto srcProxy = tempRTC ? tempRTC->asTextureProxyRef() : this->asTextureProxyRef();
     // TODO: Do something if the input is not a texture already.
     if (!srcProxy) {
         callback(context, nullptr, nullptr);
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 15a7932..9ffe1b5 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -194,7 +194,7 @@
     // care about is that it is not converted. So we use the same alpha type for the data
     // and the surface context.
     static constexpr auto kAlphaType = kUnpremul_SkAlphaType;
-    sk_sp<GrSurfaceContext> sContext =
+    auto sContext =
             context->priv().makeWrappedSurfaceContext(std::move(proxy), srcColorType, kAlphaType);
     if (!sContext) {
         return nullptr;
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 6d66634..3ab7a1f 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -136,7 +136,7 @@
         sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr
                                                   : this->colorSpaceInfo().refColorSpace();
 
-        sk_sp<GrRenderTargetContext> tempCtx = direct->priv().makeDeferredRenderTargetContext(
+        auto tempCtx = direct->priv().makeDeferredRenderTargetContext(
                 SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs),
                 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes);
         if (!tempCtx) {
@@ -428,10 +428,11 @@
     return this->getOpList()->copySurface(fContext, src, srcRect, dstPoint);
 }
 
-sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
-                                                       const SkIRect& srcRect,
-                                                       SkSurface::RescaleGamma rescaleGamma,
-                                                       SkFilterQuality rescaleQuality) {
+std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
+        const SkImageInfo& info,
+        const SkIRect& srcRect,
+        SkSurface::RescaleGamma rescaleGamma,
+        SkFilterQuality rescaleQuality) {
     auto direct = fContext->priv().asDirectContext();
     if (!direct) {
         return nullptr;
@@ -477,7 +478,11 @@
         stepsY = sy != 1.f;
     }
     SkASSERT(stepsX || stepsY);
-    auto currCtx = sk_ref_sp(this);
+    // Within a rescaling pass A is the input (if not null) and B is the output. At the end of the
+    // pass B is moved to A. If 'this' is the input on the first pass then tempA is null.
+    std::unique_ptr<GrRenderTargetContext> tempA;
+    std::unique_ptr<GrRenderTargetContext> tempB;
+
     // Assume we should ignore the rescale linear request if the surface has no color space since
     // it's unclear how we'd linearize from an unknown color space.
     if (rescaleGamma == SkSurface::kLinear && this->colorSpaceInfo().colorSpace() &&
@@ -498,7 +503,7 @@
                                SkRect::MakeWH(srcW, srcH), GrAA::kNo, GrQuadAAFlags::kNone,
                                constraint, SkMatrix::I(), std::move(xform));
         texProxy = linearRTC->asTextureProxyRef();
-        currCtx = std::move(linearRTC);
+        tempA = std::move(linearRTC);
         srcX = 0;
         srcY = 0;
         constraint = SkCanvas::kFast_SrcRectConstraint;
@@ -524,23 +529,23 @@
             }
             --stepsY;
         }
-        GrColorType colorType = currCtx->colorSpaceInfo().colorType();
-        auto cs = currCtx->colorSpaceInfo().refColorSpace();
+        auto input = tempA ? tempA.get() : this;
+        GrColorType colorType = input->colorSpaceInfo().colorType();
+        auto cs = input->colorSpaceInfo().refColorSpace();
         sk_sp<GrColorSpaceXform> xform;
-        auto prevAlphaType = currCtx->colorSpaceInfo().alphaType();
+        auto prevAlphaType = input->colorSpaceInfo().alphaType();
         if (!stepsX && !stepsY) {
             // Might as well fold conversion to final info in the last step.
             cs = info.refColorSpace();
             colorType = SkColorTypeToGrColorType(info.colorType());
-            xform = GrColorSpaceXform::Make(currCtx->colorSpaceInfo().colorSpace(),
-                                            currCtx->colorSpaceInfo().alphaType(), cs.get(),
+            xform = GrColorSpaceXform::Make(input->colorSpaceInfo().colorSpace(),
+                                            input->colorSpaceInfo().alphaType(), cs.get(),
                                             info.alphaType());
         }
-        auto currRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
+        tempB = fContext->priv().makeDeferredRenderTargetContextWithFallback(
                 SkBackingFit::kExact, nextW, nextH, colorType, std::move(cs), 1, GrMipMapped::kNo,
                 kTopLeft_GrSurfaceOrigin);
-        currCtx = currRTC;
-        if (!currCtx) {
+        if (!tempB) {
             return nullptr;
         }
         auto dstRect = SkRect::MakeWH(nextW, nextH);
@@ -567,24 +572,25 @@
             GrPaint paint;
             paint.addColorFragmentProcessor(std::move(fp));
             paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
-            currRTC->fillRectToRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
+            tempB->fillRectToRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
                                     dstRect);
         } else {
             auto filter = rescaleQuality == kNone_SkFilterQuality ? GrSamplerState::Filter::kNearest
                                                                   : GrSamplerState::Filter::kBilerp;
             auto srcSubset = SkRect::MakeXYWH(srcX, srcY, srcW, srcH);
-            currRTC->drawTexture(GrNoClip(), texProxy, filter, SkBlendMode::kSrc, SK_PMColor4fWHITE,
+            tempB->drawTexture(GrNoClip(), texProxy, filter, SkBlendMode::kSrc, SK_PMColor4fWHITE,
                                  srcSubset, dstRect, GrAA::kNo, GrQuadAAFlags::kNone, constraint,
                                  SkMatrix::I(), std::move(xform));
         }
-        texProxy = currCtx->asTextureProxyRef();
+        texProxy = tempB->asTextureProxyRef();
+        tempA = std::move(tempB);
         srcX = srcY = 0;
         srcW = nextW;
         srcH = nextH;
         constraint = SkCanvas::kFast_SrcRectConstraint;
     }
-    SkASSERT(currCtx);
-    return sk_ref_sp(currCtx->asRenderTargetContext());
+    SkASSERT(tempA);
+    return tempA;
 }
 
 GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorType dstCT,
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 735c6dd..8c66ac9 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -34,9 +34,9 @@
 /**
  * A helper object to orchestrate commands for a particular surface
  */
-class SK_API GrSurfaceContext : public SkRefCnt {
+class SK_API GrSurfaceContext {
 public:
-    ~GrSurfaceContext() override {}
+    virtual ~GrSurfaceContext() = default;
 
     const GrColorSpaceInfo& colorSpaceInfo() const { return fColorSpaceInfo; }
 
@@ -118,9 +118,9 @@
     GrRecordingContext* fContext;
 
     // The rescaling step of asyncRescaleAndReadPixels[YUV420]().
-    sk_sp<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
-                                         SkSurface::RescaleGamma rescaleGamma,
-                                         SkFilterQuality rescaleQuality);
+    std::unique_ptr<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
+                                                   SkSurface::RescaleGamma rescaleGamma,
+                                                   SkFilterQuality rescaleQuality);
 
     // Inserts a transfer, part of the implementation of asyncReadPixels and
     // asyncRescaleAndReadPixelsYUV420().
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 20ca806..b1f4ebf 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -370,9 +370,9 @@
     }
     auto colorType = GrPixelConfigToColorType(src->config());
     if (src->backendFormat().textureType() != GrTextureType::kExternal) {
-        sk_sp<GrTextureContext> dstContext(context->priv().makeDeferredTextureContext(
+        auto dstContext = context->priv().makeDeferredTextureContext(
                 fit, width, height, colorType, kUnknown_SkAlphaType, nullptr, mipMapped,
-                src->origin(), budgeted, isProtected));
+                src->origin(), budgeted, isProtected);
         if (!dstContext) {
             return nullptr;
         }
@@ -381,7 +381,7 @@
         }
     }
     if (src->asTextureProxy()) {
-        sk_sp<GrRenderTargetContext> dstContext = context->priv().makeDeferredRenderTargetContext(
+        auto dstContext = context->priv().makeDeferredRenderTargetContext(
                 fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr,
                 budgeted);
 
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 6966dd8..73f7113 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -48,10 +48,9 @@
         }
     }
 
-    sk_sp<GrRenderTargetContext> copyRTC =
-            context->priv().makeDeferredRenderTargetContextWithFallback(
-                    SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1,
-                    mipMapped, inputProxy->origin());
+    auto copyRTC = context->priv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1,
+            mipMapped, inputProxy->origin());
     if (!copyRTC) {
         return nullptr;
     }
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index baabcf0..b61b8c3 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -158,9 +158,9 @@
     }
 
     // TODO: investigate preallocating mip maps here
-    sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
+    auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext(
             SkBackingFit::kExact, desc.fWidth, desc.fHeight, colorType, nullptr, 1,
-            GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+            GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index fb4c537..e3377c9 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -81,8 +81,7 @@
 }
 
 sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context,
-                                     sk_sp<GrRenderTargetContext> renderTargetContext,
-                                     int width, int height,
+                                     std::unique_ptr<GrRenderTargetContext> renderTargetContext,
                                      InitContents init) {
     if (!renderTargetContext || context->priv().abandoned()) {
         return nullptr;
@@ -91,8 +90,7 @@
     if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
         return nullptr;
     }
-    return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext),
-                                              width, height, flags));
+    return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), flags));
 }
 
 sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
@@ -104,51 +102,42 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(MakeRenderTargetContext(context, budgeted,
-                                                                             info, sampleCount,
-                                                                             origin, props,
-                                                                             mipMapped));
+    auto renderTargetContext =
+            MakeRenderTargetContext(context, budgeted, info, sampleCount, origin, props, mipMapped);
     if (!renderTargetContext) {
         return nullptr;
     }
 
-    return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext),
-                                              info.width(), info.height(), flags));
+    return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), flags));
 }
 
-static SkImageInfo make_info(GrRenderTargetContext* context, int w, int h, bool opaque) {
+static SkImageInfo make_info(GrRenderTargetContext* context, bool opaque) {
     SkColorType colorType = GrColorTypeToSkColorType(context->colorSpaceInfo().colorType());
-    return SkImageInfo::Make(w, h, colorType, opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
+    return SkImageInfo::Make(context->width(), context->height(), colorType,
+                             opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
                              context->colorSpaceInfo().refColorSpace());
 }
 
-SkGpuDevice::SkGpuDevice(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext,
-                         int width, int height, unsigned flags)
-    : INHERITED(make_info(renderTargetContext.get(), width, height,
-                          SkToBool(flags & kIsOpaque_Flag)), renderTargetContext->surfaceProps())
-    , fContext(SkRef(context))
-    , fRenderTargetContext(std::move(renderTargetContext))
-{
-    fSize.set(width, height);
-
+SkGpuDevice::SkGpuDevice(GrContext* context,
+                         std::unique_ptr<GrRenderTargetContext> renderTargetContext,
+                         unsigned flags)
+        : INHERITED(make_info(renderTargetContext.get(), SkToBool(flags & kIsOpaque_Flag)),
+                    renderTargetContext->surfaceProps())
+        , fContext(SkRef(context))
+        , fRenderTargetContext(std::move(renderTargetContext)) {
     if (flags & kNeedClear_Flag) {
         this->clearAll();
     }
 }
 
-sk_sp<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
-                                                               GrContext* context,
-                                                               SkBudgeted budgeted,
-                                                               const SkImageInfo& origInfo,
-                                                               int sampleCount,
-                                                               GrSurfaceOrigin origin,
-                                                               const SkSurfaceProps* surfaceProps,
-                                                               GrMipMapped mipMapped) {
-    if (kUnknown_SkColorType == origInfo.colorType() ||
-        origInfo.width() < 0 || origInfo.height() < 0) {
-        return nullptr;
-    }
-
+std::unique_ptr<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
+        GrContext* context,
+        SkBudgeted budgeted,
+        const SkImageInfo& origInfo,
+        int sampleCount,
+        GrSurfaceOrigin origin,
+        const SkSurfaceProps* surfaceProps,
+        GrMipMapped mipMapped) {
     if (!context) {
         return nullptr;
     }
@@ -224,7 +213,7 @@
                                 GrRenderTargetContext::CanClearFullscreen::kYes);
 }
 
-void SkGpuDevice::replaceRenderTargetContext(sk_sp<GrRenderTargetContext> rtc,
+void SkGpuDevice::replaceRenderTargetContext(std::unique_ptr<GrRenderTargetContext> rtc,
                                              bool shouldRetainContent) {
     SkASSERT(rtc->width() == this->width());
     SkASSERT(rtc->height() == this->height());
@@ -251,14 +240,13 @@
 
     // This entry point is used by SkSurface_Gpu::onCopyOnWrite so it must create a
     // kExact-backed render target context.
-    sk_sp<GrRenderTargetContext> newRTC(MakeRenderTargetContext(
-                                                            this->context(),
-                                                            budgeted,
-                                                            this->imageInfo(),
-                                                            fRenderTargetContext->numSamples(),
-                                                            fRenderTargetContext->origin(),
-                                                            &this->surfaceProps(),
-                                                            fRenderTargetContext->mipMapped()));
+    auto newRTC = MakeRenderTargetContext(this->context(),
+                                          budgeted,
+                                          this->imageInfo(),
+                                          fRenderTargetContext->numSamples(),
+                                          fRenderTargetContext->origin(),
+                                          &this->surfaceProps(),
+                                          fRenderTargetContext->mipMapped());
     if (!newRTC) {
         return;
     }
@@ -1661,7 +1649,7 @@
         colorType = GrColorType::kRGBA_8888;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(fContext->priv().makeDeferredRenderTargetContext(
+    auto rtc = fContext->priv().makeDeferredRenderTargetContext(
             fit,
             cinfo.fInfo.width(),
             cinfo.fInfo.height(),
@@ -1673,7 +1661,7 @@
             &props,
             SkBudgeted::kYes,
             fRenderTargetContext->asSurfaceProxy()->isProtected() ? GrProtected::kYes
-                                                                  : GrProtected::kNo));
+                                                                  : GrProtected::kNo);
     if (!rtc) {
         return nullptr;
     }
@@ -1681,8 +1669,7 @@
     // Skia's convention is to only clear a device if it is non-opaque.
     InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_InitContents;
 
-    return SkGpuDevice::Make(fContext.get(), std::move(rtc),
-                             cinfo.fInfo.width(), cinfo.fInfo.height(), init).release();
+    return SkGpuDevice::Make(fContext.get(), std::move(rtc), init).release();
 }
 
 sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 6421702..9d0e058 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -42,8 +42,8 @@
      * Creates an SkGpuDevice from a GrRenderTargetContext whose backing width/height is
      * different than its actual width/height (e.g., approx-match scratch texture).
      */
-    static sk_sp<SkGpuDevice> Make(GrContext*, sk_sp<GrRenderTargetContext> renderTargetContext,
-                                   int width, int height, InitContents);
+    static sk_sp<SkGpuDevice> Make(
+            GrContext*, std::unique_ptr<GrRenderTargetContext>, InitContents);
 
     /**
      * New device that will create an offscreen renderTarget based on the ImageInfo and
@@ -65,7 +65,8 @@
     void clearAll();
 
     void replaceRenderTargetContext(bool shouldRetainContent);
-    void replaceRenderTargetContext(sk_sp<GrRenderTargetContext>, bool shouldRetainContent);
+    void replaceRenderTargetContext(std::unique_ptr<GrRenderTargetContext>,
+                                    bool shouldRetainContent);
 
     GrRenderTargetContext* accessRenderTargetContext() override;
 
@@ -132,10 +133,8 @@
 
 private:
     // We want these unreffed in RenderTargetContext, GrContext order.
-    sk_sp<GrContext>             fContext;
-    sk_sp<GrRenderTargetContext> fRenderTargetContext;
-
-    SkISize                      fSize;
+    sk_sp<GrContext> fContext;
+    std::unique_ptr<GrRenderTargetContext> fRenderTargetContext;
 
     enum Flags {
         kNeedClear_Flag = 1 << 0,  //!< Surface requires an initial clear
@@ -145,7 +144,7 @@
     static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init,
                                           unsigned* flags);
 
-    SkGpuDevice(GrContext*, sk_sp<GrRenderTargetContext>, int width, int height, unsigned flags);
+    SkGpuDevice(GrContext*, std::unique_ptr<GrRenderTargetContext>, unsigned flags);
 
     SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
 
@@ -233,13 +232,13 @@
                            const SkVertices::Bone bones[], int boneCount, SkBlendMode,
                            const uint16_t indices[], int indexCount, const SkPaint&);
 
-    static sk_sp<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
-                                                                SkBudgeted,
-                                                                const SkImageInfo&,
-                                                                int sampleCount,
-                                                                GrSurfaceOrigin,
-                                                                const SkSurfaceProps*,
-                                                                GrMipMapped);
+    static std::unique_ptr<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
+                                                                          SkBudgeted,
+                                                                          const SkImageInfo&,
+                                                                          int sampleCount,
+                                                                          GrSurfaceOrigin,
+                                                                          const SkSurfaceProps*,
+                                                                          GrMipMapped);
 
     friend class GrAtlasTextContext;
     friend class SkSurface_Gpu;      // for access to surfaceProps
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index ba3033d..a454899 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -216,7 +216,7 @@
     return fCachedAtlas;
 }
 
-sk_sp<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
+std::unique_ptr<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
         GrOnFlushResourceProvider* onFlushRP, sk_sp<GrTexture> backingTexture) {
     SkASSERT(!fTextureProxy->isInstantiated());  // This method should only be called once.
     // Caller should have cropped any paths to the destination render target instead of asking for
@@ -241,8 +241,7 @@
     }
     auto colorType = (CoverageType::kFP16_CoverageCount == fCoverageType)
             ? GrColorType::kAlpha_F16 : GrColorType::kAlpha_8;
-    sk_sp<GrRenderTargetContext> rtc =
-            onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr);
+    auto rtc = onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr);
     if (!rtc) {
         SkDebugf("WARNING: failed to allocate a %ix%i atlas. Some paths will not be drawn.\n",
                  fWidth, fHeight);
diff --git a/src/gpu/ccpr/GrCCAtlas.h b/src/gpu/ccpr/GrCCAtlas.h
index 724a017..283338c 100644
--- a/src/gpu/ccpr/GrCCAtlas.h
+++ b/src/gpu/ccpr/GrCCAtlas.h
@@ -100,8 +100,8 @@
     // 'backingTexture', if provided, is a renderable texture with which to instantiate our proxy.
     // If null then we will create a texture using the resource provider. The purpose of this param
     // is to provide a guaranteed way to recycle a stashed atlas texture from a previous flush.
-    sk_sp<GrRenderTargetContext> makeRenderTargetContext(GrOnFlushResourceProvider*,
-                                                         sk_sp<GrTexture> backingTexture = nullptr);
+    std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(
+            GrOnFlushResourceProvider*, sk_sp<GrTexture> backingTexture = nullptr);
 
 private:
     class Node;
diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp
index 1997f83..223d9ad 100644
--- a/src/gpu/ccpr/GrCCPerFlushResources.cpp
+++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp
@@ -500,7 +500,7 @@
 }
 
 bool GrCCPerFlushResources::finalize(GrOnFlushResourceProvider* onFlushRP,
-                                     SkTArray<sk_sp<GrRenderTargetContext>>* out) {
+                                     SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) {
     SkASSERT(this->isMapped());
     SkASSERT(fNextPathInstanceIdx == fEndPathInstance);
     SkASSERT(fNextCopyInstanceIdx == fEndCopyInstance);
@@ -541,7 +541,7 @@
         int endCopyRange = atlas->getFillBatchID();
         SkASSERT(endCopyRange > copyRangeIdx);
 
-        sk_sp<GrRenderTargetContext> rtc = atlas->makeRenderTargetContext(onFlushRP);
+        auto rtc = atlas->makeRenderTargetContext(onFlushRP);
         for (; copyRangeIdx < endCopyRange; ++copyRangeIdx) {
             const CopyPathRange& copyRange = fCopyPathRanges[copyRangeIdx];
             int endCopyInstance = baseCopyInstance + copyRange.fCount;
diff --git a/src/gpu/ccpr/GrCCPerFlushResources.h b/src/gpu/ccpr/GrCCPerFlushResources.h
index 9187cf5..59122fe 100644
--- a/src/gpu/ccpr/GrCCPerFlushResources.h
+++ b/src/gpu/ccpr/GrCCPerFlushResources.h
@@ -107,7 +107,8 @@
     }
 
     // Finishes off the GPU buffers and renders the atlas(es).
-    bool finalize(GrOnFlushResourceProvider*, SkTArray<sk_sp<GrRenderTargetContext>>* out);
+    bool finalize(GrOnFlushResourceProvider*,
+                  SkTArray<std::unique_ptr<GrRenderTargetContext>>* out);
 
     // Accessors used by draw calls, once the resources have been finalized.
     const GrCCFiller& filler() const { SkASSERT(!this->isMapped()); return fFiller; }
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index a057f88..a9e080b 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -226,9 +226,11 @@
     return skstd::make_unique<GrCCClipProcessor>(&clipPath, isCoverageCount, mustCheckBounds);
 }
 
-void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
-                                              const uint32_t* opListIDs, int numOpListIDs,
-                                              SkTArray<sk_sp<GrRenderTargetContext>>* out) {
+void GrCoverageCountingPathRenderer::preFlush(
+        GrOnFlushResourceProvider* onFlushRP,
+        const uint32_t* opListIDs,
+        int numOpListIDs,
+        SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) {
     using DoCopiesToA8Coverage = GrCCDrawPathsOp::DoCopiesToA8Coverage;
     SkASSERT(!fFlushing);
     SkASSERT(fFlushingPaths.empty());
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index 9ebd991..0450918 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -66,7 +66,7 @@
 
     // GrOnFlushCallbackObject overrides.
     void preFlush(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs,
-                  SkTArray<sk_sp<GrRenderTargetContext>>* out) override;
+                  SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) override;
     void postFlush(GrDeferredUploadToken, const uint32_t* opListIDs, int numOpListIDs) override;
 
     void purgeCacheEntriesOlderThan(GrProxyProvider*, const GrStdSteadyClock::time_point&);
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index ba58cc2..890d188 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -40,14 +40,14 @@
         const SkImageInfo ii = SkImageInfo::Make(kSize, kSize,
                                                  kRGBA_8888_SkColorType, kPremul_SkAlphaType);
 
-        sk_sp<GrRenderTargetContext> readRTC(
+        auto readRTC =
                 context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
                                                                 kSize, kSize,
-                                                                kColorType, nullptr));
-        sk_sp<GrRenderTargetContext> tempRTC(
+                                                                kColorType, nullptr);
+        auto tempRTC =
                 context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
                                                                 kSize, kSize,
-                                                                kColorType, nullptr));
+                                                                kColorType, nullptr);
         if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
             return false;
         }
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index cf23511..6a39777 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -54,10 +54,10 @@
                 key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
         if (!mask) {
             // TODO: this could be approx but the texture coords will need to be updated
-            sk_sp<GrRenderTargetContext> rtc(
+            auto rtc =
                     context->priv().makeDeferredRenderTargetContextWithFallback(
                                                 SkBackingFit::kExact, size.fWidth,
-                                                size.fHeight, GrColorType::kAlpha_8, nullptr));
+                                                size.fHeight, GrColorType::kAlpha_8, nullptr);
             if (!rtc) {
                 return nullptr;
             }
@@ -73,7 +73,7 @@
             if (!srcProxy) {
                 return nullptr;
             }
-            sk_sp<GrRenderTargetContext> rtc2(
+            auto rtc2 =
                       SkGpuBlurUtils::GaussianBlur(context,
                                                    std::move(srcProxy),
                                                    SkIPoint::Make(0, 0),
@@ -84,7 +84,7 @@
                                                    xformedSigma,
                                                    GrTextureDomain::kIgnore_Mode,
                                                    kPremul_SkAlphaType,
-                                                   SkBackingFit::kExact));
+                                                   SkBackingFit::kExact);
             if (!rtc2) {
                 return nullptr;
             }
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index ee45889..95df89e 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -48,10 +48,10 @@
         const SkImageInfo ii =
                 SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
 
-        sk_sp<GrRenderTargetContext> readRTC(context->priv().makeDeferredRenderTargetContext(
-                SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
-        sk_sp<GrRenderTargetContext> tempRTC(context->priv().makeDeferredRenderTargetContext(
-                SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
+        auto readRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize,
+                                                                       kSize, kColorType, nullptr);
+        auto tempRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize,
+                                                                       kSize, kColorType, nullptr);
         if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
             return false;
         }
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h
index ffec0a3..aaff4d3 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.h
@@ -55,10 +55,9 @@
                 key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
         if (!mask) {
             // TODO: this could be approx but the texture coords will need to be updated
-            sk_sp<GrRenderTargetContext> rtc(
-                    context->priv().makeDeferredRenderTargetContextWithFallback(
-                            SkBackingFit::kExact, size.fWidth, size.fHeight, GrColorType::kAlpha_8,
-                            nullptr));
+            auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(
+                    SkBackingFit::kExact, size.fWidth, size.fHeight, GrColorType::kAlpha_8,
+                    nullptr);
             if (!rtc) {
                 return nullptr;
             }
@@ -74,18 +73,17 @@
             if (!srcProxy) {
                 return nullptr;
             }
-            sk_sp<GrRenderTargetContext> rtc2(
-                    SkGpuBlurUtils::GaussianBlur(context,
-                                                 std::move(srcProxy),
-                                                 SkIPoint::Make(0, 0),
-                                                 nullptr,
-                                                 SkIRect::MakeWH(size.fWidth, size.fHeight),
-                                                 SkIRect::EmptyIRect(),
-                                                 xformedSigma,
-                                                 xformedSigma,
-                                                 GrTextureDomain::kIgnore_Mode,
-                                                 kPremul_SkAlphaType,
-                                                 SkBackingFit::kExact));
+            auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
+                                                     std::move(srcProxy),
+                                                     SkIPoint::Make(0, 0),
+                                                     nullptr,
+                                                     SkIRect::MakeWH(size.fWidth, size.fHeight),
+                                                     SkIRect::EmptyIRect(),
+                                                     xformedSigma,
+                                                     xformedSigma,
+                                                     GrTextureDomain::kIgnore_Mode,
+                                                     kPremul_SkAlphaType,
+                                                     SkBackingFit::kExact);
             if (!rtc2) {
                 return nullptr;
             }
diff --git a/src/gpu/ops/GrSmallPathRenderer.h b/src/gpu/ops/GrSmallPathRenderer.h
index 01e660b..d7aa781 100644
--- a/src/gpu/ops/GrSmallPathRenderer.h
+++ b/src/gpu/ops/GrSmallPathRenderer.h
@@ -34,7 +34,7 @@
     // default retainOnFreeGpuResources implementation).
 
     void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
-                  SkTArray<sk_sp<GrRenderTargetContext>>*) override {
+                  SkTArray<std::unique_ptr<GrRenderTargetContext>>*) override {
         if (fAtlas) {
             fAtlas->instantiate(onFlushResourceProvider);
         }
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index 6ae06a4..bf57ca5 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -95,8 +95,8 @@
         return false;
     }
 
-    sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
-            sk_ref_sp(sProxy), colorType, kUnknown_SkAlphaType));
+    auto sContext = context->priv().makeWrappedSurfaceContext(sk_ref_sp(sProxy), colorType,
+                                                              kUnknown_SkAlphaType);
     if (!sContext || !sContext->asTextureProxy()) {
         return false;
     }
diff --git a/src/gpu/text/GrAtlasManager.h b/src/gpu/text/GrAtlasManager.h
index 1a2871e..026806b 100644
--- a/src/gpu/text/GrAtlasManager.h
+++ b/src/gpu/text/GrAtlasManager.h
@@ -89,7 +89,7 @@
     // GrOnFlushCallbackObject overrides
 
     void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
-                  SkTArray<sk_sp<GrRenderTargetContext>>*) override {
+                  SkTArray<std::unique_ptr<GrRenderTargetContext>>*) override {
         for (int i = 0; i < kMaskFormatCount; ++i) {
             if (fAtlases[i]) {
                 fAtlases[i]->instantiate(onFlushResourceProvider);
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 95d8893..6b55aa7 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -235,8 +235,8 @@
     }
 
     // Setup dummy SkPaint / GrPaint / GrRenderTargetContext
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
-            SkBackingFit::kApprox, 1024, 1024, GrColorType::kRGBA_8888, nullptr));
+    auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1024, 1024,
+                                                               GrColorType::kRGBA_8888, nullptr);
 
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
 
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index 9ffbdd4..3a72b2a 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -30,15 +30,11 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(
-            ctx->priv().makeVulkanSecondaryCBRenderTargetContext(imageInfo, vkInfo, props));
+    auto rtc = ctx->priv().makeVulkanSecondaryCBRenderTargetContext(imageInfo, vkInfo, props);
     SkASSERT(rtc->asSurfaceProxy()->isInstantiated());
 
-    int width = rtc->width();
-    int height = rtc->height();
-
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(ctx, std::move(rtc), width, height,
-                                                SkGpuDevice::kUninit_InitContents));
+    sk_sp<SkGpuDevice> device(
+            SkGpuDevice::Make(ctx, std::move(rtc), SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
     }
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 4772128..e299f0e 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -86,10 +86,9 @@
 
     sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(context);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContextWithFallback(
-                    SkBackingFit::kExact, this->width(), this->height(),
-                    SkColorTypeToGrColorType(targetCT), nullptr));
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kExact, this->width(), this->height(), SkColorTypeToGrColorType(targetCT),
+            nullptr);
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -245,9 +244,9 @@
     const int height = imageSize.height();
 
     // Needs to create a render target in order to draw to it for the yuv->rgb conversion.
-    sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
+    auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext(
             SkBackingFit::kExact, width, height, GrColorType::kRGBA_8888,
-            std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
+            std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin);
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -283,11 +282,9 @@
 
     // Needs to create a render target with external texture
     // in order to draw to it for the yuv->rgb conversion.
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            ctx->priv().makeBackendTextureRenderTargetContext(backendTexture, imageOrigin, 1,
-                                                              grColorType,
-                                                              std::move(imageColorSpace), nullptr,
-                                                              textureReleaseProc, releaseContext));
+    auto renderTargetContext = ctx->priv().makeBackendTextureRenderTargetContext(
+            backendTexture, imageOrigin, 1, grColorType, std::move(imageColorSpace), nullptr,
+            textureReleaseProc, releaseContext);
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -601,7 +598,7 @@
         return nullptr;
     }
 
-    sk_sp<GrTextureContext> texContext =
+    auto texContext =
             drawingManager->makeTextureContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
                                                pixmap.alphaType(), cs);
     if (!texContext) {
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 0d2fb5e..a47d3d2 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -92,11 +92,8 @@
                                                                 this->colorType(),
                                                                 texProxy->backendFormat());
 
-    sk_sp<GrSurfaceContext> sContext =
-            direct->priv().makeWrappedSurfaceContext(std::move(texProxy),
-                                                     grColorType,
-                                                     this->alphaType(),
-                                                     this->refColorSpace());
+    auto sContext = direct->priv().makeWrappedSurfaceContext(
+            std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
     if (!sContext) {
         return false;
     }
@@ -150,7 +147,7 @@
                                                                 this->colorType(),
                                                                 texProxy->backendFormat());
 
-    sk_sp<GrSurfaceContext> sContext = direct->priv().makeWrappedSurfaceContext(
+    auto sContext = direct->priv().makeWrappedSurfaceContext(
             std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
     if (!sContext) {
         return false;
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index fe4819f..978060f 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -141,10 +141,9 @@
     }
 
     // Needs to create a render target in order to draw to it for the yuv->rgb conversion.
-    sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->priv().makeDeferredRenderTargetContext(
-                    SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
-                    this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin));
+    auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
+            SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
+            this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin);
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 6b2e3d2..3136051 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -364,25 +364,23 @@
 
     GrColorType grColorType = SkColorTypeToGrColorType(c.colorType());
 
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
-            SkBackingFit::kExact,
-            c.width(),
-            c.height(),
-            grColorType,
-            c.refColorSpace(),
-            c.sampleCount(),
-            GrMipMapped(c.isMipMapped()),
-            c.origin(),
-            &c.surfaceProps(),
-            budgeted,
-            c.isProtected()));
+    auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+                                                               c.width(),
+                                                               c.height(),
+                                                               grColorType,
+                                                               c.refColorSpace(),
+                                                               c.sampleCount(),
+                                                               GrMipMapped(c.isMipMapped()),
+                                                               c.origin(),
+                                                               &c.surfaceProps(),
+                                                               budgeted,
+                                                               c.isProtected());
     if (!rtc) {
         return nullptr;
     }
 
     // CONTEXT TODO: remove this use of 'backdoor' to create an SkGpuDevice
     sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context->priv().backdoor(), std::move(rtc),
-                                                c.width(), c.height(),
                                                 SkGpuDevice::kClear_InitContents));
     if (!device) {
         return nullptr;
@@ -458,16 +456,14 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
-                backendTexture, c.origin(), c.sampleCount(), grCT,
-                c.refColorSpace(), &c.surfaceProps(), textureReleaseProc, releaseContext));
+    auto rtc = context->priv().makeBackendTextureRenderTargetContext(
+            backendTexture, c.origin(), c.sampleCount(), grCT, c.refColorSpace(), &c.surfaceProps(),
+            textureReleaseProc, releaseContext);
     if (!rtc) {
         return nullptr;
     }
 
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc),
-                                                backendTexture.width(), backendTexture.height(),
-                                                SkGpuDevice::kUninit_InitContents));
+    auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
     if (!device) {
         return nullptr;
     }
@@ -505,16 +501,13 @@
     return sk_make_sp<SkSurface_Gpu>(std::move(device));
 }
 
-sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context,
-                                                        sk_sp<GrRenderTargetContext> rtc) {
+sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(
+        GrContext* context, std::unique_ptr<GrRenderTargetContext> rtc) {
     if (!context) {
         return nullptr;
     }
 
-    int w = rtc->width();
-    int h = rtc->height();
-    sk_sp<SkGpuDevice> device(
-            SkGpuDevice::Make(context, std::move(rtc), w, h, SkGpuDevice::kUninit_InitContents));
+    auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
     if (!device) {
         return nullptr;
     }
@@ -544,15 +537,14 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
-            tex, origin, sampleCnt, grColorType, std::move(colorSpace), props,
-            textureReleaseProc, releaseContext));
+    auto rtc = context->priv().makeBackendTextureRenderTargetContext(
+            tex, origin, sampleCnt, grColorType, std::move(colorSpace), props, textureReleaseProc,
+            releaseContext);
     if (!rtc) {
         return nullptr;
     }
 
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(),
-                                                SkGpuDevice::kUninit_InitContents));
+    auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
     if (!device) {
         return nullptr;
     }
@@ -598,7 +590,7 @@
                                   sampleCnt, grColorType, true)) {
         return false;
     }
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
+    auto rtc = context->priv().makeBackendTextureRenderTargetContext(
             backendTexture,
             origin,
             sampleCnt,
@@ -606,7 +598,7 @@
             std::move(colorSpace),
             &this->props(),
             releaseProc,
-            releaseContext));
+            releaseContext);
     if (!rtc) {
         return false;
     }
@@ -652,14 +644,13 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendRenderTargetRenderTargetContext(
-            rt, origin, grColorType, std::move(colorSpace), props, relProc, releaseContext));
+    auto rtc = context->priv().makeBackendRenderTargetRenderTargetContext(
+            rt, origin, grColorType, std::move(colorSpace), props, relProc, releaseContext);
     if (!rtc) {
         return nullptr;
     }
 
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), rt.width(), rt.height(),
-                                                SkGpuDevice::kUninit_InitContents));
+    auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
     if (!device) {
         return nullptr;
     }
@@ -688,20 +679,13 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(
-            context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
-                    tex,
-                    origin,
-                    sampleCnt,
-                    grColorType,
-                    std::move(colorSpace),
-                    props));
+    auto rtc = context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
+            tex, origin, sampleCnt, grColorType, std::move(colorSpace), props);
     if (!rtc) {
         return nullptr;
     }
 
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(),
-                                                SkGpuDevice::kUninit_InitContents));
+    auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
     if (!device) {
         return nullptr;
     }
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index 9ac45d5..fd3fb6d 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -22,7 +22,8 @@
     ~SkSurface_Gpu() override;
 
     // This is an internal-only factory
-    static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
+    static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*,
+                                                    std::unique_ptr<GrRenderTargetContext>);
 
     GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
     GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;