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 | |
| 11 | #include "SkRefCnt.h" |
| 12 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 13 | class GrBackendSemaphore; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 14 | class GrGpu; |
| 15 | |
| 16 | class GrSemaphore : public SkRefCnt { |
Brian Osman | fe3b516 | 2017-03-02 15:09:20 -0500 | [diff] [blame] | 17 | private: |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 18 | // This function should only be used in the case of exporting and importing a GrSemaphore object |
| 19 | // from one GrContext to another. When exporting, the GrSemaphore should be set to a null GrGpu, |
| 20 | // and when importing it should be set to the GrGpu of the current context. Once exported, a |
| 21 | // GrSemaphore should not be used with its old context. |
| 22 | void resetGpu(const GrGpu* gpu) { fGpu = gpu; } |
| 23 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 24 | // The derived class will init the GrBackendSemaphore. This is used when flushing with signal |
| 25 | // semaphores so we can set the clients GrBackendSemaphore object after we've created the |
| 26 | // internal semaphore. |
| 27 | virtual void setBackendSemaphore(GrBackendSemaphore*) const = 0; |
| 28 | |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 29 | protected: |
| 30 | explicit GrSemaphore(const GrGpu* gpu) : fGpu(gpu) {} |
| 31 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 32 | friend class GrRenderTargetContext; // setBackendSemaphore |
Greg Daniel | d85f97d | 2017-03-07 13:37:21 -0500 | [diff] [blame] | 33 | friend class GrResourceProvider; // resetGpu |
Brian Osman | fe3b516 | 2017-03-02 15:09:20 -0500 | [diff] [blame] | 34 | |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 35 | const GrGpu* fGpu; |
| 36 | }; |
| 37 | |
| 38 | #endif |