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:
GrWaitRenderTask(sk_sp<GrSurfaceProxy> proxy,std::unique_ptr<sk_sp<GrSemaphore>[]> semaphores,int numSemaphores)16     GrWaitRenderTask(sk_sp<GrSurfaceProxy> proxy, std::unique_ptr<sk_sp<GrSemaphore>[]> semaphores,
17                      int numSemaphores)
18             : GrRenderTask(std::move(proxy))
19             , fSemaphores(std::move(semaphores))
20             , fNumSemaphores(numSemaphores){}
21 
22 private:
onIsUsed(GrSurfaceProxy * proxy)23     bool onIsUsed(GrSurfaceProxy* proxy) const override {
24         SkASSERT(proxy != fTarget.get());  // This case should be handled by GrRenderTask.
25         return false;
26     }
handleInternalAllocationFailure()27     void handleInternalAllocationFailure() override {}
28     void gatherProxyIntervals(GrResourceAllocator*) const override;
29 
onMakeClosed(const GrCaps &,SkIRect *)30     ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override {
31         return ExpectedOutcome::kTargetUnchanged;
32     }
33 
34     bool onExecute(GrOpFlushState*) override;
35 
36 #ifdef SK_DEBUG
37     // No non-dst proxies.
visitProxies_debugOnly(const VisitSurfaceProxyFunc & fn)38     void visitProxies_debugOnly(const VisitSurfaceProxyFunc& fn) const override {}
39 #endif
40     std::unique_ptr<sk_sp<GrSemaphore>[]> fSemaphores;
41     int fNumSemaphores;
42 };
43 
44 #endif
45