diff options
author | joshualitt <joshualitt@chromium.org> | 2016-03-08 09:31:15 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 09:31:15 -0800 |
commit | 08e65e718a3464a594e6dfca0351dfed19ac2445 (patch) | |
tree | 713aa9ccd82ab8f90d8575ac3231550a47624d75 /src | |
parent | e6eaa320e8dac34396dc364aa0863574d7b5291c (diff) |
Lazy init batch unique ID
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1772023003
Review URL: https://codereview.chromium.org/1772023003
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/batches/GrBatch.cpp | 7 | ||||
-rw-r--r-- | src/gpu/batches/GrBatch.h | 14 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/gpu/batches/GrBatch.cpp b/src/gpu/batches/GrBatch.cpp index 8af1c1e088..900f889ff8 100644 --- a/src/gpu/batches/GrBatch.cpp +++ b/src/gpu/batches/GrBatch.cpp @@ -36,7 +36,7 @@ public: int32_t GrBatch::gCurrBatchClassID = GrBatch::kIllegalBatchID; -GrBATCH_SPEW(int32_t GrBatch::gCurrBatchUniqueID = GrBatch::kIllegalBatchID;) +int32_t GrBatch::gCurrBatchUniqueID = GrBatch::kIllegalBatchID; void* GrBatch::operator new(size_t size) { return MemoryPoolAccessor().pool()->allocate(size); @@ -48,10 +48,7 @@ void GrBatch::operator delete(void* target) { GrBatch::GrBatch(uint32_t classID) : fClassID(classID) -#if GR_BATCH_SPEW - , fUniqueID(GenBatchID()) -#endif -{ + , fUniqueID(kIllegalBatchID) { SkDEBUGCODE(fUsed = false;) } diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h index b29c8a49b7..aae726eba9 100644 --- a/src/gpu/batches/GrBatch.h +++ b/src/gpu/batches/GrBatch.h @@ -95,9 +95,13 @@ public: uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fClassID; } -#if GR_BATCH_SPEW - uint32_t uniqueID() const { return fUniqueID; } -#endif + // We lazily initialize the uniqueID because currently the only user is GrAuditTrail + uint32_t uniqueID() const { + if (kIllegalBatchID == fUniqueID) { + fUniqueID = GenBatchID(); + } + return fUniqueID; + } SkDEBUGCODE(bool isUsed() const { return fUsed; }) /** Called prior to drawing. The batch should perform any resource creation necessary to @@ -153,11 +157,9 @@ private: SkDEBUGCODE(bool fUsed;) const uint32_t fClassID; -#if GR_BATCH_SPEW static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } - const uint32_t fUniqueID; + mutable uint32_t fUniqueID; static int32_t gCurrBatchUniqueID; -#endif static int32_t gCurrBatchClassID; }; |