aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrAuditTrail.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-01-12 12:59:28 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-12 12:59:28 -0800
commit87a721b2465c9ccfa191ce9f5012f92be7731fbc (patch)
tree3c7e0027d940d01fdde1139a305b5348d7ef36be /src/gpu/GrAuditTrail.cpp
parent61a237e319a63b7ed6d38c2f3cd9b597816c3a46 (diff)
Convert GrAuditTrail to use scoped frames
Diffstat (limited to 'src/gpu/GrAuditTrail.cpp')
-rw-r--r--src/gpu/GrAuditTrail.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp
index aa87af2cbd..1113017b2d 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);