blob: 7f3bef24df7a9218d3c3d1defdb7d9fcba92aa98 [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#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
20 for (const sk_sp<GrRenderTask>& task : fDDL->priv().renderTasks()) {
21 SkASSERT(task->isClosed());
22
23 for (int i = 0; i < task->numTargets(); ++i) {
24 drawingMgr->setLastRenderTask(task->target(i).proxy(), task.get());
25 }
26 }
27
28 // The DDL task never accepts additional tasks
29 this->setFlag(kClosed_Flag);
30}
31
32GrDDLTask::~GrDDLTask() { }
33
34void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
35 for (auto& task : fDDL->priv().renderTasks()) {
36 task->endFlush(drawingManager);
37 }
38
39 INHERITED::endFlush(drawingManager);
40}
41
42void GrDDLTask::disown(GrDrawingManager* drawingManager) {
43 for (auto& task : fDDL->priv().renderTasks()) {
44 task->disown(drawingManager);
45 }
46
47 INHERITED::disown(drawingManager);
48}
49
50bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
51 for (auto& task : fDDL->priv().renderTasks()) {
52 if (task->isUsed(proxy)) {
53 return true;
54 }
55 }
56
57 return false;
58}
59
60void GrDDLTask::handleInternalAllocationFailure() {
61 for (auto& task : fDDL->priv().renderTasks()) {
62 task->handleInternalAllocationFailure();
63 }
64}
65
66void GrDDLTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
67 // We don't have any proxies, but the resource allocator will still bark
68 // if a task doesn't claim any op indices, so we oblige it.
69 alloc->incOps();
70
71 for (auto& task : fDDL->priv().renderTasks()) {
72 task->gatherProxyIntervals(alloc);
73 }
74}
75
76GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(const GrCaps& caps,
77 SkIRect* targetUpdateBounds) {
78 SkASSERT(0);
79 return ExpectedOutcome::kTargetUnchanged;
80}
81
82void GrDDLTask::gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const {
83 for (auto& task : fDDL->priv().renderTasks()) {
84 task->gatherIDs(idArray);
85 }
86}
87
88void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
89 for (auto& task : fDDL->priv().renderTasks()) {
90 task->prepare(flushState);
91 }
92}
93
94bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
95 bool anyCommandsIssued = false;
96 for (auto& task : fDDL->priv().renderTasks()) {
97 if (task->execute(flushState)) {
98 anyCommandsIssued = true;
99 }
100 }
101
102 return anyCommandsIssued;
103}