Wire up stack traces again

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1749163002

Review URL: https://codereview.chromium.org/1749163002
This commit is contained in:
joshualitt 2016-03-02 08:11:34 -08:00 committed by Commit bot
parent cb6cb3841a
commit f55c364485
2 changed files with 23 additions and 3 deletions

View File

@ -79,6 +79,11 @@ public:
GrAuditTrail* fAuditTrail;
};
void pushFrame(const char* framename) {
SkASSERT(fEnabled);
fCurrentStackTrace.push_back(SkString(framename));
}
void addBatch(const char* name, const SkRect& bounds);
void batchingResultCombined(GrBatch* combiner);
@ -124,6 +129,7 @@ private:
struct Batch {
SkString toJson() const;
SkString fName;
SkTArray<SkString> fStackTrace;
SkRect fBounds;
int fClientID;
int fBatchListID;
@ -150,6 +156,7 @@ private:
SkTHashMap<GrBatch*, int> fIDLookup;
SkTHashMap<int, Batches*> fClientIDLookup;
BatchList fBatchList;
SkTArray<SkString> fCurrentStackTrace;
// The client cas pass in an optional client ID which we will use to mark the batches
int fClientID;
@ -162,11 +169,10 @@ private:
}
#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename) \
// TODO fill out the frame stuff
//GrAuditTrail::AutoFrame SK_MACRO_APPEND_LINE(auto_frame)(audit_trail, framename);
GR_AUDIT_TRAIL_INVOKE_GUARD((audit_trail), pushFrame, framename);
#define GR_AUDIT_TRAIL_RESET(audit_trail) \
//GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail, reset);
//GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail, fullReset);
#define GR_AUDIT_TRAIL_ADDBATCH(audit_trail, batchname, bounds) \
GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail, addBatch, batchname, bounds);

View File

@ -19,6 +19,10 @@ void GrAuditTrail::addBatch(const char* name, const SkRect& bounds) {
batch->fClientID = kGrAuditTrailInvalidID;
batch->fBatchListID = kGrAuditTrailInvalidID;
batch->fChildID = kGrAuditTrailInvalidID;
// consume the current stack trace if any
batch->fStackTrace = fCurrentStackTrace;
fCurrentStackTrace.reset();
fCurrentBatch = batch;
if (fClientID != kGrAuditTrailInvalidID) {
@ -242,6 +246,16 @@ SkString GrAuditTrail::Batch::toJson() const {
json.appendf("\"BatchListID\": \"%d\",", fBatchListID);
json.appendf("\"ChildID\": \"%d\",", fChildID);
skrect_to_json(&json, "Bounds", fBounds);
if (fStackTrace.count()) {
json.append(",\"Stack\": [");
for (int i = 0; i < fStackTrace.count(); i++) {
json.appendf("\"%s\"", fStackTrace[i].c_str());
if (i < fStackTrace.count() - 1) {
json.append(",");
}
}
json.append("]");
}
json.append("}");
return json;
}