mutable SkPixelRef* fPixelRef;
mutable int fPixelLockCount;
- // either user-specified (in which case it is not treated as mutable)
- // or a cache of the returned value from fPixelRef->lockPixels()
+ // These are just caches from the locked pixelref
mutable void* fPixels;
mutable SkColorTable* fColorTable; // only meaningful for kIndex8
// we reset our locks if we get blown away
fPixelLockCount = 0;
- /* The src could be in 3 states
- 1. no pixelref, in which case we just copy/ref the pixels/ctable
- 2. unlocked pixelref, pixels/ctable should be null
- 3. locked pixelref, we should lock the ref again ourselves
- */
- if (NULL == fPixelRef) {
- // leave fPixels as it is
- SkSafeRef(fColorTable); // ref the user's ctable if present
- } else { // we have a pixelref, so pixels/ctable reflect it
+ if (fPixelRef) {
// ignore the values from the memcpy
fPixels = NULL;
fColorTable = NULL;
+ fPixelRefOrigin.fX * fBytesPerPixel;
}
fPixels = p;
- SkRefCnt_SafeAssign(fColorTable, fPixelRef->colorTable());
+ fColorTable = fPixelRef->colorTable();
} else {
SkASSERT(0 == fPixelLockCount);
fPixels = NULL;
- if (fColorTable) {
- fColorTable->unref();
- fColorTable = NULL;
- }
+ fColorTable = NULL;
}
}
}
// if we're gonna free the pixels, we certainly need to free the mipmap
this->freeMipMap();
- if (fColorTable) {
- fColorTable->unref();
- fColorTable = NULL;
- }
-
if (NULL != fPixelRef) {
if (fPixelLockCount > 0) {
fPixelRef->unlockPixels();
}
fPixelLockCount = 0;
fPixels = NULL;
+ fColorTable = NULL;
}
void SkBitmap::freeMipMap() {
#endif
SkASSERT(fFlags <= allFlags);
SkASSERT(fPixelLockCount >= 0);
- SkASSERT(NULL == fColorTable || (unsigned)fColorTable->getRefCnt() < 10000);
SkASSERT((uint8_t)ComputeBytesPerPixel((Config)fConfig) == fBytesPerPixel);
if (fPixels) {