blob: a6c9ac721489c8e0c630c6dee5307efce4049d00 [file] [log] [blame]
Greg Danielfe71b9d2017-03-09 10:41:31 -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#include "GrSemaphoreOp.h"
9
10#include "GrGpu.h"
11#include "GrOpFlushState.h"
12
13class GrSignalSemaphoreOp final : public GrSemaphoreOp {
14public:
15 DEFINE_OP_CLASS_ID
16
Greg Daniela5cb7812017-06-16 09:45:32 -040017 static std::unique_ptr<GrSignalSemaphoreOp> Make(sk_sp<GrSemaphore> semaphore,
Greg Daniela2cebd82017-06-21 16:09:50 -040018 GrRenderTargetProxy* proxy,
19 bool forceFlush) {
Greg Daniela5cb7812017-06-16 09:45:32 -040020 return std::unique_ptr<GrSignalSemaphoreOp>(new GrSignalSemaphoreOp(std::move(semaphore),
Greg Daniela2cebd82017-06-21 16:09:50 -040021 proxy,
22 forceFlush));
Greg Danielfe71b9d2017-03-09 10:41:31 -050023 }
24
25 const char* name() const override { return "SignalSemaphore"; }
26
27private:
Greg Daniela2cebd82017-06-21 16:09:50 -040028 explicit GrSignalSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy,
29 bool forceFlush)
30 : INHERITED(ClassID(), std::move(semaphore), proxy), fForceFlush(forceFlush) {}
Greg Danielfe71b9d2017-03-09 10:41:31 -050031
32 void onExecute(GrOpFlushState* state) override {
Greg Daniela2cebd82017-06-21 16:09:50 -040033 state->gpu()->insertSemaphore(fSemaphore, fForceFlush);
Greg Danielfe71b9d2017-03-09 10:41:31 -050034 }
35
Greg Daniela2cebd82017-06-21 16:09:50 -040036 bool fForceFlush;
37
Greg Danielfe71b9d2017-03-09 10:41:31 -050038 typedef GrSemaphoreOp INHERITED;
39};
40
41class GrWaitSemaphoreOp final : public GrSemaphoreOp {
42public:
43 DEFINE_OP_CLASS_ID
44
Greg Daniela5cb7812017-06-16 09:45:32 -040045 static std::unique_ptr<GrWaitSemaphoreOp> Make(sk_sp<GrSemaphore> semaphore,
46 GrRenderTargetProxy* proxy) {
47 return std::unique_ptr<GrWaitSemaphoreOp>(new GrWaitSemaphoreOp(std::move(semaphore),
48 proxy));
Greg Danielfe71b9d2017-03-09 10:41:31 -050049 }
50
51 const char* name() const override { return "WaitSemaphore"; }
52
53private:
Greg Daniela5cb7812017-06-16 09:45:32 -040054 explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
55 : INHERITED(ClassID(), std::move(semaphore), proxy) {}
Greg Danielfe71b9d2017-03-09 10:41:31 -050056
57 void onExecute(GrOpFlushState* state) override {
58 state->gpu()->waitSemaphore(fSemaphore);
59 }
60
61 typedef GrSemaphoreOp INHERITED;
62};
63
64////////////////////////////////////////////////////////////////////////////////
65
Greg Daniela5cb7812017-06-16 09:45:32 -040066std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeSignal(sk_sp<GrSemaphore> semaphore,
Greg Daniela2cebd82017-06-21 16:09:50 -040067 GrRenderTargetProxy* proxy,
68 bool forceFlush) {
69 return GrSignalSemaphoreOp::Make(std::move(semaphore), proxy, forceFlush);
Greg Danielfe71b9d2017-03-09 10:41:31 -050070}
71
Greg Daniela5cb7812017-06-16 09:45:32 -040072std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeWait(sk_sp<GrSemaphore> semaphore,
73 GrRenderTargetProxy* proxy) {
74 return GrWaitSemaphoreOp::Make(std::move(semaphore), proxy);
Greg Danielfe71b9d2017-03-09 10:41:31 -050075}
76
77