blob: 820799eb3f1c547ae0f5b73db2f787ed074f2911 [file] [log] [blame]
Robert Phillips07f675d2020-11-16 13:44:01 -05001/*
2 * Copyright 2020 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 GrDDLTask_DEFINED
9#define GrDDLTask_DEFINED
10
Robert Phillips88b29612020-11-16 15:15:08 -050011#include "include/core/SkPoint.h"
Robert Phillips07f675d2020-11-16 13:44:01 -050012#include "src/gpu/GrRenderTask.h"
13
14class GrRenderTargetProxy;
15
16/**
17 * This render task isolates the DDL's tasks from the rest of the DAG. This means that
18 * the DDL's tasks cannot be reordered by the topological sort and are always executed
19 * as a single block.
20 * It almost entirely just forwards calls down to the DDL's render tasks.
21 */
22class GrDDLTask final : public GrRenderTask {
23public:
24 GrDDLTask(GrDrawingManager*,
25 sk_sp<GrRenderTargetProxy> ddlTarget,
Robert Phillips88b29612020-11-16 15:15:08 -050026 sk_sp<const SkDeferredDisplayList>,
27 SkIPoint offset);
Robert Phillips07f675d2020-11-16 13:44:01 -050028
29 ~GrDDLTask() override;
30
31 // The render tasks w/in the DDL don't appear in the DAG so need explicit notification
32 // when they can free their contents.
33 bool requiresExplicitCleanup() const override { return true; }
34
35 void endFlush(GrDrawingManager*) override;
36
37 void disown(GrDrawingManager*) override;
38
39private:
Robert Phillips88b29612020-11-16 15:15:08 -050040 bool onIsUsed(GrSurfaceProxy*) const override;
Robert Phillips07f675d2020-11-16 13:44:01 -050041
42 void handleInternalAllocationFailure() override;
43
44 void gatherProxyIntervals(GrResourceAllocator*) const override;
45
46 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
47
48 void gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const override;
49
50 void onPrePrepare(GrRecordingContext*) override {
51 // This entry point is only called when a DDL is snapped off of a recorder.
52 // Since DDL tasks should never recursively appear within a DDL this should never
53 // be called.
54 SkASSERT(0);
55 }
56
57 void onPrepare(GrOpFlushState*) override;
58
59 bool onExecute(GrOpFlushState*) override;
60
61#if GR_TEST_UTILS
Robert Phillips047d5bb2021-01-08 13:39:19 -050062 void dump(const SkString& label,
63 SkString indent,
64 bool printDependencies,
65 bool close) const final;
Robert Phillips07f675d2020-11-16 13:44:01 -050066 const char* name() const final { return "DDL"; }
67#endif
68#ifdef SK_DEBUG
69 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {}
70#endif
71
72 sk_sp<const SkDeferredDisplayList> fDDL;
73 sk_sp<GrRenderTargetProxy> fDDLTarget;
Robert Phillips88b29612020-11-16 15:15:08 -050074 SkIPoint fOffset;
Robert Phillips07f675d2020-11-16 13:44:01 -050075
76 typedef GrRenderTask INHERITED;
77};
78
79#endif