• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
Make(const GrGLGpu * gpu,bool isOwned)19     static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu, bool isOwned) {
20         return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
21     }
22 
MakeWrapped(const GrGLGpu * gpu,GrGLsync sync,GrWrapOwnership ownership)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 
sync()34     GrGLsync sync() const { return fSync; }
setSync(const GrGLsync & sync)35     void setSync(const GrGLsync& sync) { fSync = sync; }
36 
37 private:
38     GrGLSemaphore(const GrGLGpu* gpu, bool isOwned);
39 
setBackendSemaphore(GrBackendSemaphore * backendSemaphore)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