Remove ownership parameter from GrResourceProvider::wrapBackendTextureAsRenderTarget

Remove ownership parameter from
GrResourceProvider::wrapBackendTextureAsRenderTarget.
The function leaks the texture id if kAdopt_LifeCycle is passed.

There is no public API to access the parameter.

BUG=594928
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842313003

Review URL: https://codereview.chromium.org/1842313003
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 4f99ab8..9605266 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -220,8 +220,7 @@
     return this->onWrapBackendRenderTarget(desc, ownership);
 }
 
-GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
-                                                        GrWrapOwnership ownership) {
+GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
     this->handleDirtyContext();
     if (!(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
       return nullptr;
@@ -233,7 +232,7 @@
     if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
         return nullptr;
     }
-    return this->onWrapBackendTextureAsRenderTarget(desc, ownership);
+    return this->onWrapBackendTextureAsRenderTarget(desc);
 }
 
 GrBuffer* GrGpu::createBuffer(GrBufferType type, size_t size, GrAccessPattern accessPattern) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 8562d1e..0da1aa6 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -124,7 +124,7 @@
     /**
      * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget
      */
-    GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&, GrWrapOwnership);
+    GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&);
 
     /**
      * Creates a buffer.
@@ -526,8 +526,7 @@
     virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0;
     virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
                                                       GrWrapOwnership) = 0;
-    virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
-                                                               GrWrapOwnership) = 0;
+    virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) = 0;
     virtual GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) = 0;
 
     // overridden by backend-specific derived class to perform the clear.
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 7f6a7f1..238276d 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -186,9 +186,9 @@
 }
 
 GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget(
-        const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
+        const GrBackendTextureDesc& desc) {
     if (this->isAbandoned()) {
         return nullptr;
     }
-    return this->gpu()->wrapBackendTextureAsRenderTarget(desc, ownership);
+    return this->gpu()->wrapBackendTextureAsRenderTarget(desc);
 }
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 7b51726..fe0b5de 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -140,10 +140,12 @@
       * Wraps an existing texture with a GrRenderTarget object. This is useful when the provided
       * texture has a format that cannot be textured from by Skia, but we want to raster to it.
       *
+      * The texture is wrapped as borrowed. The texture object will not be freed once the
+      * render target is destroyed.
+      *
       * @return GrRenderTarget object or NULL on failure.
       */
-     GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
-                                                      GrWrapOwnership = kBorrow_GrWrapOwnership);
+     GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc);
 
 private:
     const GrBuffer* createInstancedIndexBuffer(const uint16_t* pattern,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 43df735..34223f1 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -661,8 +661,7 @@
     return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
 }
 
-GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
-                                                            GrWrapOwnership ownership) {
+GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
     if (!desc.fTextureHandle) {
         return nullptr;
@@ -674,34 +673,25 @@
     }
 #endif
 
-    GrGLTexture::IDDesc idDesc;
+    GrGLTextureInfo texInfo;
     GrSurfaceDesc surfDesc;
 
 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
-    idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
+    texInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
     // We only support GL_TEXTURE_2D at the moment.
-    idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
+    texInfo.fTarget = GR_GL_TEXTURE_2D;
 #else
-    idDesc.fInfo = *info;
+    texInfo = *info;
 #endif
 
-    if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget &&
-        GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) {
+    if (GR_GL_TEXTURE_RECTANGLE != texInfo.fTarget &&
+        GR_GL_TEXTURE_2D != texInfo.fTarget) {
         // Only texture rectangle and texture 2d are supported. We do not check whether texture
         // rectangle is supported by Skia - if the caller provided us with a texture rectangle,
         // we assume the necessary support exists.
         return nullptr;
     }
 
-    switch (ownership) {
-        case kAdopt_GrWrapOwnership:
-            idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
-            break;
-        case kBorrow_GrWrapOwnership:
-            idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle;
-            break;
-    }
-
     surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags;
     surfDesc.fWidth = desc.fWidth;
     surfDesc.fHeight = desc.fHeight;
@@ -719,7 +709,7 @@
 
     GrGLRenderTarget::IDDesc rtIDDesc;
     if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_LifeCycle,
-                                         idDesc.fInfo, &rtIDDesc)) {
+                                         texInfo, &rtIDDesc)) {
         return nullptr;
     }
     return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0);
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 4a70fb7..6d851ee 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -142,8 +142,7 @@
     GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
     GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
                                               GrWrapOwnership) override;
-    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
-                                                       GrWrapOwnership) override;
+    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
     // Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a
     // compatible stencil format, or negative if there is no compatible stencil format.
     int getCompatibleStencilIndex(GrPixelConfig config);
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 99c03bd..001e12c 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -129,8 +129,7 @@
 
     GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
                                               GrWrapOwnership) override;
-    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
-                                                       GrWrapOwnership) override { return NULL; }
+    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override { return NULL; }
 
     GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) override;
 
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 2b6463d..818bf64 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -340,8 +340,7 @@
         return nullptr;
     }
 
-    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
-                                                       GrWrapOwnership) override {
+    GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
         return nullptr;
     }