OLD | NEW |
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 #include "batches/GrBatch.h" | 9 #include "batches/GrBatch.h" |
10 | 10 |
11 const int GrAuditTrail::kGrAuditTrailInvalidID = -1; | 11 const int GrAuditTrail::kGrAuditTrailInvalidID = -1; |
12 | 12 |
13 void GrAuditTrail::addBatch(const char* name, const SkRect& bounds) { | 13 void GrAuditTrail::addBatch(const char* name, const SkRect& bounds) { |
14 SkASSERT(fEnabled); | 14 SkASSERT(fEnabled); |
15 Batch* batch = new Batch; | 15 Batch* batch = new Batch; |
16 fBatchPool.emplace_back(batch); | 16 fBatchPool.emplace_back(batch); |
17 batch->fName = name; | 17 batch->fName = name; |
18 batch->fBounds = bounds; | 18 batch->fBounds = bounds; |
19 batch->fClientID = kGrAuditTrailInvalidID; | 19 batch->fClientID = kGrAuditTrailInvalidID; |
20 batch->fBatchListID = kGrAuditTrailInvalidID; | 20 batch->fBatchListID = kGrAuditTrailInvalidID; |
21 batch->fChildID = kGrAuditTrailInvalidID; | 21 batch->fChildID = kGrAuditTrailInvalidID; |
| 22 |
| 23 // consume the current stack trace if any |
| 24 batch->fStackTrace = fCurrentStackTrace; |
| 25 fCurrentStackTrace.reset(); |
22 fCurrentBatch = batch; | 26 fCurrentBatch = batch; |
23 | 27 |
24 if (fClientID != kGrAuditTrailInvalidID) { | 28 if (fClientID != kGrAuditTrailInvalidID) { |
25 batch->fClientID = fClientID; | 29 batch->fClientID = fClientID; |
26 Batches** batchesLookup = fClientIDLookup.find(fClientID); | 30 Batches** batchesLookup = fClientIDLookup.find(fClientID); |
27 Batches* batches = nullptr; | 31 Batches* batches = nullptr; |
28 if (!batchesLookup) { | 32 if (!batchesLookup) { |
29 batches = new Batches; | 33 batches = new Batches; |
30 fClientIDLookup.set(fClientID, batches); | 34 fClientIDLookup.set(fClientID, batches); |
31 } else { | 35 } else { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 239 } |
236 | 240 |
237 SkString GrAuditTrail::Batch::toJson() const { | 241 SkString GrAuditTrail::Batch::toJson() const { |
238 SkString json; | 242 SkString json; |
239 json.append("{"); | 243 json.append("{"); |
240 json.appendf("\"Name\": \"%s\",", fName.c_str()); | 244 json.appendf("\"Name\": \"%s\",", fName.c_str()); |
241 json.appendf("\"ClientID\": \"%d\",", fClientID); | 245 json.appendf("\"ClientID\": \"%d\",", fClientID); |
242 json.appendf("\"BatchListID\": \"%d\",", fBatchListID); | 246 json.appendf("\"BatchListID\": \"%d\",", fBatchListID); |
243 json.appendf("\"ChildID\": \"%d\",", fChildID); | 247 json.appendf("\"ChildID\": \"%d\",", fChildID); |
244 skrect_to_json(&json, "Bounds", fBounds); | 248 skrect_to_json(&json, "Bounds", fBounds); |
| 249 if (fStackTrace.count()) { |
| 250 json.append(",\"Stack\": ["); |
| 251 for (int i = 0; i < fStackTrace.count(); i++) { |
| 252 json.appendf("\"%s\"", fStackTrace[i].c_str()); |
| 253 if (i < fStackTrace.count() - 1) { |
| 254 json.append(","); |
| 255 } |
| 256 } |
| 257 json.append("]"); |
| 258 } |
245 json.append("}"); | 259 json.append("}"); |
246 return json; | 260 return json; |
247 } | 261 } |
248 | 262 |
249 SkString GrAuditTrail::BatchNode::toJson() const { | 263 SkString GrAuditTrail::BatchNode::toJson() const { |
250 SkString json; | 264 SkString json; |
251 json.append("{"); | 265 json.append("{"); |
252 json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID); | 266 json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID); |
253 skrect_to_json(&json, "Bounds", fBounds); | 267 skrect_to_json(&json, "Bounds", fBounds); |
254 JsonifyTArray(&json, "Batches", fChildren, true); | 268 JsonifyTArray(&json, "Batches", fChildren, true); |
255 json.append("}"); | 269 json.append("}"); |
256 return json; | 270 return json; |
257 } | 271 } |
OLD | NEW |