Revert "Add GrRenderTargetContext instantiate & asTextureProxy"

This reverts commit 9113edfff89e657dabc0ba095c54f7720550196c.

Reason for revert: Looks to be causing EXCEPTION_ACCESS_VIOLATION:

https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win-MSVC-NUC-GPU-IntelIris6100-x86_64-Debug/builds/121/steps/test_skia%20on%20Windows/logs/stdio
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win-MSVC-GCE-CPU-AVX2-x86-Debug/builds/2384/steps/test_skia%20on%20Windows-2008ServerR2-SP1/logs/stdio
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win-MSVC-ShuttleC-GPU-iHD530-x86_64-Debug/builds/785/steps/test_skia%20on%20Windows/logs/stdio

Original change's description:
> Add GrRenderTargetContext instantiate & asTextureProxy
> 
> This CL also centralizes the instantiation code in GrSurfaceProxy and adds a test.
> 
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4494
> 
> Change-Id: I0081d9a216dc0af293179f23bcb88acf6a822324
> Reviewed-on: https://skia-review.googlesource.com/4494
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> 

TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I225ce7867ebd445067e5ea55ebbfd587f7fe782a
Reviewed-on: https://skia-review.googlesource.com/4528
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 20ac412..ad8adb0 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -117,14 +117,6 @@
     SkSafeUnref(fOpList);
 }
 
-GrRenderTarget* GrRenderTargetContext::instantiate() {
-    return fRenderTargetProxy->instantiate(fContext->textureProvider());
-}
-
-GrTextureProxy* GrRenderTargetContext::asDeferredTexture() {
-    return fRenderTargetProxy->asTextureProxy();
-}
-
 GrRenderTargetOpList* GrRenderTargetContext::getOpList() {
     ASSERT_SINGLE_OWNER
     SkDEBUGCODE(this->validate();)
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index fcc5275..f428a0f 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -37,17 +37,33 @@
 }
 
 GrRenderTarget* GrRenderTargetProxy::instantiate(GrTextureProvider* texProvider) {
-    SkASSERT(fDesc.fFlags & GrSurfaceFlags::kRenderTarget_GrSurfaceFlag);
+    if (fTarget) {
+        return fTarget->asRenderTarget();
+    }
 
-    GrSurface* surf = INHERITED::instantiate(texProvider);
-    if (!surf || !surf->asRenderTarget()) {
+    // TODO: it would be nice to not have to copy the desc here
+    GrSurfaceDesc desc = fDesc;
+    desc.fFlags |= GrSurfaceFlags::kRenderTarget_GrSurfaceFlag;
+
+    if (SkBackingFit::kApprox == fFit) {
+        fTarget = texProvider->createApproxTexture(desc);
+    } else {
+        fTarget = texProvider->createTexture(desc, fBudgeted);
+    }
+    if (!fTarget) {
         return nullptr;
     }
 
-    // Check that our a priori computation matched the ultimate reality
-    SkASSERT(fFlags == surf->asRenderTarget()->renderTargetPriv().flags());
+#ifdef SK_DEBUG
+    if (kInvalidGpuMemorySize != this->getRawGpuMemorySize_debugOnly()) {
+        SkASSERT(fTarget->gpuMemorySize() <= this->getRawGpuMemorySize_debugOnly());    
+    }
+#endif
 
-    return surf->asRenderTarget();
+    // Check that our a priori computation matched the ultimate reality
+    SkASSERT(fFlags == fTarget->asRenderTarget()->renderTargetPriv().flags());
+
+    return fTarget->asRenderTarget();
 }
 
 
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index b6d0e11..c5afd0f 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -9,7 +9,6 @@
 
 #include "GrGpuResourcePriv.h"
 #include "GrOpList.h"
-#include "GrTextureProvider.h"
 
 GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit)
     : INHERITED(std::move(surface))
@@ -28,29 +27,6 @@
     SkSafeUnref(fLastOpList);
 }
 
-GrSurface* GrSurfaceProxy::instantiate(GrTextureProvider* texProvider) {
-    if (fTarget) {
-        return fTarget;
-    }
-
-    if (SkBackingFit::kApprox == fFit) {
-        fTarget = texProvider->createApproxTexture(fDesc);
-    } else {
-        fTarget = texProvider->createTexture(fDesc, fBudgeted);
-    }
-    if (!fTarget) {
-        return nullptr;
-    }
-
-#ifdef SK_DEBUG
-    if (kInvalidGpuMemorySize != this->getRawGpuMemorySize_debugOnly()) {
-        SkASSERT(fTarget->gpuMemorySize() <= this->getRawGpuMemorySize_debugOnly());    
-    }
-#endif
-
-    return fTarget;
-}
-
 void GrSurfaceProxy::setLastOpList(GrOpList* opList) {
     if (fLastOpList) {
         // The non-MDB world never closes so we can't check this condition
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 5fe43f7..ca773b3 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -21,11 +21,22 @@
 }
 
 GrTexture* GrTextureProxy::instantiate(GrTextureProvider* texProvider) {
-    GrSurface* surf = this->INHERITED::instantiate(texProvider);
-    if (!surf) {
-        return nullptr;
+    if (fTarget) {
+        return fTarget->asTexture();
     }
 
+    if (SkBackingFit::kApprox == fFit) {
+        fTarget = texProvider->createApproxTexture(fDesc);
+    } else {
+        fTarget = texProvider->createTexture(fDesc, fBudgeted);
+    }
+
+#ifdef SK_DEBUG
+    if (kInvalidGpuMemorySize != this->getRawGpuMemorySize_debugOnly()) {
+        SkASSERT(fTarget->gpuMemorySize() <= this->getRawGpuMemorySize_debugOnly());
+    }
+#endif
+
     return fTarget->asTexture();
 }