• 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 "include/gpu/GrBackendSemaphore.h"
12 #include "include/private/GrTypesPriv.h"
13 #include "src/gpu/GrSemaphore.h"
14 
15 class GrGLGpu;
16 
17 class GrGLSemaphore : public GrSemaphore {
18 public:
Make(GrGLGpu * gpu,bool isOwned)19     static std::unique_ptr<GrGLSemaphore> Make(GrGLGpu* gpu, bool isOwned) {
20         return std::unique_ptr<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
21     }
22 
MakeWrapped(GrGLGpu * gpu,GrGLsync sync,GrWrapOwnership ownership)23     static std::unique_ptr<GrGLSemaphore> MakeWrapped(GrGLGpu* gpu,
24                                                       GrGLsync sync,
25                                                       GrWrapOwnership ownership) {
26         auto sema = std::unique_ptr<GrGLSemaphore>(
27                 new GrGLSemaphore(gpu, 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 
backendSemaphore()37     GrBackendSemaphore backendSemaphore() const override {
38         GrBackendSemaphore backendSemaphore;
39         backendSemaphore.initGL(fSync);
40         return backendSemaphore;
41     }
42 
43 private:
44     GrGLSemaphore(GrGLGpu* gpu, bool isOwned);
45 
setIsOwned()46     void setIsOwned() override {
47         fIsOwned = true;
48     }
49 
50     GrGLGpu* fGpu;
51     GrGLsync fSync;
52     bool     fIsOwned;
53 
54     using INHERITED = GrSemaphore;
55 };
56 
57 #endif
58