blob: f20552023d86b924bccf3553d5333da4054556d2 [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"
Greg Daniel6be35232017-03-01 17:01:09 -050012
Brian Salomon62db8d52018-08-30 10:37:47 -040013/**
Mike Kleincd2f0b62020-08-25 11:11:59 -050014 * Represents a semaphore-like GPU synchronization object.
Brian Salomon62db8d52018-08-30 10:37:47 -040015 */
Greg Daniel301015c2019-11-18 14:06:46 -050016class GrSemaphore {
Brian Salomon1e576e72018-08-30 10:20:38 -040017public:
Greg Daniel301015c2019-11-18 14:06:46 -050018 virtual ~GrSemaphore() {}
19
Brian Salomon1e576e72018-08-30 10:20:38 -040020 // The derived class can return its GrBackendSemaphore. This is used when flushing with signal
21 // semaphores so we can set the client's GrBackendSemaphore object after we've created the
Greg Daniela5cb7812017-06-16 09:45:32 -040022 // internal semaphore.
Brian Salomon1e576e72018-08-30 10:20:38 -040023 virtual GrBackendSemaphore backendSemaphore() const = 0;
Greg Daniel30a35e82019-11-19 14:12:25 -050024
25private:
26 friend class GrGpu; // for setIsOwned
27 // This is only used in GrGpu to handle the case where we created a semaphore that was meant to
28 // be borrowed, but we failed to submit it. So we must go back and switch the semaphore to owned
29 // so that it gets deleted.
30 virtual void setIsOwned() = 0;
Greg Daniel6be35232017-03-01 17:01:09 -050031};
32
33#endif