blob: d354e59405e56ce5fa95371a02e65ed955e32cec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrOpList.h"
#include "GrRenderTargetOpList.h"
#include "GrSurface.h"
#include "GrSurfaceProxy.h"
GrOpList::GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail)
: fFlags(0)
, fTarget(surfaceProxy)
, fAuditTrail(auditTrail) {
surfaceProxy->setLastOpList(this);
#ifdef SK_DEBUG
static int debugID = 0;
fDebugID = debugID++;
#endif
}
GrOpList::~GrOpList() {
if (fTarget && this == fTarget->getLastOpList()) {
fTarget->setLastOpList(nullptr);
}
}
// Add a GrOpList-based dependency
void GrOpList::addDependency(GrOpList* dependedOn) {
SkASSERT(!dependedOn->dependsOn(this)); // loops are bad
if (this->dependsOn(dependedOn)) {
return; // don't add duplicate dependencies
}
*fDependencies.push() = dependedOn;
}
// Convert from a GrSurface-based dependency to a GrOpList one
void GrOpList::addDependency(GrSurface* dependedOn) {
if (dependedOn->getLastOpList()) {
// If it is still receiving dependencies, this GrOpList shouldn't be closed
SkASSERT(!this->isClosed());
GrOpList* opList = dependedOn->getLastOpList();
if (opList == this) {
// self-read - presumably for dst reads
} else {
this->addDependency(opList);
// Can't make it closed in the self-read case
opList->makeClosed();
}
}
}
#ifdef SK_DEBUG
void GrOpList::dump() const {
SkDebugf("--------------------------------------------------------------\n");
SkDebugf("node: %d -> RT: %d\n", fDebugID, fTarget ? fTarget->uniqueID().asUInt() : -1);
SkDebugf("relies On (%d): ", fDependencies.count());
for (int i = 0; i < fDependencies.count(); ++i) {
SkDebugf("%d, ", fDependencies[i]->fDebugID);
}
SkDebugf("\n");
}
#endif
|