blob: f665de3d92802bc10a24cea21f6a42ed66dae0f2 [file] [log] [blame]
Robert Phillips02dd0ed2020-11-09 17:03:34 -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#include "src/gpu/GrDDLTask.h"
9
10#include "include/core/SkDeferredDisplayList.h"
11#include "src/core/SkDeferredDisplayListPriv.h"
12#include "src/gpu/GrResourceAllocator.h"
13
14GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr,
15 sk_sp<GrRenderTargetProxy> ddlTarget,
16 sk_sp<const SkDeferredDisplayList> ddl)
17 : fDDL(std::move(ddl))
18 , fDDLTarget(std::move(ddlTarget)) {
19 for (auto& task : fDDL->priv().renderTasks()) {
20 SkASSERT(task->isClosed());
21
22 for (int i = 0; i < task->numTargets(); ++i) {
23 this->addTarget(drawingMgr, task->target(i));
24 }
25 }
26
27 // The DDL task never accepts additional tasks
28 this->setFlag(kClosed_Flag);
29}
30
31GrDDLTask::~GrDDLTask() { }
32
33void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
34 for (auto& task : fDDL->priv().renderTasks()) {
35 task->endFlush(drawingManager);
36 }
37
38 INHERITED::endFlush(drawingManager);
39}
40
41void GrDDLTask::disown(GrDrawingManager* drawingManager) {
42 for (auto& task : fDDL->priv().renderTasks()) {
43 task->disown(drawingManager);
44 }
45
46 INHERITED::disown(drawingManager);
47}
48
49bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
50 // In the ctor we've added all the targets from the sub-renderTasks into the targets list
51 // of the this task. The base class' 'isUsed' call checks those so we don't want to check
52 // them again here. The following 'onIsUsed' methods just check the other (non-target) proxies.
53 for (auto& task : fDDL->priv().renderTasks()) {
54 if (task->onIsUsed(proxy)) {
55 return true;
56 }
57 }
58
59 return false;
60}
61
62void GrDDLTask::handleInternalAllocationFailure() {
63 for (auto& task : fDDL->priv().renderTasks()) {
64 task->handleInternalAllocationFailure();
65 }
66}
67
68void GrDDLTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
69 // We don't have any proxies, but the resource allocator will still bark
70 // if a task doesn't claim any op indices, so we oblige it.
71 alloc->incOps();
72
73 for (auto& task : fDDL->priv().renderTasks()) {
74 task->gatherProxyIntervals(alloc);
75 }
76}
77
78GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(const GrCaps& caps,
79 SkIRect* targetUpdateBounds) {
80 SkASSERT(0);
81 return ExpectedOutcome::kTargetUnchanged;
82}
83
84void GrDDLTask::gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const {
85 for (auto& task : fDDL->priv().renderTasks()) {
86 task->gatherIDs(idArray);
87 }
88}
89
90void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
91 for (auto& task : fDDL->priv().renderTasks()) {
92 task->prepare(flushState);
93 }
94}
95
96bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
97 bool anyCommandsIssued = false;
98 for (auto& task : fDDL->priv().renderTasks()) {
99 if (task->execute(flushState)) {
100 anyCommandsIssued = true;
101 }
102 }
103
104 return anyCommandsIssued;
105}