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