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