void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctable) { SkASSERT(pixels); validate_pixels_ctable(fInfo, ctable); // only call me in your constructor, otherwise fLockCount tracking can get // out of sync. fRec.fPixels = pixels; fRec.fColorTable = ctable; fRec.fRowBytes = rowBytes; fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; fPreLocked = true; }
// Increments fLockCount only on success bool SkPixelRef::lockPixelsInsideMutex() { fMutex->assertHeld(); if (1 == ++fLockCount) { SkASSERT(fRec.isZero()); if (!this->onNewLockPixels(&fRec)) { fRec.zero(); fLockCount -= 1; // we return fLockCount unchanged if we fail. return false; } } validate_pixels_ctable(fInfo, fRec.fPixels, fRec.fColorTable); return fRec.fPixels != NULL; }