Chromium Code Reviews| 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 #ifndef GrAuditTrail_DEFINED | 8 #ifndef GrAuditTrail_DEFINED |
| 9 #define GrAuditTrail_DEFINED | 9 #define GrAuditTrail_DEFINED |
| 10 | 10 |
| 11 #include "GrConfig.h" | 11 #include "GrConfig.h" |
| 12 #include "SkRect.h" | |
| 12 #include "SkString.h" | 13 #include "SkString.h" |
| 13 #include "SkTArray.h" | 14 #include "SkTArray.h" |
| 14 | 15 |
| 15 /* | 16 /* |
| 16 * GrAuditTrail collects a list of draw ops, detailed information about those op s, and can dump them | 17 * GrAuditTrail collects a list of draw ops, detailed information about those op s, and can dump them |
| 17 * to json. | 18 * to json. |
| 18 */ | 19 */ |
| 19 class GrAuditTrail { | 20 class GrAuditTrail { |
| 20 public: | 21 public: |
| 21 void addOp(SkString name) { | 22 void addOp(SkString name) { |
| 22 SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); | 23 SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); |
| 23 fOps.push_back().fName = name; | 24 fOps.push_back().fName = name; |
| 24 } | 25 } |
| 25 | 26 |
|
robertphillips
2016/01/11 21:13:55
const SkString& name ?
| |
| 27 void addBatch(SkString name, const SkRect& bounds) { | |
| 28 SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); | |
| 29 Op::Batch& batch = fOps.back().fBatches.push_back(); | |
| 30 batch.fName = name; | |
| 31 batch.fBounds = bounds; | |
| 32 } | |
| 33 | |
| 26 SkString toJson() const; | 34 SkString toJson() const; |
| 27 | 35 |
| 28 void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); fOps.reset(); } | 36 void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); fOps.reset(); } |
| 29 | 37 |
| 30 private: | 38 private: |
| 31 struct Op { | 39 struct Op { |
| 32 SkString toJson() const; | 40 SkString toJson() const; |
| 41 struct Batch { | |
| 42 SkString toJson() const; | |
| 43 SkString fName; | |
| 44 SkRect fBounds; | |
| 45 }; | |
| 46 | |
| 33 SkString fName; | 47 SkString fName; |
| 48 SkTArray<Batch> fBatches; | |
| 34 }; | 49 }; |
| 35 | 50 |
| 36 SkTArray<Op> fOps; | 51 SkTArray<Op> fOps; |
| 37 }; | 52 }; |
| 38 | 53 |
| 39 #define GR_AUDIT_TRAIL_INVOKE_GUARD(invoke, ...) \ | 54 #define GR_AUDIT_TRAIL_INVOKE_GUARD(invoke, ...) \ |
| 40 if (GR_BATCH_DEBUGGING_OUTPUT) { \ | 55 if (GR_BATCH_DEBUGGING_OUTPUT) { \ |
| 41 invoke(__VA_ARGS__); \ | 56 invoke(__VA_ARGS__); \ |
| 42 } | 57 } |
| 43 | 58 |
| 44 | 59 |
| 45 #define GR_AUDIT_TRAIL_ADDOP(audit_trail, opname) \ | 60 #define GR_AUDIT_TRAIL_ADDOP(audit_trail, opname) \ |
|
robertphillips
2016/01/11 21:13:55
Do you want to check in this SkDebugf ?
| |
| 61 SkDebugf("%s\n", opname.c_str()); \ | |
| 46 GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addOp, opname); | 62 GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addOp, opname); |
| 47 | 63 |
| 48 #define GR_AUDIT_TRAIL_RESET(audit_trail) \ | 64 #define GR_AUDIT_TRAIL_RESET(audit_trail) \ |
| 49 GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->reset); | 65 GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->reset); |
| 50 | 66 |
| 67 #define GR_AUDIT_TRAIL_ADDBATCH(audit_trail, batchname, bounds) \ | |
| 68 GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addBatch, SkString(batchname), boun ds); | |
| 69 | |
| 70 | |
| 51 #endif | 71 #endif |
| OLD | NEW |