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

Side by Side Diff: src/gpu/GrAuditTrail.cpp

Issue 1704133002: fix comma in GrAuditTrail json (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « include/private/GrAuditTrail.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrAuditTrail.h" 8 #include "GrAuditTrail.h"
9 9
10 void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const FrameAr ray& array) { 10 void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const FrameAr ray& array,
11 bool addComma) {
11 if (array.count()) { 12 if (array.count()) {
13 if (addComma) {
14 json->appendf(",");
15 }
12 json->appendf("\"%s\": [", name); 16 json->appendf("\"%s\": [", name);
13 for (int i = 0; i < array.count(); i++) { 17 for (int i = 0; i < array.count(); i++) {
14 json->append(array[i]->toJson()); 18 json->append(array[i]->toJson());
15 if (i < array.count() - 1) { 19 if (i < array.count() - 1) {
16 json->append(","); 20 json->append(",");
17 } 21 }
18 } 22 }
19 json->append("]"); 23 json->append("]");
20 } 24 }
21 } 25 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 }; 87 };
84 88
85 static SkString pretty_print_json(SkString json) { 89 static SkString pretty_print_json(SkString json) {
86 class PrettyPrintJson prettyPrintJson; 90 class PrettyPrintJson prettyPrintJson;
87 return prettyPrintJson.prettify(json); 91 return prettyPrintJson.prettify(json);
88 } 92 }
89 93
90 SkString GrAuditTrail::toJson(bool prettyPrint) const { 94 SkString GrAuditTrail::toJson(bool prettyPrint) const {
91 SkString json; 95 SkString json;
92 json.append("{"); 96 json.append("{");
93 JsonifyTArray(&json, "Stacks", fFrames); 97 JsonifyTArray(&json, "Stacks", fFrames, false);
94 json.append("}"); 98 json.append("}");
95 99
96 if (prettyPrint) { 100 if (prettyPrint) {
97 return pretty_print_json(json); 101 return pretty_print_json(json);
98 } else { 102 } else {
99 return json; 103 return json;
100 } 104 }
101 } 105 }
102 106
103 SkString GrAuditTrail::Frame::toJson() const { 107 SkString GrAuditTrail::Frame::toJson() const {
104 SkString json; 108 SkString json;
105 json.append("{"); 109 json.append("{");
106 json.appendf("\"Name\": \"%s\",", fName); 110 json.appendf("\"Name\": \"%s\"", fName);
107 JsonifyTArray(&json, "Frames", fChildren); 111 JsonifyTArray(&json, "Frames", fChildren, true);
108 json.append("}"); 112 json.append("}");
109 return json; 113 return json;
110 } 114 }
111 115
112 SkString GrAuditTrail::Batch::toJson() const { 116 SkString GrAuditTrail::Batch::toJson() const {
113 SkString json; 117 SkString json;
114 json.append("{"); 118 json.append("{");
115 json.appendf("\"Name\": \"%s\",", fName); 119 json.appendf("\"Name\": \"%s\",", fName);
116 json.append("\"Bounds\": {"); 120 json.append("\"Bounds\": {");
117 json.appendf("\"Left\": %f,", fBounds.fLeft); 121 json.appendf("\"Left\": %f,", fBounds.fLeft);
118 json.appendf("\"Right\": %f,", fBounds.fRight); 122 json.appendf("\"Right\": %f,", fBounds.fRight);
119 json.appendf("\"Top\": %f,", fBounds.fTop); 123 json.appendf("\"Top\": %f,", fBounds.fTop);
120 json.appendf("\"Bottom\": %f", fBounds.fBottom); 124 json.appendf("\"Bottom\": %f", fBounds.fBottom);
121 json.append("}"); 125 json.append("}");
122 json.append("}"); 126 json.append("}");
123 return json; 127 return json;
124 } 128 }
OLDNEW
« no previous file with comments | « include/private/GrAuditTrail.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698