Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: src/gpu/batches/GrBatch.h

Issue 1772023003: Lazy init batch unique ID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/batches/GrBatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrBatch.h
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h
index b29c8a49b701ccccee3290233350f9ee1591877f..aae726eba95c4094462b3fa76e663100cc362b76 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;
};
« no previous file with comments | « no previous file | src/gpu/batches/GrBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698