From 11fae87d39811882e3e99b4abc72c9713a38da55 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Thu, 14 Jan 2016 10:58:07 -0800 Subject: Virtualize Frames in GrAuditTrail BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1581943004 Review URL: https://codereview.chromium.org/1581943004 --- include/private/GrAuditTrail.h | 45 ++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'include/private') diff --git a/include/private/GrAuditTrail.h b/include/private/GrAuditTrail.h index 38730ede1a..fbaec84bb3 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,29 @@ 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 Event { + virtual ~Event() {} + virtual SkString toJson() const=0; const char* fName; - // TODO combine these into a single array - SkTArray fBatches; - SkTArray fChildren; uint64_t fUniqueID; }; - SkTArray fFrames; + typedef SkTArray, true> FrameArray; + struct Frame : public Event { + SkString toJson() const override; + FrameArray fChildren; + }; + + struct Batch : public Event { + SkString toJson() const override; + SkRect fBounds; + }; + + static void JsonifyTArray(SkString* json, const char* name, const FrameArray& array); + + FrameArray fFrames; SkTArray fStack; uint64_t fUniqueID; }; -- cgit v1.2.3