Some GrSemaphore cleanup

Remove unused GrResourceProvider functions that transfer context
ownership.

Return GrBackendSemaphore by value, make method public.

Change-Id: I1fe83b661cab82a54dde33b4b649579ea01be97c
Reviewed-on: https://skia-review.googlesource.com/150363
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index ca07496..70ec772 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -348,7 +348,7 @@
             this->insertSemaphore(semaphore, false);
 
             if (!backendSemaphores[i].isInitialized()) {
-                semaphore->setBackendSemaphore(&backendSemaphores[i]);
+                backendSemaphores[i] = semaphore->backendSemaphore();
             }
         }
     }
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 11843b3..12bc5ab 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -444,11 +444,3 @@
                                                                       wrapType,
                                                                       ownership);
 }
-
-void GrResourceProvider::takeOwnershipOfSemaphore(sk_sp<GrSemaphore> semaphore) {
-    semaphore->resetGpu(fGpu);
-}
-
-void GrResourceProvider::releaseOwnershipOfSemaphore(sk_sp<GrSemaphore> semaphore) {
-    semaphore->resetGpu(nullptr);
-}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 347a5de..d1c6aa3 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -237,15 +237,6 @@
                                             SemaphoreWrapType wrapType,
                                             GrWrapOwnership = kBorrow_GrWrapOwnership);
 
-    // Takes the GrSemaphore and sets the ownership of the semaphore to the GrGpu object used by
-    // this class. This call is only used when passing a GrSemaphore from one context to another.
-    void takeOwnershipOfSemaphore(sk_sp<GrSemaphore>);
-    // Takes the GrSemaphore and resets the ownership of the semaphore so that it is not owned by
-    // any GrGpu. A follow up call to takeOwnershipofSemaphore must be made so that the underlying
-    // semaphore can be deleted. This call is only used when passing a GrSemaphore from one context
-    // to another.
-    void releaseOwnershipOfSemaphore(sk_sp<GrSemaphore>);
-
     void abandon() {
         fCache = nullptr;
         fGpu = nullptr;
diff --git a/src/gpu/GrSemaphore.h b/src/gpu/GrSemaphore.h
index fbc5a6d..bdaf805 100644
--- a/src/gpu/GrSemaphore.h
+++ b/src/gpu/GrSemaphore.h
@@ -8,31 +8,21 @@
 #ifndef GrSemaphore_DEFINED
 #define GrSemaphore_DEFINED
 
+#include "GrBackendSemaphore.h"
 #include "SkRefCnt.h"
 
-class GrBackendSemaphore;
 class GrGpu;
 
 class GrSemaphore : public SkRefCnt {
-private:
-    // This function should only be used in the case of exporting and importing a GrSemaphore object
-    // from one GrContext to another. When exporting, the GrSemaphore should be set to a null GrGpu,
-    // and when importing it should be set to the GrGpu of the current context. Once exported, a
-    // GrSemaphore should not be used with its old context.
-    void resetGpu(const GrGpu* gpu) { fGpu = gpu; }
-
-    // The derived class will init the GrBackendSemaphore. This is used when flushing with signal
-    // semaphores so we can set the clients GrBackendSemaphore object after we've created the
+public:
+    // The derived class can return its GrBackendSemaphore. This is used when flushing with signal
+    // semaphores so we can set the client's GrBackendSemaphore object after we've created the
     // internal semaphore.
-    virtual void setBackendSemaphore(GrBackendSemaphore*) const = 0;
+    virtual GrBackendSemaphore backendSemaphore() const = 0;
 
 protected:
     explicit GrSemaphore(const GrGpu* gpu) : fGpu(gpu) {}
 
-    friend class GrGpu; // setBackendSemaphore
-    friend class GrRenderTargetContext; // setBackendSemaphore
-    friend class GrResourceProvider; // resetGpu
-
     const GrGpu* fGpu;
 };
 
diff --git a/src/gpu/gl/GrGLSemaphore.h b/src/gpu/gl/GrGLSemaphore.h
index b48ce78..6fd1a6f 100644
--- a/src/gpu/gl/GrGLSemaphore.h
+++ b/src/gpu/gl/GrGLSemaphore.h
@@ -34,12 +34,15 @@
     GrGLsync sync() const { return fSync; }
     void setSync(const GrGLsync& sync) { fSync = sync; }
 
+    GrBackendSemaphore backendSemaphore() const override {
+        GrBackendSemaphore backendSemaphore;
+        backendSemaphore.initGL(fSync);
+        return backendSemaphore;
+    }
+
 private:
     GrGLSemaphore(const GrGLGpu* gpu, bool isOwned);
 
-    void setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const override {
-        backendSemaphore->initGL(fSync);
-    }
 
     GrGLsync fSync;
     bool     fIsOwned;
diff --git a/src/gpu/vk/GrVkSemaphore.cpp b/src/gpu/vk/GrVkSemaphore.cpp
index c794f7a..7a56391 100644
--- a/src/gpu/vk/GrVkSemaphore.cpp
+++ b/src/gpu/vk/GrVkSemaphore.cpp
@@ -63,7 +63,8 @@
     }
 }
 
-void GrVkSemaphore::setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const {
-    backendSemaphore->initVulkan(fResource->semaphore());
+GrBackendSemaphore GrVkSemaphore::backendSemaphore() const {
+    GrBackendSemaphore backendSemaphore;
+    backendSemaphore.initVulkan(fResource->semaphore());
+    return backendSemaphore;
 }
-
diff --git a/src/gpu/vk/GrVkSemaphore.h b/src/gpu/vk/GrVkSemaphore.h
index 8f39e17..58e5080 100644
--- a/src/gpu/vk/GrVkSemaphore.h
+++ b/src/gpu/vk/GrVkSemaphore.h
@@ -31,6 +31,8 @@
 
     ~GrVkSemaphore() override;
 
+    GrBackendSemaphore backendSemaphore() const override;
+
     class Resource : public GrVkResource {
     public:
         Resource(VkSemaphore semaphore, bool prohibitSignal, bool prohibitWait, bool isOwned)
@@ -90,8 +92,6 @@
     GrVkSemaphore(const GrVkGpu* gpu, VkSemaphore semaphore, bool prohibitSignal, bool prohibitWait,
                   bool isOwned);
 
-    void setBackendSemaphore(GrBackendSemaphore*) const override;
-
     Resource* fResource;
 
     typedef GrSemaphore INHERITED;