aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrAuditTrail.cpp
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/gpu/GrAuditTrail.cpp
parent42701e98e1bc2815c78d793ab4567aeb58556c60 (diff)
Add batchlist managment to GrAuditTrail
Diffstat (limited to 'src/gpu/GrAuditTrail.cpp')
-rw-r--r--src/gpu/GrAuditTrail.cpp38
1 files changed, 35 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;