blob: ba121e4e841faf8dd8d129be4f0a500d164a9eb0 [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
Robert Phillips07f675d2020-11-16 13:44:01 -050042 void gatherProxyIntervals(GrResourceAllocator*) const override;
43
Chris Daltonaa938ce2021-06-23 18:13:59 -060044 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override;
Robert Phillips07f675d2020-11-16 13:44:01 -050045
46 void gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const override;
47
48 void onPrePrepare(GrRecordingContext*) override {
49 // This entry point is only called when a DDL is snapped off of a recorder.
50 // Since DDL tasks should never recursively appear within a DDL this should never
51 // be called.
52 SkASSERT(0);
53 }
54
55 void onPrepare(GrOpFlushState*) override;
56
57 bool onExecute(GrOpFlushState*) override;
58
59#if GR_TEST_UTILS
Robert Phillips047d5bb2021-01-08 13:39:19 -050060 void dump(const SkString& label,
61 SkString indent,
62 bool printDependencies,
63 bool close) const final;
Robert Phillips07f675d2020-11-16 13:44:01 -050064 const char* name() const final { return "DDL"; }
65#endif
66#ifdef SK_DEBUG
Robert Phillips294723d2021-06-17 09:23:58 -040067 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {}
Robert Phillips07f675d2020-11-16 13:44:01 -050068#endif
69
70 sk_sp<const SkDeferredDisplayList> fDDL;
71 sk_sp<GrRenderTargetProxy> fDDLTarget;
Robert Phillips88b29612020-11-16 15:15:08 -050072 SkIPoint fOffset;
Robert Phillips07f675d2020-11-16 13:44:01 -050073
74 typedef GrRenderTask INHERITED;
75};
76
77#endif