blob: f6148b015a118416c64cbfdb9785b1452d8b39e6 [file] [log] [blame]
Greg Daniel6be35232017-03-01 17:01:09 -05001/*
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 Daniela5cb7812017-06-16 09:45:32 -040013class GrBackendSemaphore;
Greg Daniel6be35232017-03-01 17:01:09 -050014class GrGpu;
15
16class GrSemaphore : public SkRefCnt {
Brian Osmanfe3b5162017-03-02 15:09:20 -050017private:
Greg Daniel6be35232017-03-01 17:01:09 -050018 // 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 Daniela5cb7812017-06-16 09:45:32 -040024 // 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 Daniel6be35232017-03-01 17:01:09 -050029protected:
30 explicit GrSemaphore(const GrGpu* gpu) : fGpu(gpu) {}
31
Greg Daniela5cb7812017-06-16 09:45:32 -040032 friend class GrRenderTargetContext; // setBackendSemaphore
Greg Danield85f97d2017-03-07 13:37:21 -050033 friend class GrResourceProvider; // resetGpu
Brian Osmanfe3b5162017-03-02 15:09:20 -050034
Greg Daniel6be35232017-03-01 17:01:09 -050035 const GrGpu* fGpu;
36};
37
38#endif