blob: 3c129aca4b92d958006834bd7f0bd6e400d163cb [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
11#include "src/gpu/GrRenderTask.h"
12
13class GrRenderTargetProxy;
14
15/**
16 * This render task isolates the DDL's tasks from the rest of the DAG. This means that
17 * the DDL's tasks cannot be reordered by the topological sort and are always executed
18 * as a single block.
19 * It almost entirely just forwards calls down to the DDL's render tasks.
20 */
21class GrDDLTask final : public GrRenderTask {
22public:
23 GrDDLTask(GrDrawingManager*,
24 sk_sp<GrRenderTargetProxy> ddlTarget,
25 sk_sp<const SkDeferredDisplayList>);
26
27 ~GrDDLTask() override;
28
29 // The render tasks w/in the DDL don't appear in the DAG so need explicit notification
30 // when they can free their contents.
31 bool requiresExplicitCleanup() const override { return true; }
32
33 void endFlush(GrDrawingManager*) override;
34
35 void disown(GrDrawingManager*) override;
36
37private:
38 bool onIsUsed(GrSurfaceProxy* proxy) const override;
39
40 void handleInternalAllocationFailure() override;
41
42 void gatherProxyIntervals(GrResourceAllocator*) const override;
43
44 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
45
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
60 const char* name() const final { return "DDL"; }
61#endif
62#ifdef SK_DEBUG
63 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {}
64#endif
65
66 sk_sp<const SkDeferredDisplayList> fDDL;
67 sk_sp<GrRenderTargetProxy> fDDLTarget;
68
69 typedef GrRenderTask INHERITED;
70};
71
72#endif