diff options
author | joshualitt <joshualitt@chromium.org> | 2016-02-29 07:44:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-29 07:44:02 -0800 |
commit | b95c772d45efc98f0159fa65c7aa06314cecb9de (patch) | |
tree | d3182df749c26a83ea755f0f8671f10c46515b01 /src | |
parent | 409d470a4973e2ba9f95983b9820931adcf7cd73 (diff) |
Add abilitly to query audit trail for batches by draw op
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1745513002
Committed: https://skia.googlesource.com/skia/+/9b48a6e3f862076018cc7d63b180b6340f4873cd
Review URL: https://codereview.chromium.org/1745513002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAuditTrail.cpp | 87 |
1 files changed, 56 insertions, 31 deletions
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp index 59201f4450..4b90ea524f 100644 --- a/src/gpu/GrAuditTrail.cpp +++ b/src/gpu/GrAuditTrail.cpp @@ -8,29 +8,36 @@ #include "GrAuditTrail.h" #include "batches/GrBatch.h" +const int GrAuditTrail::kGrAuditTrailInvalidID = -1; + void GrAuditTrail::batchingResultCombined(GrBatch* combiner) { int* indexPtr = fIDLookup.find(combiner); SkASSERT(indexPtr); int index = *indexPtr; - SkASSERT(index < fBatches.count()); - Batch& batch = *fBatches[index]; - - // if this is our first child, we also push back a copy of the original batch and its - // bounds - if (batch.fChildren.empty()) { - Batch* firstBatch = new Batch; - firstBatch->fName = batch.fName; - firstBatch->fBounds = batch.fBounds; - fEvents.emplace_back(firstBatch); - batch.fChildren.push_back(firstBatch); - } + SkASSERT(index < fBatchList.count()); + BatchNode& batch = *fBatchList[index]; + + // set the ids for the child batch + fCurrentBatch->fBatchListID = index; + fCurrentBatch->fChildID = batch.fChildren.count(); + + // Update the bounds and store a pointer to the new batch batch.fChildren.push_back(fCurrentBatch); batch.fBounds = combiner->bounds(); } void GrAuditTrail::batchingResultNew(GrBatch* batch) { - fIDLookup.set(batch, fBatches.count()); - fBatches.push_back(fCurrentBatch); + // Our algorithm doesn't bother to reorder inside of a BatchNode + // so the ChildID will start at 0 + fCurrentBatch->fBatchListID = fBatchList.count(); + fCurrentBatch->fChildID = 0; + + // We use the batch pointer as a key to find the batchnode we are 'glomming' batches onto + fIDLookup.set(batch, fCurrentBatch->fBatchListID); + BatchNode* batchNode = new BatchNode; + batchNode->fBounds = fCurrentBatch->fBounds; + batchNode->fChildren.push_back(fCurrentBatch); + fBatchList.emplace_back(batchNode); } template <typename T> @@ -118,15 +125,27 @@ static SkString pretty_print_json(SkString json) { return prettyPrintJson.prettify(json); } -SkString GrAuditTrail::toJson(bool batchList, bool prettyPrint) const { +SkString GrAuditTrail::toJson(bool prettyPrint) const { SkString json; json.append("{"); - if (!batchList) { - JsonifyTArray(&json, "Stacks", fFrames, false); + JsonifyTArray(&json, "Batches", fBatchList, false); + json.append("}"); + + if (prettyPrint) { + return pretty_print_json(json); } else { - JsonifyTArray(&json, "Batches", fBatches, false); + return json; } - json.append("}"); +} + +SkString GrAuditTrail::toJson(int clientID, bool prettyPrint) const { + SkString json; + json.append("{"); + Batches** batches = fClientIDLookup.find(clientID); + if (batches) { + JsonifyTArray(&json, "Batches", **batches, false); + } + json.appendf("}"); if (prettyPrint) { return pretty_print_json(json); @@ -135,26 +154,32 @@ SkString GrAuditTrail::toJson(bool batchList, bool prettyPrint) const { } } -SkString GrAuditTrail::Frame::toJson() const { +static void skrect_to_json(SkString* json, const char* name, const SkRect& rect) { + json->appendf("\"%s\": {", name); + json->appendf("\"Left\": %f,", rect.fLeft); + json->appendf("\"Right\": %f,", rect.fRight); + json->appendf("\"Top\": %f,", rect.fTop); + json->appendf("\"Bottom\": %f", rect.fBottom); + json->append("}"); +} + +SkString GrAuditTrail::Batch::toJson() const { SkString json; json.append("{"); - json.appendf("\"Name\": \"%s\"", fName); - JsonifyTArray(&json, "Frames", fChildren, true); + json.appendf("\"Name\": \"%s\",", fName.c_str()); + json.appendf("\"ClientID\": \"%d\",", fClientID); + json.appendf("\"BatchListID\": \"%d\",", fBatchListID); + json.appendf("\"ChildID\": \"%d\",", fChildID); + skrect_to_json(&json, "Bounds", fBounds); json.append("}"); return json; } -SkString GrAuditTrail::Batch::toJson() const { +SkString GrAuditTrail::BatchNode::toJson() const { SkString json; json.append("{"); - json.appendf("\"Name\": \"%s\",", fName); - json.append("\"Bounds\": {"); - json.appendf("\"Left\": %f,", fBounds.fLeft); - json.appendf("\"Right\": %f,", fBounds.fRight); - json.appendf("\"Top\": %f,", fBounds.fTop); - json.appendf("\"Bottom\": %f", fBounds.fBottom); - JsonifyTArray(&json, "Children", fChildren, true); - json.append("}"); + skrect_to_json(&json, "Bounds", fBounds); + JsonifyTArray(&json, "Batches", fChildren, true); json.append("}"); return json; } |