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/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,