Ejemplo n.º 1
0
	MODULE_API void SqrDelete(void* pMem, CSqrAllocPool* pPool)
	{
		if(!pPool)
			pPool = GetGlobalPool();

		return pPool->Dealloc(pMem);
	}
Ejemplo n.º 2
0
	MODULE_API void* SqrChunkNew(size_t stSize, CSqrAllocPool* pPool)
	{
		if(!pPool)
			pPool = GetGlobalPool();

		return pPool->Alloc(stSize);
	}
Ejemplo n.º 3
0
	MODULE_API void* SqrChunkRenew(void* pMem,size_t stSize, CSqrAllocPool* pPool)
	{
		if(!pPool)
			pPool = GetGlobalPool();

		return pPool->Realloc(pMem,stSize);
	}
SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkStream* stream,
                                             SkBitmap::Config config,
                                             int sampleSize)
        : SkImageRef(stream, config, sampleSize) {
    this->mutex()->acquire();
    GetGlobalPool()->addToHead(this);
    this->mutex()->release();
}
/*  By design, onUnlockPixels() already is inside the mutex-lock,
 *  and it is the (indirect) caller of onDecode(), therefore we can assume
 *  that we also are already inside the mutex. Hence, we can reference
 *  the global-pool directly.
 */
bool SkImageRef_GlobalPool::onDecode(SkImageDecoder* codec, SkStream* stream,
                                     SkBitmap* bitmap, SkBitmap::Config config,
                                     SkImageDecoder::Mode mode) {
    if (!this->INHERITED::onDecode(codec, stream, bitmap, config, mode)) {
        return false;
    }
    if (mode == SkImageDecoder::kDecodePixels_Mode) {
        // no need to grab the mutex here, it has already been acquired.
        GetGlobalPool()->justAddedPixels(this);
    }
    return true;
}
void SkImageRef_GlobalPool::SetRAMUsed(size_t usage) {
    SkAutoMutexAcquire ac(gImageRefMutex);
    GetGlobalPool()->setRAMUsed(usage);
}
size_t SkImageRef_GlobalPool::GetRAMUsed() {
    SkAutoMutexAcquire ac(gImageRefMutex);    
    return GetGlobalPool()->getRAMUsed();
}
void SkImageRef_GlobalPool::SetRAMBudget(size_t size) {
    SkAutoMutexAcquire ac(gImageRefMutex);
    GetGlobalPool()->setRAMBudget(size);
}
SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkFlattenableReadBuffer& buffer)
        : INHERITED(buffer) {
    this->mutex()->acquire();
    GetGlobalPool()->addToHead(this);
    this->mutex()->release();
}
void SkImageRef_GlobalPool::onUnlockPixels() {
    this->INHERITED::onUnlockPixels();
    
    // by design, onUnlockPixels() already is inside the mutex-lock
    GetGlobalPool()->canLosePixels(this);
}
SkImageRef_GlobalPool::~SkImageRef_GlobalPool() {
    this->mutex()->acquire();
    GetGlobalPool()->detach(this);
    this->mutex()->release();
}
void SkImageRef_GlobalPool::DumpPool() {
    SkAutoMutexAcquire ac(gImageRefMutex);
    GetGlobalPool()->dump();
}