Chromium Code Reviews| Index: include/private/GrAuditTrail.h |
| diff --git a/include/private/GrAuditTrail.h b/include/private/GrAuditTrail.h |
| index 38730ede1aa491b3e30d8dc40fbfefbda3d259f9..f847b913b78140c94206c00a546fd1307ae8ce35 100644 |
| --- a/include/private/GrAuditTrail.h |
| +++ b/include/private/GrAuditTrail.h |
| @@ -42,11 +42,11 @@ public: |
| void pushFrame(const char* name) { |
| SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); |
| - Frame* frame; |
| + Frame* frame = new Frame; |
| if (fStack.empty()) { |
| - frame = &fFrames.push_back(); |
| + fFrames.emplace_back(frame); |
| } else { |
| - frame = &fStack.back()->fChildren.push_back(); |
| + fStack.back()->fChildren.emplace_back(frame); |
| } |
| frame->fUniqueID = fUniqueID++; |
| @@ -60,11 +60,11 @@ public: |
| } |
| void addBatch(const char* name, const SkRect& bounds) { |
| - // TODO when every internal callsite pushes a frame, we can add the assert |
| - SkASSERT(GR_BATCH_DEBUGGING_OUTPUT /*&& !fStack.empty()*/); |
| - Frame::Batch& batch = fStack.back()->fBatches.push_back(); |
| - batch.fName = name; |
| - batch.fBounds = bounds; |
| + SkASSERT(GR_BATCH_DEBUGGING_OUTPUT && !fStack.empty()); |
| + Batch* batch = new Batch; |
| + fStack.back()->fChildren.emplace_back(batch); |
| + batch->fName = name; |
| + batch->fBounds = bounds; |
| } |
| SkString toJson() const; |
| @@ -72,22 +72,26 @@ public: |
| void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT && fStack.empty()); fFrames.reset(); } |
| private: |
| - struct Frame { |
| - SkString toJson() const; |
| - struct Batch { |
| - SkString toJson() const; |
| - const char* fName; |
| - SkRect fBounds; |
| - }; |
| + // TODO if performance becomes an issue, we can move to using SkVarAlloc |
| + struct FrameBase { |
|
bsalomon
2016/01/14 14:57:28
Seems like this isn't really a Frame anymore... Ma
|
| + virtual ~FrameBase() {} |
| + virtual SkString toJson() const=0; |
| const char* fName; |
| - // TODO combine these into a single array |
| - SkTArray<Batch> fBatches; |
| - SkTArray<Frame> fChildren; |
| uint64_t fUniqueID; |
| }; |
| - SkTArray<Frame> fFrames; |
| + struct Frame : public FrameBase { |
| + SkString toJson() const override; |
| + SkTArray<SkAutoTDelete<FrameBase>, true> fChildren; |
| + }; |
| + |
| + struct Batch : public FrameBase { |
| + SkString toJson() const override; |
| + SkRect fBounds; |
| + }; |
| + |
| + SkTArray<SkAutoTDelete<FrameBase>, true> fFrames; |
|
bsalomon
2016/01/14 14:57:28
Fairly verbose type and you're using it as a param
|
| SkTArray<Frame*> fStack; |
| uint64_t fUniqueID; |
| }; |