blob: ba05219357d68d7f87b095901f47f8d6ebc0593e [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 GrGLSemaphore_DEFINED
9#define GrGLSemaphore_DEFINED
10
11#include "GrSemaphore.h"
12
Greg Daniela5cb7812017-06-16 09:45:32 -040013#include "GrBackendSemaphore.h"
Greg Daniel6ecc9112017-06-16 16:17:03 +000014
15class GrGLGpu;
Greg Daniel6be35232017-03-01 17:01:09 -050016
17class GrGLSemaphore : public GrSemaphore {
18public:
Greg Daniela5cb7812017-06-16 09:45:32 -040019 static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu, bool isOwned) {
20 return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
21 }
22
23 static sk_sp<GrGLSemaphore> MakeWrapped(const GrGLGpu* gpu,
24 GrGLsync sync,
25 GrWrapOwnership ownership) {
26 auto sema = sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu,
27 kBorrow_GrWrapOwnership != ownership));
28 sema->setSync(sync);
29 return sema;
Greg Daniel6be35232017-03-01 17:01:09 -050030 }
31
Greg Daniel6ecc9112017-06-16 16:17:03 +000032 ~GrGLSemaphore() override;
Greg Daniel6be35232017-03-01 17:01:09 -050033
34 GrGLsync sync() const { return fSync; }
35 void setSync(const GrGLsync& sync) { fSync = sync; }
36
37private:
Greg Daniel6ecc9112017-06-16 16:17:03 +000038 GrGLSemaphore(const GrGLGpu* gpu, bool isOwned);
Greg Daniela5cb7812017-06-16 09:45:32 -040039
40 void setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const override {
41 backendSemaphore->initGL(fSync);
42 }
Greg Daniel6be35232017-03-01 17:01:09 -050043
44 GrGLsync fSync;
Greg Daniela5cb7812017-06-16 09:45:32 -040045 bool fIsOwned;
Greg Daniel6be35232017-03-01 17:01:09 -050046
47 typedef GrSemaphore INHERITED;
48};
49
50#endif