• 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 GrSemaphore_DEFINED
9 #define GrSemaphore_DEFINED
10 
11 #include "SkRefCnt.h"
12 
13 class GrBackendSemaphore;
14 class GrGpu;
15 
16 class GrSemaphore : public SkRefCnt {
17 private:
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.
resetGpu(const GrGpu * gpu)22     void resetGpu(const GrGpu* gpu) { fGpu = gpu; }
23 
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 
29 protected:
GrSemaphore(const GrGpu * gpu)30     explicit GrSemaphore(const GrGpu* gpu) : fGpu(gpu) {}
31 
32     friend class GrRenderTargetContext; // setBackendSemaphore
33     friend class GrResourceProvider; // resetGpu
34 
35     const GrGpu* fGpu;
36 };
37 
38 #endif
39