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 GrSemaphore_DEFINED |
| 9 | #define GrSemaphore_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrBackendSemaphore.h" |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 12 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 13 | /** |
Mike Klein | cd2f0b6 | 2020-08-25 11:11:59 -0500 | [diff] [blame] | 14 | * Represents a semaphore-like GPU synchronization object. |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 15 | */ |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 16 | class GrSemaphore { |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 17 | public: |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 18 | virtual ~GrSemaphore() {} |
| 19 | |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 20 | // The derived class can return its GrBackendSemaphore. This is used when flushing with signal |
| 21 | // semaphores so we can set the client's GrBackendSemaphore object after we've created the |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 22 | // internal semaphore. |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 23 | virtual GrBackendSemaphore backendSemaphore() const = 0; |
Greg Daniel | 30a35e8 | 2019-11-19 14:12:25 -0500 | [diff] [blame] | 24 | |
| 25 | private: |
| 26 | friend class GrGpu; // for setIsOwned |
| 27 | // This is only used in GrGpu to handle the case where we created a semaphore that was meant to |
| 28 | // be borrowed, but we failed to submit it. So we must go back and switch the semaphore to owned |
| 29 | // so that it gets deleted. |
| 30 | virtual void setIsOwned() = 0; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | #endif |