blob: 77e5b79d4ea1b89ddc5175e6148502111e9afd5b [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrBackendSemaphore.h"
12#include "include/gpu/GrGpuResource.h"
Greg Daniel6be35232017-03-01 17:01:09 -050013
Brian Salomon62db8d52018-08-30 10:37:47 -040014/**
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 */
Greg Daniel301015c2019-11-18 14:06:46 -050021class GrSemaphore {
Brian Salomon1e576e72018-08-30 10:20:38 -040022public:
Greg Daniel301015c2019-11-18 14:06:46 -050023 virtual ~GrSemaphore() {}
24
Brian Salomon1e576e72018-08-30 10:20:38 -040025 // The derived class can return its GrBackendSemaphore. This is used when flushing with signal
26 // semaphores so we can set the client's GrBackendSemaphore object after we've created the
Greg Daniela5cb7812017-06-16 09:45:32 -040027 // internal semaphore.
Brian Salomon1e576e72018-08-30 10:20:38 -040028 virtual GrBackendSemaphore backendSemaphore() const = 0;
Greg Daniel30a35e82019-11-19 14:12:25 -050029
30private:
31 friend class GrGpu; // for setIsOwned
32 // This is only used in GrGpu to handle the case where we created a semaphore that was meant to
33 // be borrowed, but we failed to submit it. So we must go back and switch the semaphore to owned
34 // so that it gets deleted.
35 virtual void setIsOwned() = 0;
Greg Daniel6be35232017-03-01 17:01:09 -050036};
37
38#endif