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);
GrBatch::GrBatch(uint32_t classID)
: fClassID(classID)
-#if GR_BATCH_SPEW
- , fUniqueID(GenBatchID())
-#endif
-{
+ , fUniqueID(kIllegalBatchID) {
SkDEBUGCODE(fUsed = false;)
}
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
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;
};