From 18d6b75829ac5d90050ca4da4f99292c14ff06f0 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 26 Feb 2016 08:07:50 -0800 Subject: Add batchlist managment to GrAuditTrail BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1724243004 Review URL: https://codereview.chromium.org/1724243004 --- src/gpu/GrAuditTrail.cpp | 38 +++++++++++++++++++++++++++++++++++--- src/gpu/GrDrawTarget.cpp | 2 ++ 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp index aa527fb4b0..59201f4450 100644 --- a/src/gpu/GrAuditTrail.cpp +++ b/src/gpu/GrAuditTrail.cpp @@ -6,8 +6,35 @@ */ #include "GrAuditTrail.h" +#include "batches/GrBatch.h" -void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const FrameArray& array, +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); + } + batch.fChildren.push_back(fCurrentBatch); + batch.fBounds = combiner->bounds(); +} + +void GrAuditTrail::batchingResultNew(GrBatch* batch) { + fIDLookup.set(batch, fBatches.count()); + fBatches.push_back(fCurrentBatch); +} + +template +void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const T& array, bool addComma) { if (array.count()) { if (addComma) { @@ -91,10 +118,14 @@ static SkString pretty_print_json(SkString json) { return prettyPrintJson.prettify(json); } -SkString GrAuditTrail::toJson(bool prettyPrint) const { +SkString GrAuditTrail::toJson(bool batchList, bool prettyPrint) const { SkString json; json.append("{"); - JsonifyTArray(&json, "Stacks", fFrames, false); + if (!batchList) { + JsonifyTArray(&json, "Stacks", fFrames, false); + } else { + JsonifyTArray(&json, "Batches", fBatches, false); + } json.append("}"); if (prettyPrint) { @@ -122,6 +153,7 @@ SkString GrAuditTrail::Batch::toJson() const { 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("}"); json.append("}"); return json; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index b9edabeafe..173617ebe6 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -460,6 +460,7 @@ void GrDrawTarget::recordBatch(GrBatch* batch) { if (candidate->combineIfPossible(batch, *this->caps())) { GrBATCH_INFO("\t\tCombining with (%s, B%u)\n", candidate->name(), candidate->uniqueID()); + GR_AUDIT_TRAIL_BATCHING_RESULT_COMBINED(fAuditTrail, candidate); return; } // Stop going backwards if we would cause a painter's order violation. @@ -479,6 +480,7 @@ void GrDrawTarget::recordBatch(GrBatch* batch) { } else { GrBATCH_INFO("\t\tFirstBatch\n"); } + GR_AUDIT_TRAIL_BATCHING_RESULT_NEW(fAuditTrail, batch); fBatches.push_back().reset(SkRef(batch)); } -- cgit v1.2.3