diff options
author | joshualitt <joshualitt@chromium.org> | 2016-03-01 07:47:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-01 07:47:56 -0800 |
commit | df3f2b0948507d20e72b16869f1b2bb1abdf4b40 (patch) | |
tree | cb68b767ae0cd3427e6d2275a57308752b49a892 /src | |
parent | bb7b043b2db64197d2f6a1edaf3562a50c77afb1 (diff) |
Move some GrAuditTrail fuctions to cpp file
TBR=ethannicholas@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1753753002
Review URL: https://codereview.chromium.org/1753753002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAuditTrail.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp index 6b20876807..d46387315e 100644 --- a/src/gpu/GrAuditTrail.cpp +++ b/src/gpu/GrAuditTrail.cpp @@ -10,6 +10,32 @@ const int GrAuditTrail::kGrAuditTrailInvalidID = -1; +void GrAuditTrail::addBatch(const char* name, const SkRect& bounds) { + SkASSERT(fEnabled); + Batch* batch = new Batch; + fBatchPool.emplace_back(batch); + batch->fName = name; + batch->fBounds = bounds; + batch->fClientID = kGrAuditTrailInvalidID; + batch->fBatchListID = kGrAuditTrailInvalidID; + batch->fChildID = kGrAuditTrailInvalidID; + fCurrentBatch = batch; + + if (fClientID != kGrAuditTrailInvalidID) { + batch->fClientID = fClientID; + Batches** batchesLookup = fClientIDLookup.find(fClientID); + Batches* batches = nullptr; + if (!batchesLookup) { + batches = new Batches; + fClientIDLookup.set(fClientID, batches); + } else { + batches = *batchesLookup; + } + + batches->push_back(fCurrentBatch); + } +} + void GrAuditTrail::batchingResultCombined(GrBatch* combiner) { int* indexPtr = fIDLookup.find(combiner); SkASSERT(indexPtr); @@ -75,6 +101,15 @@ void GrAuditTrail::getBoundsByClientID(SkTArray<BatchInfo>* outInfo, int clientI } } +void GrAuditTrail::fullReset() { + SkASSERT(fEnabled); + fBatchList.reset(); + fIDLookup.reset(); + // free all client batches + fClientIDLookup.foreach([](const int&, Batches** batches) { delete *batches; }); + fClientIDLookup.reset(); + fBatchPool.reset(); // must be last, frees all of the memory +} template <typename T> void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const T& array, |