Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: src/gpu/GrAuditTrail.cpp

Issue 1579193002: Convert GrAuditTrail to use scoped frames (Closed) Base URL: https://skia.googlesource.com/skia.git@audittrail-2-wireupbatchnames-andbounds
Patch Set: typo Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrAuditTrail.cpp
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp
index aa87af2cbde12c674ced1f9aea3f921df3f43416..1113017b2d3e2e201f7e832e4df01c7e752c8d39 100644
--- a/src/gpu/GrAuditTrail.cpp
+++ b/src/gpu/GrAuditTrail.cpp
@@ -8,12 +8,16 @@
#include "GrAuditTrail.h"
template <class T>
-static void jsonify_tarray(SkString* json, const SkTArray<T>& array) {
- for (int i = 0; i < array.count(); i++) {
- json->append(array[i].toJson());
- if (i < array.count() - 1) {
- json->append(",");
+static void jsonify_tarray(SkString* json, const char* name, const SkTArray<T>& array) {
+ if (array.count()) {
+ json->appendf("\"%s\": [", name);
+ for (int i = 0; i < array.count(); i++) {
+ json->append(array[i].toJson());
+ if (i < array.count() - 1) {
+ json->append(",");
+ }
}
+ json->append("]");
}
}
@@ -87,30 +91,27 @@ static SkString pretty_print_json(SkString json) {
SkString GrAuditTrail::toJson() const {
SkString json;
json.append("{");
- json.append("\"Ops\": [");
- jsonify_tarray(&json, fOps);
- json.append("]");
+ jsonify_tarray(&json, "Stacks", fFrames);
json.append("}");
// TODO if this becomes a performance issue we should make pretty print configurable
return pretty_print_json(json);
}
-SkString GrAuditTrail::Op::toJson() const {
+SkString GrAuditTrail::Frame::toJson() const {
SkString json;
json.append("{");
- json.appendf("\"Name\": \"%s\",", fName.c_str());
- json.append("\"Batches\": [");
- jsonify_tarray(&json, fBatches);
- json.append("]");
+ json.appendf("\"Name\": \"%s\",", fName);
+ jsonify_tarray(&json, "Batches", fBatches);
+ jsonify_tarray(&json, "Frames", fChildren);
json.append("}");
return json;
}
-SkString GrAuditTrail::Op::Batch::toJson() const {
+SkString GrAuditTrail::Frame::Batch::toJson() const {
SkString json;
json.append("{");
- json.appendf("\"Name\": \"%s\",", fName.c_str());
+ json.appendf("\"Name\": \"%s\",", fName);
json.append("\"Bounds\": {");
json.appendf("\"Left\": %f,", fBounds.fLeft);
json.appendf("\"Right\": %f,", fBounds.fRight);

Powered by Google App Engine
This is Rietveld 408576698