aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-02-26 08:07:50 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-26 08:07:50 -0800
commit18d6b75829ac5d90050ca4da4f99292c14ff06f0 (patch)
tree1ce00eefc29ea25672aa81c96bae8074a85f2a37 /src
parent42701e98e1bc2815c78d793ab4567aeb58556c60 (diff)
Add batchlist managment to GrAuditTrail
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAuditTrail.cpp38
-rw-r--r--src/gpu/GrDrawTarget.cpp2
2 files changed, 37 insertions, 3 deletions
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 <typename T>
+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));
}