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 | |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 11 | #include "GrBackendSemaphore.h" |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 12 | #include "GrGpuResource.h" |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 13 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 14 | /** |
| 15 | * Represents a semaphore-like GPU synchronization object. This is a slightly odd fit for |
| 16 | * GrGpuResource because we don't care about budgeting, recycling, or read/write references for |
| 17 | * these. However, making it a GrGpuResource makes it simpler to handle releasing/abandoning these |
| 18 | * along with other resources. If more cases like this arise we could consider moving some of the |
| 19 | * unused functionality off of GrGpuResource. |
| 20 | */ |
| 21 | class GrSemaphore : public GrGpuResource { |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 22 | public: |
| 23 | // The derived class can return its GrBackendSemaphore. This is used when flushing with signal |
| 24 | // 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] | 25 | // internal semaphore. |
Brian Salomon | 1e576e7 | 2018-08-30 10:20:38 -0400 | [diff] [blame] | 26 | virtual GrBackendSemaphore backendSemaphore() const = 0; |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 27 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 28 | const char* getResourceType() const override { return "semaphore"; } |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 29 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame] | 30 | protected: |
| 31 | explicit GrSemaphore(GrGpu* gpu) : INHERITED(gpu) {} |
| 32 | |
| 33 | private: |
| 34 | size_t onGpuMemorySize() const override { return 0; } |
| 35 | |
| 36 | typedef GrGpuResource INHERITED; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | #endif |