Remove GrBackendTextureDesc

Change-Id: I2b123d1782400e97ab2ce2f11e3e3d325a13e6c8
Reviewed-on: https://skia-review.googlesource.com/24748
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index f63ba41..2a423c0 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -87,56 +87,9 @@
      */
     static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr);
 
-    /**
-     *  Create a new image from the specified descriptor. Note - the caller is responsible for
-     *  managing the lifetime of the underlying platform texture.
-     *
-     *  Will return NULL if the specified descriptor is unsupported.
-     *
-     *  It is preferred to use the new methods which take a GrBackendTexture instead of a
-     *  GrBackendTextureDesc. This method will eventually be removed.
-     */
-    static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc) {
-        return MakeFromTexture(ctx, desc, kPremul_SkAlphaType, nullptr, nullptr, nullptr);
-    }
-
-    static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& de,
-                                          SkAlphaType at) {
-        return MakeFromTexture(ctx, de, at, nullptr, nullptr, nullptr);
-    }
-
     typedef void (*TextureReleaseProc)(ReleaseContext);
 
     /**
-     *  Create a new image from the specified descriptor. The underlying platform texture must stay
-     *  valid and unaltered until the specified release-proc is invoked, indicating that Skia
-     *  no longer is holding a reference to it.
-     *
-     *  Will return NULL if the specified descriptor is unsupported.
-     *
-     *  It is preferred to use the new methods which take a GrBackendTexture instead of a
-     *  GrBackendTextureDesc. This method will eventually be removed.
-     */
-    static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
-                                          SkAlphaType at, TextureReleaseProc trp,
-                                          ReleaseContext rc) {
-        return MakeFromTexture(ctx, desc, at, nullptr, trp, rc);
-    }
-
-    /**
-    *  Create a new image from the specified descriptor. The underlying platform texture must stay
-    *  valid and unaltered until the specified release-proc is invoked, indicating that Skia
-    *  no longer is holding a reference to it.
-    *
-    *  Will return NULL if the specified descriptor is unsupported.
-     *
-     *  It is preferred to use the new methods which take a GrBackendTexture instead of a
-     *  GrBackendTextureDesc. This method will eventually be removed.
-    */
-    static sk_sp<SkImage> MakeFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
-                                          sk_sp<SkColorSpace>, TextureReleaseProc, ReleaseContext);
-
-    /**
      *  Create a new image from the specified descriptor. Note - the caller is responsible for
      *  managing the lifetime of the underlying platform texture.
      *
@@ -180,19 +133,6 @@
      *  Create a new image from the specified descriptor. Note - Skia will delete or recycle the
      *  texture when the image is released.
      *
-     *  Will return NULL if the specified descriptor is unsupported.
-     *
-     *  It is preferred to use the new methods which take a GrBackendTexture instead of a
-     *  GrBackendTextureDesc. This method will eventually be removed.
-     */
-    static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
-                                                 SkAlphaType = kPremul_SkAlphaType,
-                                                 sk_sp<SkColorSpace> = nullptr);
-
-    /**
-     *  Create a new image from the specified descriptor. Note - Skia will delete or recycle the
-     *  texture when the image is released.
-     *
      *  Will return NULL if the specified backend texture is unsupported.
      */
     static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext*,
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index f6142c9..c2a98bd 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -81,15 +81,6 @@
     }
 
     /**
-     *  Used to wrap a pre-existing backend 3D API texture as a SkSurface. The kRenderTarget flag
-     *  must be set on GrBackendTextureDesc for this to succeed. Skia will not assume ownership
-     *  of the texture and the client must ensure the texture is valid for the lifetime of the
-     *  SkSurface.
-     */
-    static sk_sp<SkSurface> MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
-                                                   sk_sp<SkColorSpace>, const SkSurfaceProps*);
-
-    /**
      *  Used to wrap a pre-existing backend 3D API texture as a SkSurface. Skia will not assume
      *  ownership of the texture and the client must ensure the texture is valid for the lifetime
      *  of the SkSurface. If sampleCnt > 0, then we will create an intermediate mssa surface which
@@ -123,9 +114,6 @@
      *  of the texture and the client must ensure the texture is valid for the lifetime of the
      *  SkSurface.
      */
-    static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
-        GrContext*, const GrBackendTextureDesc&, sk_sp<SkColorSpace>, const SkSurfaceProps*);
-
     static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext*,
                                                                  const GrBackendTexture&,
                                                                  GrSurfaceOrigin origin,
@@ -134,25 +122,15 @@
                                                                  const SkSurfaceProps*);
 
     /**
-     * Legacy versions of the above factories, without color space support. These create "legacy"
-     * surfaces that operate without gamma correction or color management.
+     * Legacy version of the above factory, without color space support. This creates a "legacy"
+     * surface that operate without gamma correction or color management.
      */
-    static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
-                                                   const SkSurfaceProps* props) {
-        return MakeFromBackendTexture(ctx, desc, nullptr, props);
-    }
-
     static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* ctx,
                                                         const GrBackendRenderTargetDesc& desc,
                                                         const SkSurfaceProps* props) {
         return MakeFromBackendRenderTarget(ctx, desc, nullptr, props);
     }
 
-    static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
-            GrContext* ctx, const GrBackendTextureDesc& desc, const SkSurfaceProps* props) {
-        return MakeFromBackendTextureAsRenderTarget(ctx, desc, nullptr, props);
-    }
-
 
     /**
      *  Return a new surface whose contents will be drawn to an offscreen
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index bb50484..c9a9ad0 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -59,13 +59,6 @@
 private:
     bool isValid() const { return fConfig != kUnknown_GrPixelConfig; }
 
-    // Temporary constructor which can be used to convert from a GrBackendTextureDesc.
-    GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend);
-
-    // Friending for access to above constructor taking a GrBackendTextureDesc
-    friend class SkImage;
-    friend class SkSurface;
-
     int fWidth;         //<! width in pixels
     int fHeight;        //<! height in pixels
     GrPixelConfig fConfig;
@@ -118,7 +111,7 @@
     // Temporary constructor which can be used to convert from a GrBackendRenderTargetDesc.
     GrBackendRenderTarget(const GrBackendRenderTargetDesc& desc, GrBackend backend);
 
-    // Friending for access to above constructor taking a GrBackendTextureDesc
+    // Friending for access to above constructor taking a GrBackendRenderTargetDesc
     friend class SkSurface;
 
     int fWidth;         //<! width in pixels
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index e56cead..a343f03 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -635,7 +635,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-
 /** Ownership rules for external GPU resources imported into Skia. */
 enum GrWrapOwnership {
     /** Skia will assume the client will keep the resource alive and Skia will not free it. */
@@ -645,60 +644,6 @@
     kAdopt_GrWrapOwnership,
 };
 
-/**
- * Gr can wrap an existing texture created by the client with a GrTexture
- * object. The client is responsible for ensuring that the texture lives at
- * least as long as the GrTexture object wrapping it. We require the client to
- * explicitly provide information about the texture, such as width, height,
- * and pixel config, rather than querying the 3D APIfor these values. We expect
- * these to be immutable even if the 3D API doesn't require this (OpenGL).
- *
- * Textures that are also render targets are supported as well. Gr will manage
- * any ancillary 3D API (stencil buffer, FBO id, etc) objects necessary for
- * Gr to draw into the render target. To access the render target object
- * call GrTexture::asRenderTarget().
- *
- * If in addition to the render target flag, the caller also specifies a sample
- * count Gr will create an MSAA buffer that resolves into the texture. Gr auto-
- * resolves when it reads from the texture. The client can explictly resolve
- * using the GrRenderTarget interface.
- *
- * Note: These flags currently form a subset of GrTexture's flags.
- */
-
-enum GrBackendTextureFlags {
-    /**
-     * No flags enabled
-     */
-    kNone_GrBackendTextureFlag             = 0,
-    /**
-     * Indicates that the texture is also a render target, and thus should have
-     * a GrRenderTarget object.
-     */
-    kRenderTarget_GrBackendTextureFlag     = kRenderTarget_GrSurfaceFlag,
-};
-GR_MAKE_BITFIELD_OPS(GrBackendTextureFlags)
-
-struct GrBackendTextureDesc {
-    GrBackendTextureDesc() { memset(this, 0, sizeof(*this)); }
-    GrBackendTextureFlags           fFlags;
-    GrSurfaceOrigin                 fOrigin;
-    int                             fWidth;         //<! width in pixels
-    int                             fHeight;        //<! height in pixels
-    GrPixelConfig                   fConfig;        //<! color format
-    /**
-     * If the render target flag is set and sample count is greater than 0
-     * then Gr will create an MSAA buffer that resolves to the texture.
-     */
-    int                             fSampleCnt;
-    /**
-     * Handle to the 3D API object.
-     * OpenGL: Texture ID.
-     * Vulkan: GrVkImageInfo*
-     */
-    GrBackendObject                 fTextureHandle;
-};
-
 ///////////////////////////////////////////////////////////////////////////////
 
 /**
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index bc6f9a2..d37c73a 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -43,33 +43,6 @@
         , fBackend(kMock_GrBackend)
         , fMockInfo(mockInfo) {}
 
-GrBackendTexture::GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend)
-        : fWidth(desc.fWidth)
-        , fHeight(desc.fHeight)
-        , fConfig(desc.fConfig)
-        , fBackend(backend) {
-    switch (backend) {
-        case kOpenGL_GrBackend:
-            fGLInfo = *reinterpret_cast<const GrGLTextureInfo*>(desc.fTextureHandle);
-            break;
-#ifdef SK_VULKAN
-        case kVulkan_GrBackend: {
-            const GrVkImageInfo* vkInfo =
-                    reinterpret_cast<const GrVkImageInfo*>(desc.fTextureHandle);
-            fConfig = GrVkFormatToPixelConfig(vkInfo->fFormat);
-            fVkInfo = *vkInfo;
-            break;
-        }
-#endif
-        case kMock_GrBackend:
-            fMockInfo = *reinterpret_cast<const GrMockTextureInfo*>(desc.fTextureHandle);
-            break;
-        default:
-            fConfig = kUnknown_GrPixelConfig;
-            break;
-    }
-}
-
 #ifdef SK_VULKAN
 const GrVkImageInfo* GrBackendTexture::getVkImageInfo() const {
     if (this->isValid() && kVulkan_GrBackend == fBackend) {
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 52ba4e7..dac8168 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -152,7 +152,6 @@
         // with it. This is unfortunate - we'll have two texture objects referencing the same GPU
         // object. However, no client can ever see the original texture, so this should be safe.
         tex = context->resourceProvider()->wrapBackendTexture(fBackendTexture, fSurfaceOrigin,
-                                                              kNone_GrBackendTextureFlag, 0,
                                                               kBorrow_GrWrapOwnership);
         if (!tex) {
             fRefHelper->fBorrowingContextID = SK_InvalidGenID;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index ecf4398..88fe379 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -666,15 +666,12 @@
     return this->makeWrappedSurfaceContext(std::move(proxy), nullptr);
 }
 
-sk_sp<GrSurfaceContext> GrContextPriv::makeBackendSurfaceContext(const GrBackendTexture& tex,
+sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
                                                                  GrSurfaceOrigin origin,
-                                                                 GrBackendTextureFlags flags,
-                                                                 int sampleCnt,
                                                                  sk_sp<SkColorSpace> colorSpace) {
     ASSERT_SINGLE_OWNER_PRIV
 
-    sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(tex, origin,
-                                                                              flags, sampleCnt));
+    sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(tex, origin));
     if (!surface) {
         return nullptr;
     }
@@ -684,7 +681,7 @@
         return nullptr;
     }
 
-    return this->makeWrappedSurfaceContext(std::move(proxy), std::move(colorSpace));
+    return this->drawingManager()->makeTextureContext(std::move(proxy), std::move(colorSpace));
 }
 
 sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
@@ -695,9 +692,8 @@
                                                                    const SkSurfaceProps* props) {
     ASSERT_SINGLE_OWNER_PRIV
 
-    static const GrBackendTextureFlags kForceRT = kRenderTarget_GrBackendTextureFlag;
-    sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(tex, origin, kForceRT,
-                                                                              sampleCnt));
+    sk_sp<GrSurface> surface(
+            fContext->resourceProvider()->wrapRenderableBackendTexture(tex, origin, sampleCnt));
     if (!surface) {
         return nullptr;
     }
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index a043b64..be67d0e 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -12,9 +12,10 @@
 #include "GrSurfaceContext.h"
 
 class GrBackendRenderTarget;
+class GrOnFlushCallbackObject;
 class GrSemaphore;
 class GrSurfaceProxy;
-class GrOnFlushCallbackObject;
+class GrTextureContext;
 
 /** Class that adds methods to GrContext that are only intended for use internal to Skia.
     This class is purely a privileged window into GrContext. It should never have additional
@@ -29,12 +30,8 @@
                                                        SkBackingFit,
                                                        SkBudgeted);
 
-    // TODO: Maybe add a 'surfaceProps' param (that is ignored for non-RTs) and remove
-    // makeBackendTextureRenderTargetContext & makeBackendTextureAsRenderTargetRenderTargetContext
-    sk_sp<GrSurfaceContext> makeBackendSurfaceContext(const GrBackendTexture& tex,
+    sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture& tex,
                                                       GrSurfaceOrigin origin,
-                                                      GrBackendTextureFlags flags,
-                                                      int sampleCnt,
                                                       sk_sp<SkColorSpace> colorSpace);
 
     sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 038ffef..afe3956 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -175,31 +175,44 @@
 
 sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
                                            GrSurfaceOrigin origin,
-                                           GrBackendTextureFlags flags,
-                                           int sampleCnt,
                                            GrWrapOwnership ownership) {
     this->handleDirtyContext();
     if (!this->caps()->isConfigTexturable(backendTex.config())) {
         return nullptr;
     }
-    if ((flags & kRenderTarget_GrBackendTextureFlag) &&
-        !this->caps()->isConfigRenderable(backendTex.config(), sampleCnt > 0)) {
+    if (backendTex.width() > this->caps()->maxTextureSize() ||
+        backendTex.height() > this->caps()->maxTextureSize()) {
         return nullptr;
     }
-    int maxSize = this->caps()->maxTextureSize();
-    if (backendTex.width() > maxSize || backendTex.height() > maxSize) {
-        return nullptr;
-    }
-    sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, origin, flags, sampleCnt,
-                                                      ownership);
+    sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, origin, ownership);
     if (!tex) {
         return nullptr;
     }
+    return tex;
+}
 
+sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
+                                                     GrSurfaceOrigin origin, int sampleCnt,
+                                                     GrWrapOwnership ownership) {
+    this->handleDirtyContext();
+    if (!this->caps()->isConfigTexturable(backendTex.config()) ||
+        !this->caps()->isConfigRenderable(backendTex.config(), sampleCnt > 0)) {
+        return nullptr;
+    }
+
+    if (backendTex.width() > this->caps()->maxRenderTargetSize() ||
+        backendTex.height() > this->caps()->maxRenderTargetSize()) {
+        return nullptr;
+    }
+    sk_sp<GrTexture> tex =
+            this->onWrapRenderableBackendTexture(backendTex, origin, sampleCnt, ownership);
+    if (!tex) {
+        return nullptr;
+    }
+    SkASSERT(tex->asRenderTarget());
     if (!this->caps()->avoidStencilBuffers()) {
         // TODO: defer this and attach dynamically
-        GrRenderTarget* tgt = tex->asRenderTarget();
-        if (tgt && !fContext->resourceProvider()->attachStencilAttachment(tgt)) {
+        if (!fContext->resourceProvider()->attachStencilAttachment(tex->asRenderTarget())) {
             return nullptr;
         }
     }
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index af061da..c6684ac 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -118,8 +118,13 @@
     /**
      * Implements GrResourceProvider::wrapBackendTexture
      */
-    sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
-                                        GrBackendTextureFlags, int sampleCnt, GrWrapOwnership);
+    sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, GrWrapOwnership);
+
+    /**
+     * Implements GrResourceProvider::wrapRenderableBackendTexture
+     */
+    sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
+                                                  int sampleCnt, GrWrapOwnership);
 
     /**
      * Implements GrResourceProvider::wrapBackendRenderTarget
@@ -546,9 +551,11 @@
 
     virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
                                                   GrSurfaceOrigin,
-                                                  GrBackendTextureFlags,
-                                                  int sampleCnt,
                                                   GrWrapOwnership) = 0;
+    virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
+                                                            GrSurfaceOrigin,
+                                                            int sampleCnt,
+                                                            GrWrapOwnership) = 0;
     virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
                                                             GrSurfaceOrigin) = 0;
     virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index f3be50b..cc9ec2a 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -239,14 +239,23 @@
 
 sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture& tex,
                                                         GrSurfaceOrigin origin,
-                                                        GrBackendTextureFlags flags,
-                                                        int sampleCnt,
                                                         GrWrapOwnership ownership) {
     ASSERT_SINGLE_OWNER
     if (this->isAbandoned()) {
         return nullptr;
     }
-    return fGpu->wrapBackendTexture(tex, origin, flags, sampleCnt, ownership);
+    return fGpu->wrapBackendTexture(tex, origin, ownership);
+}
+
+sk_sp<GrTexture> GrResourceProvider::wrapRenderableBackendTexture(const GrBackendTexture& tex,
+                                                                  GrSurfaceOrigin origin,
+                                                                  int sampleCnt,
+                                                                  GrWrapOwnership ownership) {
+    ASSERT_SINGLE_OWNER
+    if (this->isAbandoned()) {
+        return nullptr;
+    }
+    return fGpu->wrapRenderableBackendTexture(tex, origin, sampleCnt, ownership);
 }
 
 sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget(
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index a50333d..44155a8 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -86,11 +86,19 @@
      */
     sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex,
                                         GrSurfaceOrigin origin,
-                                        GrBackendTextureFlags flags,
-                                        int sampleCnt,
                                         GrWrapOwnership = kBorrow_GrWrapOwnership);
 
     /**
+     * This makes the backend texture be renderable. If sampleCnt is > 0 and the underlying API
+     * uses separate MSAA render buffers then a MSAA render buffer is created that resolves
+     * to the texture.
+     */
+    sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture& tex,
+                                                  GrSurfaceOrigin origin,
+                                                  int sampleCnt,
+                                                  GrWrapOwnership = kBorrow_GrWrapOwnership);
+
+    /**
      * Wraps an existing render target with a GrRenderTarget object. It is
      * similar to wrapBackendTexture but can be used to draw into surfaces
      * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index f300770..0932971 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -248,8 +248,7 @@
 sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context,
                                                          GrBackendTexture& backendTex,
                                                          GrSurfaceOrigin origin) {
-    sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(
-            backendTex, origin, kNone_GrBackendTextureFlag, 0));
+    sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(backendTex, origin));
     return GrSurfaceProxy::MakeWrapped(std::move(tex));
 }
 
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index a7ef780..760af59 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -76,15 +76,17 @@
     int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
                                                : GrProcessorUnitTest::kAlphaTextureIdx;
     static const SkShader::TileMode kTileModes[] = {
-            SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode,
+            SkShader::kClamp_TileMode,
+            SkShader::kRepeat_TileMode,
+            SkShader::kMirror_TileMode,
     };
     SkShader::TileMode tileModes[] = {
             kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
             kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
     };
-    GrSamplerParams params(tileModes,
-                           testData->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
-                                                         : GrSamplerParams::kNone_FilterMode);
+    GrSamplerParams params(tileModes, testData->fRandom->nextBool()
+                                              ? GrSamplerParams::kBilerp_FilterMode
+                                              : GrSamplerParams::kNone_FilterMode);
 
     const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
     sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index b310df4..49be761 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -523,41 +523,71 @@
     }
 }
 
-sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
-                                               GrSurfaceOrigin origin,
-                                               GrBackendTextureFlags flags,
-                                               int sampleCnt,
-                                               GrWrapOwnership ownership) {
+static bool check_backend_texture(const GrBackendTexture& backendTex, const GrGLCaps& caps,
+                                  GrGLTexture::IDDesc* idDesc) {
     const GrGLTextureInfo* info = backendTex.getGLTextureInfo();
     if (!info || !info->fID) {
-        return nullptr;
+        return false;
     }
 
-    // next line relies on GrBackendTextureFlags matching GrTexture's
-    bool renderTarget = SkToBool(flags & kRenderTarget_GrBackendTextureFlag);
+    idDesc->fInfo = *info;
 
+    if (GR_GL_TEXTURE_EXTERNAL == idDesc->fInfo.fTarget) {
+        if (!caps.shaderCaps()->externalTextureSupport()) {
+            return false;
+        }
+    } else if (GR_GL_TEXTURE_RECTANGLE == idDesc->fInfo.fTarget) {
+        if (!caps.rectangleTextureSupport()) {
+            return false;
+        }
+    } else if (GR_GL_TEXTURE_2D != idDesc->fInfo.fTarget) {
+        return false;
+    }
+    return true;
+}
+
+sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
+                                               GrSurfaceOrigin origin,
+                                               GrWrapOwnership ownership) {
     GrGLTexture::IDDesc idDesc;
-    idDesc.fInfo = *info;
+    if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
+        return nullptr;
+    }
+    if (kBorrow_GrWrapOwnership == ownership) {
+        idDesc.fOwnership = GrBackendObjectOwnership::kBorrowed;
+    } else {
+        idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
+    }
 
-    if (GR_GL_TEXTURE_EXTERNAL == idDesc.fInfo.fTarget) {
-        if (renderTarget) {
-            // This combination is not supported.
-            return nullptr;
-        }
-        if (!this->caps()->shaderCaps()->externalTextureSupport()) {
-            return nullptr;
-        }
-    } else  if (GR_GL_TEXTURE_RECTANGLE == idDesc.fInfo.fTarget) {
-        if (!this->glCaps().rectangleTextureSupport()) {
-            return nullptr;
-        }
-    } else if (GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) {
+    GrSurfaceDesc surfDesc;
+    surfDesc.fFlags = kNone_GrSurfaceFlags;
+    surfDesc.fWidth = backendTex.width();
+    surfDesc.fHeight = backendTex.height();
+    surfDesc.fConfig = backendTex.config();
+    surfDesc.fSampleCnt = 0;
+    // FIXME:  this should be calling resolve_origin(), but Chrome code is currently
+    // assuming the old behaviour, which is that backend textures are always
+    // BottomLeft, even for non-RT's.  Once Chrome is fixed, change this to:
+    // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
+    if (kDefault_GrSurfaceOrigin == origin) {
+        surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+    } else {
+        surfDesc.fOrigin = origin;
+    }
+    return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
+}
+
+sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
+                                                         GrSurfaceOrigin origin,
+                                                         int sampleCnt,
+                                                         GrWrapOwnership ownership) {
+    GrGLTexture::IDDesc idDesc;
+    if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
         return nullptr;
     }
 
-    // Sample count is interpreted to mean the number of samples that Gr code should allocate
-    // for a render buffer that resolves to the texture. We don't support MSAA textures.
-    if (sampleCnt && !renderTarget) {
+    // We don't support rendering to a EXTERNAL texture.
+    if (GR_GL_TEXTURE_EXTERNAL == idDesc.fInfo.fTarget) {
         return nullptr;
     }
 
@@ -568,7 +598,7 @@
     }
 
     GrSurfaceDesc surfDesc;
-    surfDesc.fFlags = (GrSurfaceFlags) flags;
+    surfDesc.fFlags = kRenderTarget_GrSurfaceFlag;
     surfDesc.fWidth = backendTex.width();
     surfDesc.fHeight = backendTex.height();
     surfDesc.fConfig = backendTex.config();
@@ -583,18 +613,14 @@
         surfDesc.fOrigin = origin;
     }
 
-    if (renderTarget) {
-        GrGLRenderTarget::IDDesc rtIDDesc;
-        if (!this->createRenderTargetObjects(surfDesc, idDesc.fInfo, &rtIDDesc)) {
-            return nullptr;
-        }
-        sk_sp<GrGLTextureRenderTarget> texRT(
-                GrGLTextureRenderTarget::MakeWrapped(this, surfDesc, idDesc, rtIDDesc));
-        texRT->baseLevelWasBoundToFBO();
-        return texRT;
+    GrGLRenderTarget::IDDesc rtIDDesc;
+    if (!this->createRenderTargetObjects(surfDesc, idDesc.fInfo, &rtIDDesc)) {
+        return nullptr;
     }
-
-    return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
+    sk_sp<GrGLTextureRenderTarget> texRT(
+            GrGLTextureRenderTarget::MakeWrapped(this, surfDesc, idDesc, rtIDDesc));
+    texRT->baseLevelWasBoundToFBO();
+    return std::move(texRT);
 }
 
 sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 9d9c2b0..9b6e004 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -193,9 +193,11 @@
 
     sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
                                           GrSurfaceOrigin,
-                                          GrBackendTextureFlags,
-                                          int sampleCnt,
                                           GrWrapOwnership) override;
+    sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
+                                                    GrSurfaceOrigin,
+                                                    int sampleCnt,
+                                                    GrWrapOwnership) override;
     sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
                                                     GrSurfaceOrigin origin) override;
     sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index b6ba494..e31570a 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -71,12 +71,17 @@
 
     sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
                                           GrSurfaceOrigin,
-                                          GrBackendTextureFlags,
-                                          int sampleCnt,
                                           GrWrapOwnership) override {
         return nullptr;
     }
 
+    sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
+                                                    GrSurfaceOrigin,
+                                                    int sampleCnt,
+                                                    GrWrapOwnership) override {
+        return nullptr;
+    }
+
     sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
                                                     GrSurfaceOrigin) override {
         return nullptr;
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index b63f908..f150e30 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -74,12 +74,17 @@
 
     sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
                                           GrSurfaceOrigin,
-                                          GrBackendTextureFlags,
-                                          int sampleCnt,
                                           GrWrapOwnership) override {
         return nullptr;
     }
 
+    sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
+                                                    GrSurfaceOrigin,
+                                                    int sampleCnt,
+                                                    GrWrapOwnership) override {
+        return nullptr;
+    }
+
     sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
                                                     GrSurfaceOrigin) override {
         return nullptr;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index cd0fc99..d7094b7 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -855,43 +855,60 @@
     }
 }
 
-sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
-                                               GrSurfaceOrigin origin,
-                                               GrBackendTextureFlags flags,
-                                               int sampleCnt,
-                                               GrWrapOwnership ownership) {
+static bool check_backend_texture(const GrBackendTexture& backendTex) {
     const GrVkImageInfo* info = backendTex.getVkImageInfo();
     if (!info) {
-        return nullptr;
-    }
-
-    int maxSize = this->caps()->maxTextureSize();
-    if (backendTex.width() > maxSize || backendTex.height() > maxSize) {
-        return nullptr;
+        return false;
     }
 
     if (VK_NULL_HANDLE == info->fImage || VK_NULL_HANDLE == info->fAlloc.fMemory) {
-        return nullptr;
+        return false;
     }
 
     SkASSERT(backendTex.config() == GrVkFormatToPixelConfig(info->fFormat));
+    return true;
+}
+
+sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
+                                               GrSurfaceOrigin origin,
+                                               GrWrapOwnership ownership) {
+    if (!check_backend_texture(backendTex)) {
+        return nullptr;
+    }
 
     GrSurfaceDesc surfDesc;
-    // next line relies on GrBackendTextureFlags matching GrTexture's
-    surfDesc.fFlags = (GrSurfaceFlags)flags;
+    surfDesc.fFlags = kNone_GrSurfaceFlags;
     surfDesc.fWidth = backendTex.width();
     surfDesc.fHeight = backendTex.height();
     surfDesc.fConfig = backendTex.config();
-    surfDesc.fSampleCnt = this->caps()->getSampleCount(sampleCnt, backendTex.config());
-    bool renderTarget = SkToBool(flags & kRenderTarget_GrBackendTextureFlag);
+    surfDesc.fSampleCnt = 0;
     // In GL, Chrome assumes all textures are BottomLeft
     // In VK, we don't have this restriction
     surfDesc.fOrigin = resolve_origin(origin);
 
-    if (!renderTarget) {
-        return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, info);
+    return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, backendTex.getVkImageInfo());
+}
+
+sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
+                                                         GrSurfaceOrigin origin,
+                                                         int sampleCnt,
+                                                         GrWrapOwnership ownership) {
+    if (!check_backend_texture(backendTex)) {
+        return nullptr;
     }
-    return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership, info);
+
+    GrSurfaceDesc surfDesc;
+    surfDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+    surfDesc.fWidth = backendTex.width();
+    surfDesc.fHeight = backendTex.height();
+    surfDesc.fConfig = backendTex.config();
+    surfDesc.fSampleCnt = this->caps()->getSampleCount(sampleCnt, backendTex.config());
+    // In GL, Chrome assumes all textures are BottomLeft
+    // In VK, we don't have this restriction
+    surfDesc.fOrigin = resolve_origin(origin);
+
+    return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership,
+                                                                   backendTex.getVkImageInfo());
 }
 
 sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index ab4df3e..419e9e3 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -178,9 +178,11 @@
 
     sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
                                           GrSurfaceOrigin,
-                                          GrBackendTextureFlags,
-                                          int sampleCnt,
                                           GrWrapOwnership) override;
+    sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
+                                                    GrSurfaceOrigin,
+                                                    int sampleCnt,
+                                                    GrWrapOwnership) override;
     sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
                                                     GrSurfaceOrigin) override;
 
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 841e83c..3ac8ba8 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -334,11 +334,6 @@
     return nullptr;
 }
 
-sk_sp<SkImage> SkImage::MakeFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
-                                        sk_sp<SkColorSpace>, TextureReleaseProc, ReleaseContext) {
-    return nullptr;
-}
-
 sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx,
                                         const GrBackendTexture& tex, GrSurfaceOrigin origin,
                                         SkAlphaType at, sk_sp<SkColorSpace> cs,
@@ -359,11 +354,6 @@
     return nullptr;
 }
 
-sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
-                                               SkAlphaType, sk_sp<SkColorSpace>) {
-    return nullptr;
-}
-
 sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx,
                                                const GrBackendTexture& tex, GrSurfaceOrigin origin,
                                                SkAlphaType at, sk_sp<SkColorSpace> cs) {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 5dd7943..adc2359 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -266,11 +266,8 @@
         return nullptr;
     }
 
-    GrBackendTextureFlags flags = kNone_GrBackendTextureFlag;
     sk_sp<GrTexture> tex = ctx->resourceProvider()->wrapBackendTexture(backendTex,
                                                                        origin,
-                                                                       flags,
-                                                                       0,
                                                                        ownership);
     if (!tex) {
         return nullptr;
@@ -285,25 +282,6 @@
                                    at, std::move(proxy), std::move(colorSpace), budgeted);
 }
 
-sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
-                                        SkAlphaType at, sk_sp<SkColorSpace> cs,
-                                        TextureReleaseProc releaseP, ReleaseContext releaseC) {
-    SkASSERT(!(kRenderTarget_GrBackendTextureFlag & desc.fFlags));
-    GrBackendTexture tex(desc, ctx->contextPriv().getBackend());
-    return new_wrapped_texture_common(ctx, tex, desc.fOrigin, at, std::move(cs),
-                                      kBorrow_GrWrapOwnership,
-                                      releaseP, releaseC);
-}
-
-sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
-                                               SkAlphaType at, sk_sp<SkColorSpace> cs) {
-    SkASSERT(!(kRenderTarget_GrBackendTextureFlag & desc.fFlags));
-    GrBackendTexture tex(desc, ctx->contextPriv().getBackend());
-    return new_wrapped_texture_common(ctx, tex, desc.fOrigin, at, std::move(cs),
-                                      kAdopt_GrWrapOwnership,
-                                      nullptr, nullptr);
-}
-
 sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx,
                                         const GrBackendTexture& tex, GrSurfaceOrigin origin,
                                         SkAlphaType at, sk_sp<SkColorSpace> cs,
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index dcf5649..d7fa605 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -234,11 +234,6 @@
     return nullptr;
 }
 
-sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
-                                                   sk_sp<SkColorSpace>, const SkSurfaceProps*) {
-    return nullptr;
-}
-
 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTexture&,
                                                    GrSurfaceOrigin origin, int sampleCnt,
                                                    sk_sp<SkColorSpace>, const SkSurfaceProps*) {
@@ -261,13 +256,6 @@
 }
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext*,
-                                                                 const GrBackendTextureDesc&,
-                                                                 sk_sp<SkColorSpace>,
-                                                                 const SkSurfaceProps*) {
-    return nullptr;
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext*,
                                                                  const GrBackendTexture&,
                                                                  GrSurfaceOrigin origin,
                                                                  int sampleCnt,
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 732fe4a..143a603 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -203,17 +203,6 @@
     return sk_make_sp<SkSurface_Gpu>(std::move(device));
 }
 
-sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
-                                                   const GrBackendTextureDesc& desc,
-                                                   sk_sp<SkColorSpace> colorSpace,
-                                                   const SkSurfaceProps* props) {
-    if (!context) {
-        return nullptr;
-    }
-    GrBackendTexture tex(desc, context->contextPriv().getBackend());
-    return MakeFromBackendTexture(context, tex, desc.fOrigin, desc.fSampleCnt, colorSpace, props);
-}
-
 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrBackendTexture& tex,
                                                    GrSurfaceOrigin origin, int sampleCnt,
                                                    sk_sp<SkColorSpace> colorSpace,
@@ -289,18 +278,6 @@
 }
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,
-                                                                 const GrBackendTextureDesc& desc,
-                                                                 sk_sp<SkColorSpace> colorSpace,
-                                                                 const SkSurfaceProps* props) {
-    if (!context) {
-        return nullptr;
-    }
-    GrBackendTexture tex(desc, context->contextPriv().getBackend());
-    return MakeFromBackendTextureAsRenderTarget(context, tex, desc.fOrigin, desc.fSampleCnt,
-                                                std::move(colorSpace), props);
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,
                                                                  const GrBackendTexture& tex,
                                                                  GrSurfaceOrigin origin,
                                                                  int sampleCnt,
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 5ddccdf..84a6bfd 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -9,14 +9,15 @@
 #include "TestUtils.h"
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
-#include "GrContextPriv.h"
 #include "GrContextFactory.h"
+#include "GrContextPriv.h"
+#include "GrRenderTargetContext.h"
 #include "GrShaderCaps.h"
-#include "GrSurfaceContext.h"
 #include "GrTest.h"
+#include "GrTextureContext.h"
+#include "gl/GLTestContext.h"
 #include "gl/GrGLGpu.h"
 #include "gl/GrGLUtil.h"
-#include "gl/GLTestContext.h"
 
 using sk_gpu_test::GLTestContext;
 
@@ -139,8 +140,8 @@
 
     // TODO: If I make this TopLeft origin to match resolve_origin calls for kDefault, this test
     // fails on the Nexus5. Why?
-    sk_sp<GrSurfaceContext> surfaceContext = context0->contextPriv().makeBackendSurfaceContext(
-            backendTex, kBottomLeft_GrSurfaceOrigin, kNone_GrBackendTextureFlag, 0, nullptr);
+    sk_sp<GrTextureContext> surfaceContext = context0->contextPriv().makeBackendTextureContext(
+            backendTex, kBottomLeft_GrSurfaceOrigin, nullptr);
 
     if (!surfaceContext) {
         ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");
@@ -150,23 +151,14 @@
 
     // Should not be able to wrap as a RT
     {
-        sk_sp<GrSurfaceContext> temp = context0->contextPriv().makeBackendSurfaceContext(
-            backendTex, kBottomLeft_GrSurfaceOrigin, kRenderTarget_GrBackendTextureFlag, 0,
-            nullptr);
+        sk_sp<GrRenderTargetContext> temp =
+                context0->contextPriv().makeBackendTextureRenderTargetContext(
+                        backendTex, kBottomLeft_GrSurfaceOrigin, 0, nullptr);
         if (temp) {
             ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
         }
     }
 
-    // Should not be able to wrap with a sample count
-    {
-        sk_sp<GrSurfaceContext> temp = context0->contextPriv().makeBackendSurfaceContext(
-            backendTex, kBottomLeft_GrSurfaceOrigin, kNone_GrBackendTextureFlag, 4, nullptr);
-        if (temp) {
-            ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture with MSAA.");
-        }
-    }
-
     test_read_pixels(reporter, surfaceContext.get(), pixels.get(), "EGLImageTest-read");
 
     // We should not be able to write to a EXTERNAL texture
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 0b00893..d67f103 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -54,9 +54,8 @@
                                                                kRGBA_8888_GrPixelConfig,
                                                                backendTexHandle);
 
-    sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapBackendTexture(
-        backendTex, kTopLeft_GrSurfaceOrigin, kRenderTarget_GrBackendTextureFlag, 0,
-        kBorrow_GrWrapOwnership);
+    sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapRenderableBackendTexture(
+            backendTex, kTopLeft_GrSurfaceOrigin, 0, kBorrow_GrWrapOwnership);
 
     REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
     REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 50ddd00..3cfa157 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -228,8 +228,7 @@
                                                                 kRGBA_8888_GrPixelConfig,
                                                                 texHandles[0]);
     sk_sp<GrTexture> borrowed(context->resourceProvider()->wrapBackendTexture(
-                              backendTex1, kTopLeft_GrSurfaceOrigin, kNone_GrBackendTextureFlag, 0,
-                              kBorrow_GrWrapOwnership));
+            backendTex1, kTopLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership));
 
     GrBackendTexture backendTex2 = GrTest::CreateBackendTexture(context->contextPriv().getBackend(),
                                                                 kW,
@@ -237,8 +236,7 @@
                                                                 kRGBA_8888_GrPixelConfig,
                                                                 texHandles[1]);
     sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture(
-                             backendTex2, kTopLeft_GrSurfaceOrigin, kNone_GrBackendTextureFlag, 0,
-                             kAdopt_GrWrapOwnership));
+            backendTex2, kTopLeft_GrSurfaceOrigin, kAdopt_GrWrapOwnership));
 
     REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
     if (!borrowed || !adopted) {
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index ca0feb5..4e36315 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -38,8 +38,6 @@
     GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo);
     sk_sp<GrTexture> tex = gpu->wrapBackendTexture(backendTex,
                                                    kTopLeft_GrSurfaceOrigin,
-                                                   kNone_GrBackendTextureFlag,
-                                                   0,
                                                    kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, tex);
 
@@ -49,14 +47,10 @@
     backendTex = GrBackendTexture(kW, kH, backendCopy);
     tex = gpu->wrapBackendTexture(backendTex,
                                   kTopLeft_GrSurfaceOrigin,
-                                  kNone_GrBackendTextureFlag,
-                                  0,
                                   kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
     tex = gpu->wrapBackendTexture(backendTex,
                                   kTopLeft_GrSurfaceOrigin,
-                                  kNone_GrBackendTextureFlag,
-                                  0,
                                   kAdopt_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
 
@@ -66,14 +60,10 @@
     backendTex = GrBackendTexture(kW, kH, backendCopy);
     tex = gpu->wrapBackendTexture(backendTex,
                                   kTopLeft_GrSurfaceOrigin,
-                                  kNone_GrBackendTextureFlag,
-                                  0,
                                   kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
     tex = gpu->wrapBackendTexture(backendTex,
                                   kTopLeft_GrSurfaceOrigin,
-                                  kNone_GrBackendTextureFlag,
-                                  0,
                                   kAdopt_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
     // check adopt creation
@@ -81,8 +71,6 @@
     backendTex = GrBackendTexture(kW, kH, backendCopy);
     tex = gpu->wrapBackendTexture(backendTex,
                                   kTopLeft_GrSurfaceOrigin,
-                                  kNone_GrBackendTextureFlag,
-                                  0,
                                   kAdopt_GrWrapOwnership);
 
     REPORTER_ASSERT(reporter, tex);
@@ -130,55 +118,49 @@
     const GrVkImageInfo* imageInfo = reinterpret_cast<const GrVkImageInfo*>(backendObj);
 
     GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo);
-    sk_sp<GrTexture> tex = gpu->wrapBackendTexture(backendTex,
-                                                   kTopLeft_GrSurfaceOrigin,
-                                                   kRenderTarget_GrBackendTextureFlag,
-                                                   0,
-                                                   kBorrow_GrWrapOwnership);
+    sk_sp<GrTexture> tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                                             kTopLeft_GrSurfaceOrigin,
+                                                             0,
+                                                             kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, tex);
 
     // image is null
     GrVkImageInfo backendCopy = *imageInfo;
     backendCopy.fImage = VK_NULL_HANDLE;
     backendTex = GrBackendTexture(kW, kH, backendCopy);
-    tex = gpu->wrapBackendTexture(backendTex,
-                                  kTopLeft_GrSurfaceOrigin,
-                                  kRenderTarget_GrBackendTextureFlag,
-                                  0,
-                                  kBorrow_GrWrapOwnership);
+    tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                            kTopLeft_GrSurfaceOrigin,
+                                            0,
+                                            kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
-    tex = gpu->wrapBackendTexture(backendTex,
-                                  kTopLeft_GrSurfaceOrigin,
-                                  kRenderTarget_GrBackendTextureFlag,
-                                  0,
-                                  kAdopt_GrWrapOwnership);
+    tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                            kTopLeft_GrSurfaceOrigin,
+                                            0,
+                                            kAdopt_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
 
     // alloc is null
     backendCopy.fImage = imageInfo->fImage;
     backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
     backendTex = GrBackendTexture(kW, kH, backendCopy);
-    tex = gpu->wrapBackendTexture(backendTex,
-                                  kTopLeft_GrSurfaceOrigin,
-                                  kRenderTarget_GrBackendTextureFlag,
-                                  0,
-                                  kBorrow_GrWrapOwnership);
+    tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                            kTopLeft_GrSurfaceOrigin,
+                                            0,
+                                            kBorrow_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
-    tex = gpu->wrapBackendTexture(backendTex,
-                                  kTopLeft_GrSurfaceOrigin,
-                                  kRenderTarget_GrBackendTextureFlag,
-                                  0,
-                                  kAdopt_GrWrapOwnership);
+    tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                            kTopLeft_GrSurfaceOrigin,
+                                            0,
+                                            kAdopt_GrWrapOwnership);
     REPORTER_ASSERT(reporter, !tex);
 
     // check adopt creation
     backendCopy.fAlloc = imageInfo->fAlloc;
     backendTex = GrBackendTexture(kW, kH, backendCopy);
-    tex = gpu->wrapBackendTexture(backendTex,
-                                  kTopLeft_GrSurfaceOrigin,
-                                  kRenderTarget_GrBackendTextureFlag,
-                                  0,
-                                  kAdopt_GrWrapOwnership);
+    tex = gpu->wrapRenderableBackendTexture(backendTex,
+                                            kTopLeft_GrSurfaceOrigin,
+                                            0,
+                                            kAdopt_GrWrapOwnership);
     REPORTER_ASSERT(reporter, tex);
 
     gpu->deleteTestingOnlyBackendTexture(backendObj, true);
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 3aec3e6..e876c8f 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -13,8 +13,10 @@
 #include "sk_tool_utils.h"
 
 #if SK_SUPPORT_GPU
+#include "GrBackendSurface.h"
 #include "GrContext.h"
 #include "GrGpu.h"
+#include "GrTest.h"
 #endif
 
 #include <initializer_list>
@@ -429,26 +431,21 @@
 
     for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
         for (int sampleCnt : {0, 4}) {
-            GrBackendTextureDesc desc;
-            desc.fConfig = kSkia8888_GrPixelConfig;
-            desc.fWidth = DEV_W;
-            desc.fHeight = DEV_H;
-            desc.fFlags = kRenderTarget_GrBackendTextureFlag;
-            desc.fSampleCnt = sampleCnt;
-            desc.fOrigin = origin;
-            desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
-                nullptr, DEV_W, DEV_H, kSkia8888_GrPixelConfig, true);
-            sk_sp<SkSurface> surface(SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc,
-                                                                                     nullptr));
+            auto handle = context->getGpu()->createTestingOnlyBackendTexture(
+                    nullptr, DEV_W, DEV_H, kSkia8888_GrPixelConfig, true);
+            GrBackendTexture backendTexture = GrTest::CreateBackendTexture(
+                    ctxInfo.backend(), DEV_W, DEV_H, kSkia8888_GrPixelConfig, handle);
+            sk_sp<SkSurface> surface(SkSurface::MakeFromBackendTextureAsRenderTarget(
+                    context, backendTexture, origin, sampleCnt, nullptr, nullptr));
             if (!surface) {
-                context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
+                context->getGpu()->deleteTestingOnlyBackendTexture(handle);
                 continue;
             }
 
             test_write_pixels(reporter, surface.get());
 
             surface.reset();
-            context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
+            context->getGpu()->deleteTestingOnlyBackendTexture(handle);
         }
     }
 }
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index e867241..c5af01e 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -30,6 +30,7 @@
 #include "text/GrTextBlobCache.h"
 
 namespace GrTest {
+
 void SetupAlwaysEvictAtlas(GrContext* context) {
     // These sizes were selected because they allow each atlas to hold a single plot and will thus
     // stress the atlas
@@ -61,17 +62,27 @@
 
 GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
                                       GrPixelConfig config, GrBackendObject handle) {
+    switch (backend) {
 #ifdef SK_VULKAN
-    if (kVulkan_GrBackend == backend) {
-        GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
-        return GrBackendTexture(width, height, *vkInfo);
-    }
+        case kVulkan_GrBackend: {
+            GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
+            return GrBackendTexture(width, height, *vkInfo);
+        }
 #endif
-    SkASSERT(kOpenGL_GrBackend == backend);
-    GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
-    return GrBackendTexture(width, height, config, *glInfo);
+        case kOpenGL_GrBackend: {
+            GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
+            return GrBackendTexture(width, height, config, *glInfo);
+        }
+        case kMock_GrBackend: {
+            GrMockTextureInfo* mockInfo = (GrMockTextureInfo*)(handle);
+            return GrBackendTexture(width, height, config, *mockInfo);
+        }
+        default:
+            return GrBackendTexture();
+    }
 }
-};
+
+}  // namespace GrTest
 
 bool GrSurfaceProxy::isWrapped_ForTesting() const {
     return SkToBool(fTarget);