• 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 #include "GrSemaphoreOp.h"
9 
10 #include "GrGpu.h"
11 #include "GrOpFlushState.h"
12 
13 class GrSignalSemaphoreOp final : public GrSemaphoreOp {
14 public:
15     DEFINE_OP_CLASS_ID
16 
Make(sk_sp<GrSemaphore> semaphore)17     static std::unique_ptr<GrSignalSemaphoreOp> Make(sk_sp<GrSemaphore> semaphore) {
18         return std::unique_ptr<GrSignalSemaphoreOp>(new GrSignalSemaphoreOp(std::move(semaphore)));
19     }
20 
name() const21     const char* name() const override { return "SignalSemaphore"; }
22 
23 private:
GrSignalSemaphoreOp(sk_sp<GrSemaphore> semaphore)24     explicit GrSignalSemaphoreOp(sk_sp<GrSemaphore> semaphore)
25             : INHERITED(ClassID(), std::move(semaphore)) {}
26 
onExecute(GrOpFlushState * state)27     void onExecute(GrOpFlushState* state) override {
28         state->gpu()->insertSemaphore(fSemaphore);
29     }
30 
31     typedef GrSemaphoreOp INHERITED;
32 };
33 
34 class GrWaitSemaphoreOp final : public GrSemaphoreOp {
35 public:
36     DEFINE_OP_CLASS_ID
37 
Make(sk_sp<GrSemaphore> semaphore)38     static std::unique_ptr<GrWaitSemaphoreOp> Make(sk_sp<GrSemaphore> semaphore) {
39         return std::unique_ptr<GrWaitSemaphoreOp>(new GrWaitSemaphoreOp(std::move(semaphore)));
40     }
41 
name() const42     const char* name() const override { return "WaitSemaphore"; }
43 
44 private:
GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore)45     explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore)
46             : INHERITED(ClassID(), std::move(semaphore)) {}
47 
onExecute(GrOpFlushState * state)48     void onExecute(GrOpFlushState* state) override {
49         state->gpu()->waitSemaphore(fSemaphore);
50     }
51 
52     typedef GrSemaphoreOp INHERITED;
53 };
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 
MakeSignal(sk_sp<GrSemaphore> semaphore)57 std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeSignal(sk_sp<GrSemaphore> semaphore) {
58     return GrSignalSemaphoreOp::Make(std::move(semaphore));
59 }
60 
MakeWait(sk_sp<GrSemaphore> semaphore)61 std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeWait(sk_sp<GrSemaphore> semaphore) {
62     return GrWaitSemaphoreOp::Make(std::move(semaphore));
63 }
64 
65 
66