xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrWaitRenderTask.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 "include/private/base/SkDebug.h"
12 #include "include/private/gpu/ganesh/GrTypesPriv.h"
13 #include "src/gpu/ganesh/GrRenderTask.h"
14 #include "src/gpu/ganesh/GrSemaphore.h"
15 #include "src/gpu/ganesh/GrSurfaceProxyView.h"
16 
17 #include <memory>
18 #include <utility>
19 
20 class GrOpFlushState;
21 class GrRecordingContext;
22 class GrResourceAllocator;
23 class GrSurfaceProxy;
24 struct SkIRect;
25 
26 class GrWaitRenderTask final : public GrRenderTask {
27 public:
GrWaitRenderTask(GrSurfaceProxyView surfaceView,std::unique_ptr<std::unique_ptr<GrSemaphore>[]> semaphores,int numSemaphores)28     GrWaitRenderTask(GrSurfaceProxyView surfaceView,
29                      std::unique_ptr<std::unique_ptr<GrSemaphore>[]> semaphores,
30                      int numSemaphores)
31             : GrRenderTask()
32             , fSemaphores(std::move(semaphores))
33             , fNumSemaphores(numSemaphores)
34             , fWaitedOn(std::move(surfaceView)) {}
35 
36 private:
onIsUsed(GrSurfaceProxy * proxy)37     bool onIsUsed(GrSurfaceProxy* proxy) const override {
38         return proxy == fWaitedOn.proxy();
39     }
40     void gatherProxyIntervals(GrResourceAllocator*) const override;
41 
onMakeClosed(GrRecordingContext *,SkIRect *)42     ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override {
43         return ExpectedOutcome::kTargetUnchanged;
44     }
45 
46     bool onExecute(GrOpFlushState*) override;
47 
48 #if defined(GPU_TEST_UTILS)
name()49     const char* name() const final { return "Wait"; }
50 #endif
51 #ifdef SK_DEBUG
52     // No non-dst proxies.
visitProxies_debugOnly(const GrVisitProxyFunc &)53     void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {}
54 #endif
55     std::unique_ptr<std::unique_ptr<GrSemaphore>[]> fSemaphores;
56     int fNumSemaphores;
57 
58     // This field is separate from the main "targets" field on GrRenderTask because this task
59     // does not actually write to the surface and so should not participate in the normal
60     // lastRenderTask tracking that written-to targets do.
61     GrSurfaceProxyView fWaitedOn;
62 };
63 
64 #endif
65