| 1 | /* |
|---|---|
| 2 | * Copyright 2019 Google LLC |
| 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 | #ifndef GrWaitRenderTask_DEFINED |
| 9 | #define GrWaitRenderTask_DEFINED |
| 10 | |
| 11 | #include "src/gpu/GrRenderTask.h" |
| 12 | #include "src/gpu/GrSemaphore.h" |
| 13 | |
| 14 | class GrWaitRenderTask final : public GrRenderTask { |
| 15 | public: |
| 16 | GrWaitRenderTask(GrSurfaceProxyView surfaceView, |
| 17 | std::unique_ptr<std::unique_ptr<GrSemaphore>[]> semaphores, |
| 18 | int numSemaphores) |
| 19 | : GrRenderTask() |
| 20 | , fSemaphores(std::move(semaphores)) |
| 21 | , fNumSemaphores(numSemaphores) |
| 22 | , fWaitedOn(std::move(surfaceView)) {} |
| 23 | |
| 24 | private: |
| 25 | bool onIsUsed(GrSurfaceProxy* proxy) const override { |
| 26 | return proxy == fWaitedOn.proxy(); |
| 27 | } |
| 28 | void handleInternalAllocationFailure() override {} |
| 29 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 30 | |
| 31 | ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override { |
| 32 | return ExpectedOutcome::kTargetUnchanged; |
| 33 | } |
| 34 | |
| 35 | bool onExecute(GrOpFlushState*) override; |
| 36 | |
| 37 | #if GR_TEST_UTILS |
| 38 | const char* name() const final { return "Wait"; } |
| 39 | #endif |
| 40 | #ifdef SK_DEBUG |
| 41 | // No non-dst proxies. |
| 42 | void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {} |
| 43 | #endif |
| 44 | std::unique_ptr<std::unique_ptr<GrSemaphore>[]> fSemaphores; |
| 45 | int fNumSemaphores; |
| 46 | |
| 47 | // This field is separate from the main "targets" field on GrRenderTask because this task |
| 48 | // does not actually write to the surface and so should not participate in the normal |
| 49 | // lastRenderTask tracking that written-to targets do. |
| 50 | GrSurfaceProxyView fWaitedOn; |
| 51 | }; |
| 52 | |
| 53 | #endif |
| 54 |