2 * Copyright 2020 Google LLC
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "src/gpu/ganesh/GrDDLTask.h"
10 #include "include/core/SkDeferredDisplayList.h"
11 #include "src/core/SkDeferredDisplayListPriv.h"
12 #include "src/gpu/ganesh/GrResourceAllocator.h"
14 GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr,
15 sk_sp<GrRenderTargetProxy> ddlTarget,
16 sk_sp<const SkDeferredDisplayList> ddl,
18 : fDDL(std::move(ddl))
19 , fDDLTarget(std::move(ddlTarget))
21 (void) fOffset; // fOffset will be used shortly
23 for (auto& task : fDDL->priv().renderTasks()) {
24 SkASSERT(task->isClosed());
26 for (int i = 0; i < task->numTargets(); ++i) {
27 drawingMgr->setLastRenderTask(task->target(i), task.get());
31 // The DDL task never accepts additional tasks
32 this->setFlag(kClosed_Flag);
35 GrDDLTask::~GrDDLTask() { }
37 void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
38 for (auto& task : fDDL->priv().renderTasks()) {
39 task->endFlush(drawingManager);
42 INHERITED::endFlush(drawingManager);
45 void GrDDLTask::disown(GrDrawingManager* drawingManager) {
46 for (auto& task : fDDL->priv().renderTasks()) {
47 task->disown(drawingManager);
50 INHERITED::disown(drawingManager);
53 bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
54 if (proxy == fDDLTarget.get()) {
58 for (auto& task : fDDL->priv().renderTasks()) {
59 if (task->isUsed(proxy)) {
67 void GrDDLTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
68 // We don't have any proxies, but the resource allocator will still bark
69 // if a task doesn't claim any op indices, so we oblige it.
72 for (auto& task : fDDL->priv().renderTasks()) {
73 task->gatherProxyIntervals(alloc);
77 GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(GrRecordingContext*,
78 SkIRect* targetUpdateBounds) {
80 return ExpectedOutcome::kTargetUnchanged;
83 void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
84 for (auto& task : fDDL->priv().renderTasks()) {
85 task->prepare(flushState);
89 bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
90 bool anyCommandsIssued = false;
91 for (auto& task : fDDL->priv().renderTasks()) {
92 if (task->execute(flushState)) {
93 anyCommandsIssued = true;
97 return anyCommandsIssued;
101 void GrDDLTask::dump(const SkString& label,
103 bool printDependencies,
105 INHERITED::dump(label, indent, printDependencies, false);
107 SkDebugf("%sDDL Target: ", indent.c_str());
109 SkString proxyStr = fDDLTarget->dump();
110 SkDebugf("%s", proxyStr.c_str());
114 SkDebugf("%s%d sub-tasks\n", indent.c_str(), fDDL->priv().numRenderTasks());
116 SkString subIndent(indent);
117 subIndent.append(" ");
120 for (auto& task : fDDL->priv().renderTasks()) {
122 subLabel.printf("sub-task %d/%d", index++, fDDL->priv().numRenderTasks());
123 task->dump(subLabel, subIndent, printDependencies, true);
127 SkDebugf("%s--------------------------------------------------------------\n\n",