• 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,GrRenderTargetProxy * proxy,bool forceFlush)17     static std::unique_ptr<GrSignalSemaphoreOp> Make(sk_sp<GrSemaphore> semaphore,
18                                                      GrRenderTargetProxy* proxy,
19                                                      bool forceFlush) {
20         return std::unique_ptr<GrSignalSemaphoreOp>(new GrSignalSemaphoreOp(std::move(semaphore),
21                                                                             proxy,
22                                                                             forceFlush));
23     }
24 
name() const25     const char* name() const override { return "SignalSemaphore"; }
26 
27 private:
GrSignalSemaphoreOp(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy,bool forceFlush)28     explicit GrSignalSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy,
29                                  bool forceFlush)
30             : INHERITED(ClassID(), std::move(semaphore), proxy), fForceFlush(forceFlush) {}
31 
onExecute(GrOpFlushState * state)32     void onExecute(GrOpFlushState* state) override {
33         state->gpu()->insertSemaphore(fSemaphore, fForceFlush);
34     }
35 
36     bool fForceFlush;
37 
38     typedef GrSemaphoreOp INHERITED;
39 };
40 
41 class GrWaitSemaphoreOp final : public GrSemaphoreOp {
42 public:
43     DEFINE_OP_CLASS_ID
44 
Make(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)45     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));
49     }
50 
name() const51     const char* name() const override { return "WaitSemaphore"; }
52 
53 private:
GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)54     explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
55             : INHERITED(ClassID(), std::move(semaphore), proxy) {}
56 
onExecute(GrOpFlushState * state)57     void onExecute(GrOpFlushState* state) override {
58         state->gpu()->waitSemaphore(fSemaphore);
59     }
60 
61     typedef GrSemaphoreOp INHERITED;
62 };
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 
MakeSignal(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy,bool forceFlush)66 std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeSignal(sk_sp<GrSemaphore> semaphore,
67                                                          GrRenderTargetProxy* proxy,
68                                                          bool forceFlush) {
69     return GrSignalSemaphoreOp::Make(std::move(semaphore), proxy, forceFlush);
70 }
71 
MakeWait(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)72 std::unique_ptr<GrSemaphoreOp> GrSemaphoreOp::MakeWait(sk_sp<GrSemaphore> semaphore,
73                                                        GrRenderTargetProxy* proxy) {
74     return GrWaitSemaphoreOp::Make(std::move(semaphore), proxy);
75 }
76 
77 
78