void GrBufferAllocPool::reset() { VALIDATE(); fBytesInUse = 0; if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isLocked()) { buffer->unlock(); } } // fPreallocBuffersInUse will be decremented down to zero in the while loop int preallocBuffersInUse = fPreallocBuffersInUse; while (!fBlocks.empty()) { this->destroyBlock(); } if (fPreallocBuffers.count()) { // must set this after above loop. fPreallocBufferStartIdx = (fPreallocBufferStartIdx + preallocBuffersInUse) % fPreallocBuffers.count(); } // we may have created a large cpu mirror of a large VB. Reset the size // to match our pre-allocated VBs. fCpuData.reset(fMinBlockSize); SkASSERT(0 == fPreallocBuffersInUse); VALIDATE(); }
GrBufferAllocPool::~GrBufferAllocPool() { VALIDATE(); if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isLocked()) { buffer->unlock(); } } while (!fBlocks.empty()) { destroyBlock(); } fPreallocBuffers.unrefAll(); releaseGpuRef(); }
void GrBufferAllocPool::reset() { VALIDATE(); fBytesInUse = 0; if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isLocked()) { buffer->unlock(); } } while (!fBlocks.empty()) { destroyBlock(); } if (fPreallocBuffers.count()) { // must set this after above loop. fFirstPreallocBuffer = (fFirstPreallocBuffer + fPreallocBuffersInUse) % fPreallocBuffers.count(); } fCpuData.reset(fGpu->getCaps().fBufferLockSupport ? 0 : fMinBlockSize); GrAssert(0 == fPreallocBuffersInUse); VALIDATE(); }