blob: ca89b7f627f0b4121c67e6b69c580ebf6ae7d3f3 [file] [log] [blame]
Greg Danielc30f1a92019-09-06 15:28:58 -04001/*
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
14class GrWaitRenderTask final : public GrRenderTask {
15public:
Greg Daniel16f5c652019-10-29 11:26:01 -040016 GrWaitRenderTask(GrSurfaceProxyView surfaceView,
Greg Daniel301015c2019-11-18 14:06:46 -050017 std::unique_ptr<std::unique_ptr<GrSemaphore>[]> semaphores,
Greg Danielc30f1a92019-09-06 15:28:58 -040018 int numSemaphores)
Adlai Holler33d569e2020-06-16 14:30:08 -040019 : GrRenderTask()
Greg Danielc30f1a92019-09-06 15:28:58 -040020 , fSemaphores(std::move(semaphores))
Adlai Holler33d569e2020-06-16 14:30:08 -040021 , fNumSemaphores(numSemaphores)
22 , fWaitedOn(std::move(surfaceView)) {}
Greg Danielc30f1a92019-09-06 15:28:58 -040023
24private:
Greg Danielc30f1a92019-09-06 15:28:58 -040025 bool onIsUsed(GrSurfaceProxy* proxy) const override {
Adlai Holler33d569e2020-06-16 14:30:08 -040026 return proxy == fWaitedOn.proxy();
Greg Danielc30f1a92019-09-06 15:28:58 -040027 }
Greg Danielc30f1a92019-09-06 15:28:58 -040028 void gatherProxyIntervals(GrResourceAllocator*) const override;
29
Chris Daltonaa938ce2021-06-23 18:13:59 -060030 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override {
Greg Danielc30f1a92019-09-06 15:28:58 -040031 return ExpectedOutcome::kTargetUnchanged;
32 }
33
34 bool onExecute(GrOpFlushState*) override;
35
John Stiles1e0136e2020-08-12 18:44:00 -040036#if GR_TEST_UTILS
Robert Phillips44e2c5f2020-04-14 13:00:04 -040037 const char* name() const final { return "Wait"; }
John Stiles1e0136e2020-08-12 18:44:00 -040038#endif
39#ifdef SK_DEBUG
Greg Danielc30f1a92019-09-06 15:28:58 -040040 // No non-dst proxies.
Robert Phillips294723d2021-06-17 09:23:58 -040041 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {}
Greg Danielc30f1a92019-09-06 15:28:58 -040042#endif
Greg Daniel301015c2019-11-18 14:06:46 -050043 std::unique_ptr<std::unique_ptr<GrSemaphore>[]> fSemaphores;
Greg Danielc30f1a92019-09-06 15:28:58 -040044 int fNumSemaphores;
Adlai Holler33d569e2020-06-16 14:30:08 -040045
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;
Greg Danielc30f1a92019-09-06 15:28:58 -040050};
51
52#endif