xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrDDLTask.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
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 "include/core/SkRefCnt.h"
12 #include "include/core/SkTypes.h"
13 #include "include/private/gpu/ganesh/GrTypesPriv.h"
14 #include "src/gpu/ganesh/GrRenderTask.h"
15 
16 class GrDeferredDisplayList;
17 class GrDrawingManager;
18 class GrOpFlushState;
19 class GrRecordingContext;
20 class GrRenderTargetProxy;
21 class GrResourceAllocator;
22 class GrSurfaceProxy;
23 class SkString;
24 struct SkIRect;
25 
26 /**
27  * This render task isolates the DDL's tasks from the rest of the DAG. This means that
28  * the DDL's tasks cannot be reordered by the topological sort and are always executed
29  * as a single block.
30  * It almost entirely just forwards calls down to the DDL's render tasks.
31  */
32 class GrDDLTask final : public GrRenderTask {
33 public:
34     GrDDLTask(GrDrawingManager*,
35               sk_sp<GrRenderTargetProxy> ddlTarget,
36               sk_sp<const GrDeferredDisplayList>);
37 
38     ~GrDDLTask() override;
39 
40     // The render tasks w/in the DDL don't appear in the DAG so need explicit notification
41     // when they can free their contents.
requiresExplicitCleanup()42     bool requiresExplicitCleanup() const override { return true; }
43 
44     void endFlush(GrDrawingManager*) override;
45 
46     void disown(GrDrawingManager*) override;
47 
48 private:
49     bool onIsUsed(GrSurfaceProxy*) const override;
50 
51     void gatherProxyIntervals(GrResourceAllocator*) const override;
52 
53     ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override;
54 
onPrePrepare(GrRecordingContext *)55     void onPrePrepare(GrRecordingContext*) override {
56         // This entry point is only called when a DDL is snapped off of a recorder.
57         // Since DDL tasks should never recursively appear within a DDL this should never
58         // be called.
59         SkASSERT(0);
60     }
61 
62     void onPrepare(GrOpFlushState*) override;
63 
64     bool onExecute(GrOpFlushState*) override;
65 
66 #if defined(GPU_TEST_UTILS)
67     void dump(const SkString& label,
68               SkString indent,
69               bool printDependencies,
70               bool close) const final;
name()71     const char* name() const final { return "DDL"; }
72 #endif
73 #ifdef SK_DEBUG
visitProxies_debugOnly(const GrVisitProxyFunc &)74     void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {}
75 #endif
76 
77     sk_sp<const GrDeferredDisplayList> fDDL;
78     sk_sp<GrRenderTargetProxy>         fDDLTarget;
79 
80     typedef GrRenderTask INHERITED;
81 };
82 
83 #endif
84