Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 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 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 10 | #include "GrContext.h" |
| 11 | #include "GrContextPriv.h" |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 12 | #include "GrGpu.h" |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 13 | #include "GrMemoryPool.h" |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 14 | #include "GrOpFlushState.h" |
| 15 | |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 16 | class GrWaitSemaphoreOp final : public GrSemaphoreOp { |
| 17 | public: |
| 18 | DEFINE_OP_CLASS_ID |
| 19 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 20 | static std::unique_ptr<GrOp> Make(GrContext* context, |
| 21 | sk_sp<GrSemaphore> semaphore, |
| 22 | GrRenderTargetProxy* proxy) { |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 23 | GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); |
| 24 | |
| 25 | return pool->allocate<GrWaitSemaphoreOp>(std::move(semaphore), proxy); |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | const char* name() const override { return "WaitSemaphore"; } |
| 29 | |
| 30 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 31 | friend class GrOpMemoryPool; // for ctor |
| 32 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 33 | explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy) |
| 34 | : INHERITED(ClassID(), std::move(semaphore), proxy) {} |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 35 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 36 | void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override { |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 37 | state->gpu()->waitSemaphore(fSemaphore); |
| 38 | } |
| 39 | |
| 40 | typedef GrSemaphoreOp INHERITED; |
| 41 | }; |
| 42 | |
| 43 | //////////////////////////////////////////////////////////////////////////////// |
| 44 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 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); |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | |