Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | List of all members
GrAuditTrail Class Reference

#include <GrAuditTrail.h>

Classes

class  AutoCollectOps
 
class  AutoEnable
 
class  AutoManageOpsTask
 
struct  OpInfo
 

Public Member Functions

 GrAuditTrail ()
 
void pushFrame (const char *framename)
 
void addOp (const GrOp *, GrRenderTargetProxy::UniqueID proxyID)
 
void opsCombined (const GrOp *consumer, const GrOp *consumed)
 
void toJson (SkJSONWriter &writer) const
 
void toJson (SkJSONWriter &writer, int clientID) const
 
bool isEnabled ()
 
void setEnabled (bool enabled)
 
void setClientID (int clientID)
 
void getBoundsByClientID (skia_private::TArray< OpInfo > *outInfo, int clientID)
 
void getBoundsByOpsTaskID (OpInfo *outInfo, int opsTaskID)
 
void fullReset ()
 

Static Public Attributes

static const int kGrAuditTrailInvalidID = -1
 

Detailed Description

Definition at line 31 of file GrAuditTrail.h.

Constructor & Destructor Documentation

◆ GrAuditTrail()

GrAuditTrail::GrAuditTrail ( )
inline

Definition at line 33 of file GrAuditTrail.h.

33: fClientID(kGrAuditTrailInvalidID), fEnabled(false) {}
static const int kGrAuditTrailInvalidID

Member Function Documentation

◆ addOp()

void GrAuditTrail::addOp ( const GrOp op,
GrRenderTargetProxy::UniqueID  proxyID 
)

Definition at line 15 of file GrAuditTrail.cpp.

15 {
16 SkASSERT(fEnabled);
17 Op* auditOp = new Op;
18 fOpPool.emplace_back(auditOp);
19 auditOp->fName = op->name();
20 auditOp->fBounds = op->bounds();
21 auditOp->fClientID = kGrAuditTrailInvalidID;
22 auditOp->fOpsTaskID = kGrAuditTrailInvalidID;
23 auditOp->fChildID = kGrAuditTrailInvalidID;
24
25 // consume the current stack trace if any
26 auditOp->fStackTrace = fCurrentStackTrace;
27 fCurrentStackTrace.clear();
28
29 if (fClientID != kGrAuditTrailInvalidID) {
30 auditOp->fClientID = fClientID;
31 Ops** opsLookup = fClientIDLookup.find(fClientID);
32 Ops* ops = nullptr;
33 if (!opsLookup) {
34 ops = new Ops;
35 fClientIDLookup.set(fClientID, ops);
36 } else {
37 ops = *opsLookup;
38 }
39
40 ops->push_back(auditOp);
41 }
42
43 // Our algorithm doesn't bother to reorder inside of an OpNode so the ChildID will start at 0
44 auditOp->fOpsTaskID = fOpsTask.size();
45 auditOp->fChildID = 0;
46
47 // We use the op pointer as a key to find the OpNode we are 'glomming' ops onto
48 fIDLookup.set(op->uniqueID(), auditOp->fOpsTaskID);
49 OpNode* opNode = new OpNode(proxyID);
50 opNode->fBounds = op->bounds();
51 opNode->fChildren.push_back(auditOp);
52 fOpsTask.emplace_back(opNode);
53}
SkPathOp ops[]
#define SkASSERT(cond)
Definition SkAssert.h:116
uint32_t uniqueID() const
Definition GrOp.h:161
virtual const char * name() const =0
const SkRect & bounds() const
Definition GrOp.h:122
int size() const
Definition SkTArray.h:416
T & emplace_back(Args &&... args)
Definition SkTArray.h:243
V * set(K key, V val)
Definition SkTHash.h:472

◆ fullReset()

void GrAuditTrail::fullReset ( )

Definition at line 130 of file GrAuditTrail.cpp.

130 {
131 SkASSERT(fEnabled);
132 fOpsTask.clear();
133 fIDLookup.reset();
134 // free all client ops
135 fClientIDLookup.foreach ([](const int&, Ops** ops) { delete *ops; });
136 fClientIDLookup.reset();
137 fOpPool.clear(); // must be last, frees all of the memory
138}

◆ getBoundsByClientID()

void GrAuditTrail::getBoundsByClientID ( skia_private::TArray< OpInfo > *  outInfo,
int  clientID 
)

Definition at line 103 of file GrAuditTrail.cpp.

103 {
104 Ops** opsLookup = fClientIDLookup.find(clientID);
105 if (opsLookup) {
106 // We track which oplistID we're currently looking at. If it changes, then we need to push
107 // back a new op info struct. We happen to know that ops are in sequential order in the
108 // oplist, otherwise we'd have to do more bookkeeping
109 int currentOpsTaskID = kGrAuditTrailInvalidID;
110 for (int i = 0; i < (*opsLookup)->size(); i++) {
111 const Op* op = (**opsLookup)[i];
112
113 // Because we will copy out all of the ops associated with a given op list id everytime
114 // the id changes, we only have to update our struct when the id changes.
115 if (kGrAuditTrailInvalidID == currentOpsTaskID || op->fOpsTaskID != currentOpsTaskID) {
116 OpInfo& outOpInfo = outInfo->push_back();
117
118 // copy out all of the ops so the client can display them even if they have a
119 // different clientID
120 this->copyOutFromOpsTask(&outOpInfo, op->fOpsTaskID);
121 }
122 }
123 }
124}

◆ getBoundsByOpsTaskID()

void GrAuditTrail::getBoundsByOpsTaskID ( OpInfo outInfo,
int  opsTaskID 
)

Definition at line 126 of file GrAuditTrail.cpp.

126 {
127 this->copyOutFromOpsTask(outInfo, opsTaskID);
128}

◆ isEnabled()

bool GrAuditTrail::isEnabled ( )
inline

Definition at line 98 of file GrAuditTrail.h.

98{ return fEnabled; }

◆ opsCombined()

void GrAuditTrail::opsCombined ( const GrOp consumer,
const GrOp consumed 
)

Definition at line 55 of file GrAuditTrail.cpp.

55 {
56 // Look up the op we are going to glom onto
57 int* indexPtr = fIDLookup.find(consumer->uniqueID());
58 SkASSERT(indexPtr);
59 int index = *indexPtr;
60 SkASSERT(index < fOpsTask.size() && fOpsTask[index]);
61 OpNode& consumerOp = *fOpsTask[index];
62
63 // Look up the op which will be glommed
64 int* consumedPtr = fIDLookup.find(consumed->uniqueID());
65 SkASSERT(consumedPtr);
66 int consumedIndex = *consumedPtr;
67 SkASSERT(consumedIndex < fOpsTask.size() && fOpsTask[consumedIndex]);
68 OpNode& consumedOp = *fOpsTask[consumedIndex];
69
70 // steal all of consumed's ops
71 for (int i = 0; i < consumedOp.fChildren.size(); i++) {
72 Op* childOp = consumedOp.fChildren[i];
73
74 // set the ids for the child op
75 childOp->fOpsTaskID = index;
76 childOp->fChildID = consumerOp.fChildren.size();
77 consumerOp.fChildren.push_back(childOp);
78 }
79
80 // Update the bounds for the combineWith node
81 consumerOp.fBounds = consumer->bounds();
82
83 // remove the old node from our opsTask and clear the combinee's lookup
84 // NOTE: because we can't change the shape of the oplist, we use a sentinel
85 fOpsTask[consumedIndex].reset(nullptr);
86 fIDLookup.remove(consumed->uniqueID());
87}
void reset(int n)
Definition SkTArray.h:139
V * find(const K &key) const
Definition SkTHash.h:479
void remove(const K &key)
Definition SkTHash.h:494

◆ pushFrame()

void GrAuditTrail::pushFrame ( const char *  framename)
inline

Definition at line 78 of file GrAuditTrail.h.

78 {
79 SkASSERT(fEnabled);
80 fCurrentStackTrace.push_back(SkString(framename));
81 }

◆ setClientID()

void GrAuditTrail::setClientID ( int  clientID)
inline

Definition at line 101 of file GrAuditTrail.h.

101{ fClientID = clientID; }

◆ setEnabled()

void GrAuditTrail::setEnabled ( bool  enabled)
inline

Definition at line 99 of file GrAuditTrail.h.

99{ fEnabled = enabled; }

◆ toJson() [1/2]

void GrAuditTrail::toJson ( SkJSONWriter writer) const

Definition at line 208 of file GrAuditTrail.cpp.

208{}

◆ toJson() [2/2]

void GrAuditTrail::toJson ( SkJSONWriter writer,
int  clientID 
) const

Definition at line 209 of file GrAuditTrail.cpp.

209{}

Member Data Documentation

◆ kGrAuditTrailInvalidID

const int GrAuditTrail::kGrAuditTrailInvalidID = -1
static

Definition at line 121 of file GrAuditTrail.h.


The documentation for this class was generated from the following files: