Coverage Report

Created: 2024-09-14 07:19

/src/skia/src/gpu/ganesh/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/ganesh/GrDDLTask.h"
9
10
#include "include/core/SkString.h"
11
#include "include/private/base/SkDebug.h"
12
#include "include/private/base/SkTArray.h"
13
#include "include/private/chromium/GrDeferredDisplayList.h"
14
#include "src/gpu/ganesh/GrDeferredDisplayListPriv.h"
15
#include "src/gpu/ganesh/GrDrawingManager.h"
16
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
17
#include "src/gpu/ganesh/GrResourceAllocator.h"
18
19
#include <utility>
20
21
class GrOpFlushState;
22
class GrRecordingContext;
23
class GrSurfaceProxy;
24
struct SkIRect;
25
26
GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr,
27
                     sk_sp<GrRenderTargetProxy> ddlTarget,
28
                     sk_sp<const GrDeferredDisplayList> ddl)
29
        : fDDL(std::move(ddl))
30
0
        , fDDLTarget(std::move(ddlTarget)) {
31
32
0
    for (auto& task : fDDL->priv().renderTasks()) {
33
0
        SkASSERT(task->isClosed());
34
35
0
        for (int i = 0; i < task->numTargets(); ++i) {
36
0
            drawingMgr->setLastRenderTask(task->target(i), task.get());
37
0
        }
38
0
    }
39
40
    // The DDL task never accepts additional tasks
41
0
    this->setFlag(kClosed_Flag);
42
0
}
Unexecuted instantiation: GrDDLTask::GrDDLTask(GrDrawingManager*, sk_sp<GrRenderTargetProxy>, sk_sp<GrDeferredDisplayList const>)
Unexecuted instantiation: GrDDLTask::GrDDLTask(GrDrawingManager*, sk_sp<GrRenderTargetProxy>, sk_sp<GrDeferredDisplayList const>)
43
44
0
GrDDLTask::~GrDDLTask() { }
45
46
0
void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
47
0
    for (auto& task : fDDL->priv().renderTasks()) {
48
0
        task->endFlush(drawingManager);
49
0
    }
50
51
0
    INHERITED::endFlush(drawingManager);
52
0
}
53
54
0
void GrDDLTask::disown(GrDrawingManager* drawingManager) {
55
0
    for (auto& task : fDDL->priv().renderTasks()) {
56
0
        task->disown(drawingManager);
57
0
    }
58
59
0
    INHERITED::disown(drawingManager);
60
0
}
61
62
0
bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
63
0
    if (proxy == fDDLTarget.get()) {
64
0
        return true;
65
0
    }
66
67
0
    for (auto& task : fDDL->priv().renderTasks()) {
68
0
        if (task->isUsed(proxy)) {
69
0
            return true;
70
0
        }
71
0
    }
72
73
0
    return false;
74
0
}
75
76
0
void GrDDLTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
77
    // We don't have any proxies, but the resource allocator will still bark
78
    // if a task doesn't claim any op indices, so we oblige it.
79
0
    alloc->incOps();
80
81
0
    for (auto& task : fDDL->priv().renderTasks()) {
82
0
        task->gatherProxyIntervals(alloc);
83
0
    }
84
0
}
85
86
GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(GrRecordingContext*,
87
0
                                                      SkIRect* targetUpdateBounds) {
88
0
    SkASSERT(0);
89
0
    return ExpectedOutcome::kTargetUnchanged;
90
0
}
Unexecuted instantiation: GrDDLTask::onMakeClosed(GrRecordingContext*, SkIRect*)
Unexecuted instantiation: GrDDLTask::onMakeClosed(GrRecordingContext*, SkIRect*)
91
92
0
void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
93
0
    for (auto& task : fDDL->priv().renderTasks()) {
94
0
        task->prepare(flushState);
95
0
    }
96
0
}
97
98
0
bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
99
0
    bool anyCommandsIssued = false;
100
0
    for (auto& task : fDDL->priv().renderTasks()) {
101
0
        if (task->execute(flushState)) {
102
0
            anyCommandsIssued = true;
103
0
        }
104
0
    }
105
106
0
    return anyCommandsIssued;
107
0
}
108
109
#if defined(GPU_TEST_UTILS)
110
void GrDDLTask::dump(const SkString& label,
111
                     SkString indent,
112
                     bool printDependencies,
113
0
                     bool close) const {
114
0
    INHERITED::dump(label, indent, printDependencies, false);
115
116
0
    SkDebugf("%sDDL Target: ", indent.c_str());
117
0
    if (fDDLTarget) {
118
0
        SkString proxyStr = fDDLTarget->dump();
119
0
        SkDebugf("%s", proxyStr.c_str());
120
0
    }
121
0
    SkDebugf("\n");
122
123
0
    SkDebugf("%s%d sub-tasks\n", indent.c_str(), fDDL->priv().numRenderTasks());
124
125
0
    SkString subIndent(indent);
126
0
    subIndent.append("    ");
127
128
0
    int index = 0;
129
0
    for (auto& task : fDDL->priv().renderTasks()) {
130
0
        SkString subLabel;
131
0
        subLabel.printf("sub-task %d/%d", index++, fDDL->priv().numRenderTasks());
132
0
        task->dump(subLabel, subIndent, printDependencies, true);
133
0
    }
134
135
0
    if (close) {
136
0
        SkDebugf("%s--------------------------------------------------------------\n\n",
137
0
                 indent.c_str());
138
0
    }
139
0
}
140
#endif