Make GrSemaphore a GrGpuResource

This makes semaphores get handled correctly when GrContext is abandoned or
asked to free all its resources.

Change-Id: I0b935bb95cf99b9acf647472bcd0231bb2759db6
Reviewed-on: https://skia-review.googlesource.com/150364
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLSemaphore.h b/src/gpu/gl/GrGLSemaphore.h
index 6fd1a6f..851ae02 100644
--- a/src/gpu/gl/GrGLSemaphore.h
+++ b/src/gpu/gl/GrGLSemaphore.h
@@ -16,11 +16,11 @@
 
 class GrGLSemaphore : public GrSemaphore {
 public:
-    static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu, bool isOwned) {
+    static sk_sp<GrGLSemaphore> Make(GrGLGpu* gpu, bool isOwned) {
         return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
     }
 
-    static sk_sp<GrGLSemaphore> MakeWrapped(const GrGLGpu* gpu,
+    static sk_sp<GrGLSemaphore> MakeWrapped(GrGLGpu* gpu,
                                             GrGLsync sync,
                                             GrWrapOwnership ownership) {
         auto sema = sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu,
@@ -29,8 +29,6 @@
         return sema;
     }
 
-    ~GrGLSemaphore() override;
-
     GrGLsync sync() const { return fSync; }
     void setSync(const GrGLsync& sync) { fSync = sync; }
 
@@ -41,8 +39,10 @@
     }
 
 private:
-    GrGLSemaphore(const GrGLGpu* gpu, bool isOwned);
+    GrGLSemaphore(GrGLGpu* gpu, bool isOwned);
 
+    void onRelease() override;
+    void onAbandon() override;
 
     GrGLsync fSync;
     bool     fIsOwned;