Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/gpu/GrDDLTask.cpp
Line
Count
Source (jump to first uncovered line)
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
#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
14
GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr,
15
                     sk_sp<GrRenderTargetProxy> ddlTarget,
16
                     sk_sp<const SkDeferredDisplayList> ddl,
17
                     SkIPoint offset)
18
        : fDDL(std::move(ddl))
19
        , fDDLTarget(std::move(ddlTarget))
20
0
        , fOffset(offset) {
21
0
    (void) fOffset;  // fOffset will be used shortly
22
23
0
    for (auto& task : fDDL->priv().renderTasks()) {
24
0
        SkASSERT(task->isClosed());
25
26
0
        for (int i = 0; i < task->numTargets(); ++i) {
27
0
            drawingMgr->setLastRenderTask(task->target(i), task.get());
28
0
        }
29
0
    }
30
31
    // The DDL task never accepts additional tasks
32
0
    this->setFlag(kClosed_Flag);
33
0
}
Unexecuted instantiation: GrDDLTask::GrDDLTask(GrDrawingManager*, sk_sp<GrRenderTargetProxy>, sk_sp<SkDeferredDisplayList const>, SkIPoint)
Unexecuted instantiation: GrDDLTask::GrDDLTask(GrDrawingManager*, sk_sp<GrRenderTargetProxy>, sk_sp<SkDeferredDisplayList const>, SkIPoint)
34
35
0
GrDDLTask::~GrDDLTask() { }
36
37
0
void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
38
0
    for (auto& task : fDDL->priv().renderTasks()) {
39
0
        task->endFlush(drawingManager);
40
0
    }
41
42
0
    INHERITED::endFlush(drawingManager);
43
0
}
44
45
0
void GrDDLTask::disown(GrDrawingManager* drawingManager) {
46
0
    for (auto& task : fDDL->priv().renderTasks()) {
47
0
        task->disown(drawingManager);
48
0
    }
49
50
0
    INHERITED::disown(drawingManager);
51
0
}
52
53
0
bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
54
0
    if (proxy == fDDLTarget.get()) {
55
0
        return true;
56
0
    }
57
58
0
    for (auto& task : fDDL->priv().renderTasks()) {
59
0
        if (task->isUsed(proxy)) {
60
0
            return true;
61
0
        }
62
0
    }
63
64
0
    return false;
65
0
}
66
67
0
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.
70
0
    alloc->incOps();
71
72
0
    for (auto& task : fDDL->priv().renderTasks()) {
73
0
        task->gatherProxyIntervals(alloc);
74
0
    }
75
0
}
76
77
GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(GrRecordingContext*,
78
0
                                                      SkIRect* targetUpdateBounds) {
79
0
    SkASSERT(0);
80
0
    return ExpectedOutcome::kTargetUnchanged;
81
0
}
Unexecuted instantiation: GrDDLTask::onMakeClosed(GrRecordingContext*, SkIRect*)
Unexecuted instantiation: GrDDLTask::onMakeClosed(GrRecordingContext*, SkIRect*)
82
83
0
void GrDDLTask::gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const {
84
0
    for (auto& task : fDDL->priv().renderTasks()) {
85
0
        task->gatherIDs(idArray);
86
0
    }
87
0
}
88
89
0
void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
90
0
    for (auto& task : fDDL->priv().renderTasks()) {
91
0
        task->prepare(flushState);
92
0
    }
93
0
}
94
95
0
bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
96
0
    bool anyCommandsIssued = false;
97
0
    for (auto& task : fDDL->priv().renderTasks()) {
98
0
        if (task->execute(flushState)) {
99
0
            anyCommandsIssued = true;
100
0
        }
101
0
    }
102
103
0
    return anyCommandsIssued;
104
0
}
105
106
#if GR_TEST_UTILS
107
void GrDDLTask::dump(const SkString& label,
108
                     SkString indent,
109
                     bool printDependencies,
110
0
                     bool close) const {
111
0
    INHERITED::dump(label, indent, printDependencies, false);
112
113
0
    SkDebugf("%sDDL Target: ", indent.c_str());
114
0
    if (fDDLTarget) {
115
0
        SkString proxyStr = fDDLTarget->dump();
116
0
        SkDebugf("%s", proxyStr.c_str());
117
0
    }
118
0
    SkDebugf("\n");
119
120
0
    SkDebugf("%s%d sub-tasks\n", indent.c_str(), fDDL->priv().numRenderTasks());
121
122
0
    SkString subIndent(indent);
123
0
    subIndent.append("    ");
124
125
0
    int index = 0;
126
0
    for (auto& task : fDDL->priv().renderTasks()) {
127
0
        SkString subLabel;
128
0
        subLabel.printf("sub-task %d/%d", index++, fDDL->priv().numRenderTasks());
129
0
        task->dump(subLabel, subIndent, printDependencies, true);
130
0
    }
131
132
0
    if (close) {
133
0
        SkDebugf("%s--------------------------------------------------------------\n\n",
134
0
                 indent.c_str());
135
0
    }
136
0
}
137
#endif