Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 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 | |
Robert Phillips | 88b2961 | 2020-11-16 15:15:08 -0500 | [diff] [blame] | 11 | #include "include/core/SkPoint.h" |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 12 | #include "src/gpu/GrRenderTask.h" |
| 13 | |
| 14 | class 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 | */ |
| 22 | class GrDDLTask final : public GrRenderTask { |
| 23 | public: |
| 24 | GrDDLTask(GrDrawingManager*, |
| 25 | sk_sp<GrRenderTargetProxy> ddlTarget, |
Robert Phillips | 88b2961 | 2020-11-16 15:15:08 -0500 | [diff] [blame] | 26 | sk_sp<const SkDeferredDisplayList>, |
| 27 | SkIPoint offset); |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 28 | |
| 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 | |
| 39 | private: |
Robert Phillips | 88b2961 | 2020-11-16 15:15:08 -0500 | [diff] [blame] | 40 | bool onIsUsed(GrSurfaceProxy*) const override; |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 41 | |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 42 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 43 | |
Chris Dalton | aa938ce | 2021-06-23 18:13:59 -0600 | [diff] [blame] | 44 | ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override; |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 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 |
Robert Phillips | 047d5bb | 2021-01-08 13:39:19 -0500 | [diff] [blame] | 60 | void dump(const SkString& label, |
| 61 | SkString indent, |
| 62 | bool printDependencies, |
| 63 | bool close) const final; |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 64 | const char* name() const final { return "DDL"; } |
| 65 | #endif |
| 66 | #ifdef SK_DEBUG |
Robert Phillips | 294723d | 2021-06-17 09:23:58 -0400 | [diff] [blame] | 67 | void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {} |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 68 | #endif |
| 69 | |
| 70 | sk_sp<const SkDeferredDisplayList> fDDL; |
| 71 | sk_sp<GrRenderTargetProxy> fDDLTarget; |
Robert Phillips | 88b2961 | 2020-11-16 15:15:08 -0500 | [diff] [blame] | 72 | SkIPoint fOffset; |
Robert Phillips | 07f675d | 2020-11-16 13:44:01 -0500 | [diff] [blame] | 73 | |
| 74 | typedef GrRenderTask INHERITED; |
| 75 | }; |
| 76 | |
| 77 | #endif |