Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 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 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 13 | #include "GrBackendSemaphore.h" |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 14 | |
| 15 | class GrGLGpu; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 16 | |
| 17 | class GrGLSemaphore : public GrSemaphore { |
| 18 | public: |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 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; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 30 | } |
| 31 | |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 32 | ~GrGLSemaphore() override; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 33 | |
| 34 | GrGLsync sync() const { return fSync; } |
| 35 | void setSync(const GrGLsync& sync) { fSync = sync; } |
| 36 | |
| 37 | private: |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 38 | GrGLSemaphore(const GrGLGpu* gpu, bool isOwned); |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 39 | |
| 40 | void setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const override { |
| 41 | backendSemaphore->initGL(fSync); |
| 42 | } |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 43 | |
| 44 | GrGLsync fSync; |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 45 | bool fIsOwned; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 46 | |
| 47 | typedef GrSemaphore INHERITED; |
| 48 | }; |
| 49 | |
| 50 | #endif |