• 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 "GrContext.h"
11 #include "GrContextPriv.h"
12 #include "GrGpu.h"
13 #include "GrMemoryPool.h"
14 #include "GrOpFlushState.h"
15 
16 class GrWaitSemaphoreOp final : public GrSemaphoreOp {
17 public:
18     DEFINE_OP_CLASS_ID
19 
Make(GrContext * context,sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)20     static std::unique_ptr<GrOp> Make(GrContext* context,
21                                       sk_sp<GrSemaphore> semaphore,
22                                       GrRenderTargetProxy* proxy) {
23         GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
24 
25         return pool->allocate<GrWaitSemaphoreOp>(std::move(semaphore), proxy);
26     }
27 
name() const28     const char* name() const override { return "WaitSemaphore"; }
29 
30 private:
31     friend class GrOpMemoryPool; // for ctor
32 
GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)33     explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
34             : INHERITED(ClassID(), std::move(semaphore), proxy) {}
35 
onExecute(GrOpFlushState * state,const SkRect & chainBounds)36     void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {
37         state->gpu()->waitSemaphore(fSemaphore);
38     }
39 
40     typedef GrSemaphoreOp INHERITED;
41 };
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 
MakeWait(GrContext * context,sk_sp<GrSemaphore> semaphore,GrRenderTargetProxy * proxy)45 std::unique_ptr<GrOp> GrSemaphoreOp::MakeWait(GrContext* context,
46                                               sk_sp<GrSemaphore> semaphore,
47                                               GrRenderTargetProxy* proxy) {
48     return GrWaitSemaphoreOp::Make(context, std::move(semaphore), proxy);
49 }
50 
51 
52