Home | History | Annotate | Download | only in gl
      1 /*
      2  * Copyright 2017 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef GrGLSemaphore_DEFINED
      9 #define GrGLSemaphore_DEFINED
     10 
     11 #include "GrSemaphore.h"
     12 
     13 #include "GrBackendSemaphore.h"
     14 
     15 class GrGLGpu;
     16 
     17 class GrGLSemaphore : public GrSemaphore {
     18 public:
     19     static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu, bool isOwned) {
     20         return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
     21     }
     22 
     23     static sk_sp<GrGLSemaphore> MakeWrapped(const GrGLGpu* gpu,
     24                                             GrGLsync sync,
     25                                             GrWrapOwnership ownership) {
     26         auto sema = sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu,
     27                                                            kBorrow_GrWrapOwnership != ownership));
     28         sema->setSync(sync);
     29         return sema;
     30     }
     31 
     32     ~GrGLSemaphore() override;
     33 
     34     GrGLsync sync() const { return fSync; }
     35     void setSync(const GrGLsync& sync) { fSync = sync; }
     36 
     37 private:
     38     GrGLSemaphore(const GrGLGpu* gpu, bool isOwned);
     39 
     40     void setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const override {
     41         backendSemaphore->initGL(fSync);
     42     }
     43 
     44     GrGLsync fSync;
     45     bool     fIsOwned;
     46 
     47     typedef GrSemaphore INHERITED;
     48 };
     49 
     50 #endif
     51