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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/ops/GrSemaphoreOp.h" |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/private/GrRecordingContext.h" |
| 11 | #include "src/gpu/GrGpu.h" |
| 12 | #include "src/gpu/GrMemoryPool.h" |
| 13 | #include "src/gpu/GrOpFlushState.h" |
| 14 | #include "src/gpu/GrRecordingContextPriv.h" |
Greg Daniel | fe71b9d | 2017-03-09 10:41:31 -0500 | [diff] [blame] | 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 | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 20 | static std::unique_ptr<GrOp> Make(GrRecordingContext* context, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 21 | sk_sp<GrSemaphore> semaphore, |
| 22 | GrRenderTargetProxy* proxy) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 23 | GrOpMemoryPool* pool = context->priv().opMemoryPool(); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 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 | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 45 | std::unique_ptr<GrOp> GrSemaphoreOp::MakeWait(GrRecordingContext* context, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 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 | |