Revert "Plumb the use of GrBackendRenderTarget throughout Skia"

This reverts commit fdd77daedbba3b7c53be74a82fb9fae891b51696.

Reason for revert: Apparently I have a few more build files to update before this can land.

Original change's description:
> Plumb the use of GrBackendRenderTarget throughout Skia
> 
> Bug: skia:
> Change-Id: Ib99a58d9552f5c7b8d77c09dcc72fa88326c26aa
> Reviewed-on: https://skia-review.googlesource.com/14148
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> 

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

Change-Id: I984e1909870182474c4c3cce257f01b6a9d8581f
Reviewed-on: https://skia-review.googlesource.com/14531
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp
index f3be850..abd198a 100644
--- a/example/SkiaSDLExample.cpp
+++ b/example/SkiaSDLExample.cpp
@@ -6,7 +6,6 @@
  *
  */
 
-#include "GrBackendSurface.h"
 #include "GrContext.h"
 #include "SDL.h"
 #include "SkCanvas.h"
@@ -193,12 +192,16 @@
 
     // Wrap the frame buffer object attached to the screen in a Skia render target so Skia can
     // render to it
-    GrGLFrameBufferInfo fbInfo;
+    GrBackendRenderTargetDesc desc;
+    desc.fWidth = dm.w;
+    desc.fHeight = dm.h;
+    desc.fConfig = kSkia8888_GrPixelConfig;
+    desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+    desc.fSampleCnt = kMsaaSampleCount;
+    desc.fStencilBits = kStencilBits;
     GrGLint buffer;
     GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
-    fbInfo.fFBOID = buffer;
-    GrBackendRenderTarget backendRT(dm.w, dm.h, kMsaaSampleCount, kStencilBits,
-                                    kSkia8888_GrPixelConfig, fbInfo);
+    desc.fRenderTargetHandle = buffer;
 
     // setup SkSurface
     // To use distance field text, use commented out SkSurfaceProps instead
@@ -206,10 +209,7 @@
     //                      SkSurfaceProps::kLegacyFontHost_InitType);
     SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
 
-    sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext,
-                                                                    backendRT,
-                                                                    kBottomLeft_GrSurfaceOrigin,
-                                                                    &props));
+    sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext, desc, &props));
 
     SkCanvas* canvas = surface->getCanvas();
 
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index d9302da..fd99a43 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -9,8 +9,9 @@
 #define GrBackendSurface_DEFINED
 
 #include "GrTypes.h"
-#include "gl/GrGLTypes.h"
-#include "vk/GrVkTypes.h"
+
+struct GrVkImageInfo;
+struct GrGLTextureInfo;
 
 class GrBackendTexture {
 public:
@@ -62,18 +63,22 @@
 
 class GrBackendRenderTarget {
 public:
+    // The passed in GrVkImageInfo must live until the GrBackendTexture is no longer used in
+    // creation of SkImages or SkSurfaces.
     GrBackendRenderTarget(int width,
                           int height,
                           int sampleCnt,
                           int stencilBits,
-                          const GrVkImageInfo& vkInfo);
+                          const GrVkImageInfo* vkInfo);
 
+    // The passed in GrGLTextureInfo must live until the GrBackendTexture is no longer used in
+    // creation of SkImages or SkSurfaces.
     GrBackendRenderTarget(int width,
                           int height,
                           int sampleCnt,
                           int stencilBits,
                           GrPixelConfig config,
-                          const GrGLFramebufferInfo& glInfo);
+                          const GrGLTextureInfo* glInfo);
 
     int width() const { return fWidth; }
     int height() const { return fHeight; }
@@ -83,12 +88,12 @@
     GrBackend backend() const {return fBackend; }
 
     // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
-    // it returns nullptr
+    // it returns nullptr.
     const GrVkImageInfo* getVkImageInfo() const;
 
-    // If the backend API is GL, this returns a pointer to the GrGLFramebufferInfo struct. Otherwise
+    // If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise
     // it returns nullptr.
-    const GrGLFramebufferInfo* getGLFramebufferInfo() const;
+    const GrGLTextureInfo* getGLTextureInfo() const;
 
 private:
     // Temporary constructor which can be used to convert from a GrBackendRenderTargetDesc.
@@ -107,8 +112,9 @@
     GrBackend fBackend;
 
     union {
-        GrVkImageInfo   fVkInfo;
-        GrGLFramebufferInfo fGLInfo;
+        const GrVkImageInfo*   fVkInfo;
+        const GrGLTextureInfo* fGLInfo;
+        GrBackendObject  fHandle;
     };
 };
 
diff --git a/include/gpu/gl/GrGLTypes.h b/include/gpu/gl/GrGLTypes.h
index 345364b..f2b339e 100644
--- a/include/gpu/gl/GrGLTypes.h
+++ b/include/gpu/gl/GrGLTypes.h
@@ -135,10 +135,4 @@
 
 GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*));
 
-struct GrGLFramebufferInfo {
-    GrGLuint fFBOID;
-};
-
-GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLFramebufferInfo*));
-
 #endif
diff --git a/include/gpu/vk/GrVkDefines.h b/include/gpu/vk/GrVkDefines.h
index 7defed2..7b9ee8d 100644
--- a/include/gpu/vk/GrVkDefines.h
+++ b/include/gpu/vk/GrVkDefines.h
@@ -9,8 +9,6 @@
 #ifndef GrVkDefines_DEFINED
 #define GrVkDefines_DEFINED
 
-#ifdef SK_VULKAN
-
 #if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_WIN32)
 #   if !defined(VK_USE_PLATFORM_WIN32_KHR)
 #      define VK_USE_PLATFORM_WIN32_KHR
@@ -31,6 +29,8 @@
 #   endif
 #endif
 
+#if defined(Bool) || defined(Status) || defined(True) || defined(False)
+#   pragma error "Macros unexpectedly defined."
 #endif
 
 #include <vulkan/vulkan.h>
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 6a1448e..97b3b6e 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -70,14 +70,14 @@
                                              int height,
                                              int sampleCnt,
                                              int stencilBits,
-                                             const GrVkImageInfo& vkInfo)
+                                             const GrVkImageInfo* vkInfo)
         : fWidth(width)
         , fHeight(height)
         , fSampleCnt(sampleCnt)
         , fStencilBits(stencilBits)
         , fConfig(
 #ifdef SK_VULKAN
-                  GrVkFormatToPixelConfig(vkInfo.fFormat)
+                  GrVkFormatToPixelConfig(vkInfo->fFormat)
 #else
                   kUnknown_GrPixelConfig
 #endif
@@ -90,7 +90,7 @@
                                              int sampleCnt,
                                              int stencilBits,
                                              GrPixelConfig config,
-                                             const GrGLFramebufferInfo& glInfo)
+                                             const GrGLTextureInfo* glInfo)
         : fWidth(width)
         , fHeight(height)
         , fSampleCnt(sampleCnt)
@@ -105,33 +105,26 @@
         , fHeight(desc.fHeight)
         , fSampleCnt(desc.fSampleCnt)
         , fStencilBits(desc.fStencilBits)
-        , fConfig(desc.fConfig)
-        , fBackend(backend) {
-    if (kOpenGL_GrBackend == backend) {
-        fGLInfo = *reinterpret_cast<const GrGLFramebufferInfo*>(desc.fRenderTargetHandle);
-    } else {
-        SkASSERT(kVulkan_GrBackend == backend);
+        , fConfig(kVulkan_GrBackend == backend
 #ifdef SK_VULKAN
-        const GrVkImageInfo* vkInfo =
-                reinterpret_cast<const GrVkImageInfo*>(desc.fRenderTargetHandle);
-        fConfig = GrVkFormatToPixelConfig(vkInfo->fFormat);
-        fVkInfo = *vkInfo;
+                  ? GrVkFormatToPixelConfig(((GrVkImageInfo*)desc.fRenderTargetHandle)->fFormat)
 #else
-        fConfig = kUnknown_GrPixelConfig;
+                  ? kUnknown_GrPixelConfig
 #endif
-    }
-}
+                  : desc.fConfig)
+        , fBackend(backend)
+        , fHandle(desc.fRenderTargetHandle) {}
 
 const GrVkImageInfo* GrBackendRenderTarget::getVkImageInfo() const {
     if (kVulkan_GrBackend == fBackend) {
-        return &fVkInfo;
+        return fVkInfo;
     }
     return nullptr;
 }
 
-const GrGLFramebufferInfo* GrBackendRenderTarget::getGLFramebufferInfo() const {
+const GrGLTextureInfo* GrBackendRenderTarget::getGLTextureInfo() const {
     if (kOpenGL_GrBackend == fBackend) {
-        return &fGLInfo;
+        return fGLInfo;
     }
     return nullptr;
 }
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index aa245b5..a2f2272 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -702,14 +702,12 @@
 }
 
 sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
-                                                const GrBackendRenderTarget& backendRT,
-                                                GrSurfaceOrigin origin,
+                                                const GrBackendRenderTargetDesc& desc,
                                                 sk_sp<SkColorSpace> colorSpace,
                                                 const SkSurfaceProps* surfaceProps) {
     ASSERT_SINGLE_OWNER_PRIV
 
-    sk_sp<GrRenderTarget> rt(fContext->resourceProvider()->wrapBackendRenderTarget(backendRT,
-                                                                                   origin));
+    sk_sp<GrRenderTarget> rt(fContext->resourceProvider()->wrapBackendRenderTarget(desc));
     if (!rt) {
         return nullptr;
     }
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 08b26e5..c85ac2c 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -11,7 +11,6 @@
 #include "GrContext.h"
 #include "GrSurfaceContext.h"
 
-class GrBackendRenderTarget;
 class GrSemaphore;
 class GrSurfaceProxy;
 class GrPreFlushCallbackObject;
@@ -53,8 +52,7 @@
                                                          const SkSurfaceProps* = nullptr);
 
     sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
-                                                              const GrBackendRenderTarget&,
-                                                              GrSurfaceOrigin origin,
+                                                              const GrBackendRenderTargetDesc& desc,
                                                               sk_sp<SkColorSpace> colorSpace,
                                                               const SkSurfaceProps* = nullptr);
 
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 5ce8274..4bf0c87 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -223,13 +223,12 @@
     return tex;
 }
 
-sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
-                                                     GrSurfaceOrigin origin) {
-    if (!this->caps()->isConfigRenderable(backendRT.config(), backendRT.sampleCnt() > 0)) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
+    if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
         return nullptr;
     }
     this->handleDirtyContext();
-    return this->onWrapBackendRenderTarget(backendRT, origin);
+    return this->onWrapBackendRenderTarget(desc);
 }
 
 sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 000b324..523add5 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -20,7 +20,6 @@
 #include "SkTArray.h"
 #include <map>
 
-class GrBackendRenderTarget;
 class GrBuffer;
 class GrContext;
 struct GrContextOptions;
@@ -136,7 +135,7 @@
     /**
      * Implements GrResourceProvider::wrapBackendRenderTarget
      */
-    sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrSurfaceOrigin);
+    sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc&);
 
     /**
      * Implements GrResourceProvider::wrapBackendTextureAsRenderTarget
@@ -557,8 +556,7 @@
                                                   GrBackendTextureFlags,
                                                   int sampleCnt,
                                                   GrWrapOwnership) = 0;
-    virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
-                                                            GrSurfaceOrigin) = 0;
+    virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) = 0;
     virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
                                                                      GrSurfaceOrigin,
                                                                      int sampleCnt)=0;
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index d7b9087..a250f68 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -254,10 +254,10 @@
 }
 
 sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget(
-        const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin)
+        const GrBackendRenderTargetDesc& desc)
 {
     ASSERT_SINGLE_OWNER
-    return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(backendRT, origin);
+    return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc);
 }
 
 void GrResourceProvider::assignUniqueKeyToResource(const GrUniqueKey& key,
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index e22a0d8..c3d96ff8 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -12,7 +12,6 @@
 #include "GrGpu.h"
 #include "GrPathRange.h"
 
-class GrBackendRenderTarget;
 class GrPath;
 class GrRenderTarget;
 class GrSingleOwner;
@@ -101,7 +100,7 @@
      *
      * @return GrRenderTarget object or NULL on failure.
      */
-    sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrSurfaceOrigin);
+    sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
 
     static const int kMinScratchTextureSize;
 
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 646524a..da3ec49 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -504,6 +504,17 @@
     }
 }
 
+static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) {
+    // By default, GrRenderTargets are GL's normal orientation so that they
+    // can be drawn to by the outside world without the client having
+    // to render upside down.
+    if (kDefault_GrSurfaceOrigin == origin) {
+        return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
+    } else {
+        return origin;
+    }
+}
+
 sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
                                                GrSurfaceOrigin origin,
                                                GrBackendTextureFlags flags,
@@ -580,30 +591,23 @@
     }
 }
 
-sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
-                                                         GrSurfaceOrigin origin) {
-    const GrGLFramebufferInfo* info = backendRT.getGLFramebufferInfo();
-    if (!info) {
-        return nullptr;
-    }
-
+sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){
     GrGLRenderTarget::IDDesc idDesc;
-    idDesc.fRTFBOID = info->fFBOID;
+    idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
     idDesc.fMSColorRenderbufferID = 0;
     idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
     idDesc.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
     idDesc.fIsMixedSampled = false;
 
     GrSurfaceDesc desc;
-    desc.fConfig = backendRT.config();
+    desc.fConfig = wrapDesc.fConfig;
     desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag;
-    desc.fWidth = backendRT.width();
-    desc.fHeight = backendRT.height();
-    desc.fSampleCnt = SkTMin(backendRT.sampleCnt(), this->caps()->maxSampleCount());
-    SkASSERT(kDefault_GrSurfaceOrigin != origin);
-    desc.fOrigin = origin;
+    desc.fWidth = wrapDesc.fWidth;
+    desc.fHeight = wrapDesc.fHeight;
+    desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount());
+    desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
 
-    return GrGLRenderTarget::MakeWrapped(this, desc, idDesc, backendRT.stencilBits());
+    return GrGLRenderTarget::MakeWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
 }
 
 sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index f74673f..f7e75cc 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -176,8 +176,7 @@
                                           GrBackendTextureFlags,
                                           int sampleCnt,
                                           GrWrapOwnership) override;
-    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
-                                                    GrSurfaceOrigin origin) override;
+    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override;
     sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
                                                              GrSurfaceOrigin,
                                                              int sampleCnt) override;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 1eec506..be5b0c7 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -815,36 +815,32 @@
     return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership, info);
 }
 
-sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
-                                                         GrSurfaceOrigin origin){
+sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){
     // Currently the Vulkan backend does not support wrapping of msaa render targets directly. In
     // general this is not an issue since swapchain images in vulkan are never multisampled. Thus if
     // you want a multisampled RT it is best to wrap the swapchain images and then let Skia handle
     // creating and owning the MSAA images.
-    if (backendRT.sampleCnt()) {
+    if (wrapDesc.fSampleCnt) {
         return nullptr;
     }
 
-    const GrVkImageInfo* info = backendRT.getVkImageInfo();
-    if (!info) {
-        return nullptr;
-    }
+    const GrVkImageInfo* info =
+        reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle);
     if (VK_NULL_HANDLE == info->fImage) {
         return nullptr;
     }
 
     GrSurfaceDesc desc;
-    desc.fConfig = backendRT.config();
+    desc.fConfig = wrapDesc.fConfig;
     desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag;
-    desc.fWidth = backendRT.width();
-    desc.fHeight = backendRT.height();
+    desc.fWidth = wrapDesc.fWidth;
+    desc.fHeight = wrapDesc.fHeight;
     desc.fSampleCnt = 0;
 
-    SkASSERT(kDefault_GrSurfaceOrigin != origin);
-    desc.fOrigin = origin;
+    desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
 
     sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
-    if (tgt && backendRT.stencilBits()) {
+    if (tgt && wrapDesc.fStencilBits) {
         if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
             return nullptr;
         }
@@ -857,9 +853,6 @@
                                                                   int sampleCnt) {
 
     const GrVkImageInfo* info = tex.getVkImageInfo();
-    if (!info) {
-        return nullptr;
-    }
     if (VK_NULL_HANDLE == info->fImage) {
         return nullptr;
     }
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 6ae34bd..d3e1555 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -180,8 +180,7 @@
                                           GrBackendTextureFlags,
                                           int sampleCnt,
                                           GrWrapOwnership) override;
-    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
-                                                    GrSurfaceOrigin) override;
+    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override;
 
     sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
                                                              GrSurfaceOrigin,
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 5001811..96ac31e 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -261,36 +261,19 @@
     if (!context) {
         return nullptr;
     }
-
-    GrBackendRenderTarget backendRT(desc, context->contextPriv().getBackend());
-    return MakeFromBackendRenderTarget(context, backendRT, desc.fOrigin,
-                                       std::move(colorSpace), props);
-
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
-                                                        const GrBackendRenderTarget& backendRT,
-                                                        GrSurfaceOrigin origin,
-                                                        sk_sp<SkColorSpace> colorSpace,
-                                                        const SkSurfaceProps* props) {
-    if (!context) {
-        return nullptr;
-    }
-    if (!SkSurface_Gpu::Valid(context, backendRT.config(), colorSpace.get())) {
+    if (!SkSurface_Gpu::Valid(context, desc.fConfig, colorSpace.get())) {
         return nullptr;
     }
 
     sk_sp<GrRenderTargetContext> rtc(
-        context->contextPriv().makeBackendRenderTargetRenderTargetContext(backendRT,
-                                                                          origin,
+        context->contextPriv().makeBackendRenderTargetRenderTargetContext(desc,
                                                                           std::move(colorSpace),
                                                                           props));
     if (!rtc) {
         return nullptr;
     }
 
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc),
-                                                backendRT.width(), backendRT.height(),
+    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), desc.fWidth, desc.fHeight,
                                                 SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
@@ -299,6 +282,16 @@
     return sk_make_sp<SkSurface_Gpu>(std::move(device));
 }
 
+sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
+                                                        const GrBackendRenderTarget&,
+                                                        GrSurfaceOrigin origin,
+                                                        sk_sp<SkColorSpace>,
+                                                        const SkSurfaceProps*) {
+    // This function is not implemented yet
+    sk_throw();
+    return nullptr;
+}
+
 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,
                                                                  const GrBackendTextureDesc& desc,
                                                                  sk_sp<SkColorSpace> colorSpace,
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index ba06a1f..f86bb9f 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -316,7 +316,6 @@
 
 #if SK_SUPPORT_GPU
 
-#include "GrBackendSurface.h"
 #include "GrContext.h"
 #include "gl/GrGLInterface.h"
 #include "gl/GrGLUtil.h"
@@ -325,9 +324,10 @@
 sk_sp<SkSurface> SkWindow::makeGpuBackedSurface(const AttachmentInfo& attachmentInfo,
                                                 const GrGLInterface* interface,
                                                 GrContext* grContext) {
-    int width = SkScalarRoundToInt(this->width());
-    int height = SkScalarRoundToInt(this->height());
-    if (0 == width || 0 == height) {
+    GrBackendRenderTargetDesc desc;
+    desc.fWidth = SkScalarRoundToInt(this->width());
+    desc.fHeight = SkScalarRoundToInt(this->height());
+    if (0 == desc.fWidth || 0 == desc.fHeight) {
         return nullptr;
     }
 
@@ -340,28 +340,22 @@
     //
     // ... and, if we're using a 10-bit/channel FB0, it doesn't do sRGB conversion on write,
     // so pretend that it's non-sRGB 8888:
-    GrPixelConfig config = grContext->caps()->srgbSupport() &&
-                           info().colorSpace() &&
-                           (attachmentInfo.fColorBits != 30)
-                           ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig;
-    GrGLFramebufferInfo fbInfo;
+    desc.fConfig =
+        grContext->caps()->srgbSupport() &&
+        info().colorSpace() &&
+        (attachmentInfo.fColorBits != 30)
+        ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig;
+    desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+    desc.fSampleCnt = attachmentInfo.fSampleCount;
+    desc.fStencilBits = attachmentInfo.fStencilBits;
     GrGLint buffer;
     GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
-    fbInfo.fFBOID = buffer;
-
-    GrBackendRenderTarget backendRT(width,
-                                    height,
-                                    attachmentInfo.fSampleCount,
-                                    attachmentInfo.fStencilBits,
-                                    config,
-                                    fbInfo);
-
+    desc.fRenderTargetHandle = buffer;
 
     sk_sp<SkColorSpace> colorSpace =
         grContext->caps()->srgbSupport() && info().colorSpace()
         ? SkColorSpace::MakeSRGB() : nullptr;
-    return SkSurface::MakeFromBackendRenderTarget(grContext, backendRT, kBottomLeft_GrSurfaceOrigin,
-                                                  colorSpace, &fSurfaceProps);
+    return SkSurface::MakeFromBackendRenderTarget(grContext, desc, colorSpace, &fSurfaceProps);
 }
 
 #endif
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index 167cc4b..a041d68 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -10,7 +10,6 @@
 #include "Test.h"
 
 #if SK_SUPPORT_GPU
-#include "GrBackendSurface.h"
 #include "GrRenderTargetProxy.h"
 #include "GrResourceProvider.h"
 #include "GrSurfaceProxy.h"
@@ -19,12 +18,16 @@
 static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider,
                                                skiatest::Reporter* reporter,
                                                const GrSurfaceDesc& desc) {
-    GrGLFramebufferInfo fboInfo;
-    fboInfo.fFBOID = 0;
-    GrBackendRenderTarget backendRT(desc.fWidth, desc.fHeight, desc.fSampleCnt, 8,
-                                    desc.fConfig, fboInfo);
+    GrBackendRenderTargetDesc backendDesc;
+    backendDesc.fWidth = desc.fWidth;
+    backendDesc.fHeight = desc.fHeight;
+    backendDesc.fConfig = desc.fConfig;
+    backendDesc.fOrigin = desc.fOrigin;
+    backendDesc.fSampleCnt = desc.fSampleCnt;
+    backendDesc.fStencilBits = 8;
+    backendDesc.fRenderTargetHandle = 0;
 
-    sk_sp<GrRenderTarget> defaultFBO(provider->wrapBackendRenderTarget(backendRT, desc.fOrigin));
+    sk_sp<GrRenderTarget> defaultFBO(provider->wrapBackendRenderTarget(backendDesc));
     SkASSERT(!defaultFBO->asTexture());
 
     return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO));
@@ -59,7 +62,6 @@
     desc.fWidth = 64;
     desc.fHeight = 64;
     desc.fConfig = kRGBA_8888_GrPixelConfig;
-    desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
 
     if (kOpenGL_GrBackend == ctxInfo.backend()) {
         // External on-screen render target.
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 6553b4e..db407d7 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -10,7 +10,6 @@
 #include "Test.h"
 
 #if SK_SUPPORT_GPU
-#include "GrBackendSurface.h"
 #include "GrRenderTargetPriv.h"
 #include "GrRenderTargetProxy.h"
 #include "GrResourceProvider.h"
@@ -21,7 +20,7 @@
 static void check_surface(skiatest::Reporter* reporter,
                           GrSurfaceProxy* proxy,
                           GrSurfaceOrigin origin,
-                          int width, int height,
+                          int width, int height, 
                           GrPixelConfig config,
                           const GrGpuResource::UniqueID& uniqueID,
                           SkBudgeted budgeted) {
@@ -229,13 +228,17 @@
 
                     // External on-screen render target.
                     if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) {
-                        GrGLFramebufferInfo fboInfo;
-                        fboInfo.fFBOID = 0;
-                        GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8,
-                                                        config, fboInfo);
+                        GrBackendRenderTargetDesc backendDesc;
+                        backendDesc.fWidth = kWidthHeight;
+                        backendDesc.fHeight = kWidthHeight;
+                        backendDesc.fConfig = config;
+                        backendDesc.fOrigin = origin;
+                        backendDesc.fSampleCnt = numSamples;
+                        backendDesc.fStencilBits = 8;
+                        backendDesc.fRenderTargetHandle = 0;
 
                         sk_sp<GrRenderTarget> defaultFBO(
-                            provider->wrapBackendRenderTarget(backendRT, origin));
+                            provider->wrapBackendRenderTarget(backendDesc));
 
                         sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO));
                         check_surface(reporter, sProxy.get(), origin,
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index 0ae3402..44b5e72 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -93,24 +93,30 @@
                                                                       true);
     const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
 
-    GrBackendRenderTarget backendRT(kW, kH, 0, 0, *backendTex);
-
-    sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(backendRT, kTopLeft_GrSurfaceOrigin);
+    // check basic borrowed creation
+    GrBackendRenderTargetDesc desc;
+    desc.fWidth = kW;
+    desc.fHeight = kH;
+    desc.fConfig = kPixelConfig;
+    desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+    desc.fSampleCnt = 0;
+    desc.fStencilBits = 0;
+    desc.fRenderTargetHandle = backendObj;
+    sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(desc);
     REPORTER_ASSERT(reporter, rt);
 
     // image is null
     GrVkImageInfo backendCopy = *backendTex;
     backendCopy.fImage = VK_NULL_HANDLE;
-    GrBackendRenderTarget backendRT2(kW, kH, 0, 0, backendCopy);
-    rt = gpu->wrapBackendRenderTarget(backendRT2, kTopLeft_GrSurfaceOrigin);
+    desc.fRenderTargetHandle = (GrBackendObject)&backendCopy;
+    rt = gpu->wrapBackendRenderTarget(desc);
     REPORTER_ASSERT(reporter, !rt);
 
     // alloc is null
     backendCopy.fImage = backendTex->fImage;
     backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
     // can wrap null alloc
-    GrBackendRenderTarget backendRT3(kW, kH, 0, 0, backendCopy);
-    rt = gpu->wrapBackendRenderTarget(backendRT3, kTopLeft_GrSurfaceOrigin);
+    rt = gpu->wrapBackendRenderTarget(desc);
     REPORTER_ASSERT(reporter, rt);
 
     // When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index c7751ec..2e34d2f 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -359,8 +359,7 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
-                                                    GrSurfaceOrigin) override {
+    sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override {
         return nullptr;
     }
 
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index 6195199..ff56ce8 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -6,18 +6,19 @@
  * found in the LICENSE file.
  */
 
-#include "GrBackendSurface.h"
 #include "GrContext.h"
-#include "GrRenderTarget.h"
+#include "SkSurface.h"
 #include "GLWindowContext.h"
 
 #include "gl/GrGLDefines.h"
+
 #include "gl/GrGLUtil.h"
+#include "GrRenderTarget.h"
+#include "GrContext.h"
 
 #include "SkCanvas.h"
 #include "SkImage_Base.h"
 #include "SkMathPriv.h"
-#include "SkSurface.h"
 
 namespace sk_app {
 
@@ -63,7 +64,7 @@
         fContext->unref();
         fContext = nullptr;
     }
-
+    
     fBackendContext.reset(nullptr);
 
     this->onDestroyContext();
@@ -72,21 +73,18 @@
 sk_sp<SkSurface> GLWindowContext::getBackbufferSurface() {
     if (nullptr == fSurface) {
         if (fContext) {
-            GrGLFramebufferInfo fbInfo;
+            GrBackendRenderTargetDesc desc;
+            desc.fWidth = this->fWidth;
+            desc.fHeight = this->fHeight;
+            desc.fConfig = fPixelConfig;
+            desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+            desc.fSampleCnt = fSampleCount;
+            desc.fStencilBits = fStencilBits;
             GrGLint buffer;
-            GR_GL_CALL(fBackendContext.get(), GetIntegerv(GR_GL_FRAMEBUFFER_BINDING,
-                                                          &buffer));
-            fbInfo.fFBOID = buffer;
+            GR_GL_CALL(fBackendContext.get(), GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer));
+            desc.fRenderTargetHandle = buffer;
 
-            GrBackendRenderTarget backendRT(fWidth,
-                                            fHeight,
-                                            fSampleCount,
-                                            fStencilBits,
-                                            fPixelConfig,
-                                            fbInfo);
-
-            fSurface = SkSurface::MakeFromBackendRenderTarget(fContext, backendRT,
-                                                              kBottomLeft_GrSurfaceOrigin,
+            fSurface = SkSurface::MakeFromBackendRenderTarget(fContext, desc,
                                                               fDisplayParams.fColorSpace,
                                                               &fSurfaceProps);
         }