| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
| 9 #include "SkMutex.h" | 9 #include "SkMutex.h" |
| 10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 // We can't quite SkASSERT(this->genIDIsUnique()). It could be non-uniqu
e | 237 // We can't quite SkASSERT(this->genIDIsUnique()). It could be non-uniqu
e |
| 238 // if we got here via the else path (pretty unlikely, but possible). | 238 // if we got here via the else path (pretty unlikely, but possible). |
| 239 } | 239 } |
| 240 return id & ~1u; // Mask off bottom unique bit. | 240 return id & ~1u; // Mask off bottom unique bit. |
| 241 } | 241 } |
| 242 | 242 |
| 243 void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) { | 243 void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) { |
| 244 if (NULL == listener || !this->genIDIsUnique()) { | 244 if (NULL == listener || !this->genIDIsUnique()) { |
| 245 // No point in tracking this if we're not going to call it. | 245 // No point in tracking this if we're not going to call it. |
| 246 SkDELETE(listener); | 246 delete listener; |
| 247 return; | 247 return; |
| 248 } | 248 } |
| 249 *fGenIDChangeListeners.append() = listener; | 249 *fGenIDChangeListeners.append() = listener; |
| 250 } | 250 } |
| 251 | 251 |
| 252 // we need to be called *before* the genID gets changed or zerod | 252 // we need to be called *before* the genID gets changed or zerod |
| 253 void SkPixelRef::callGenIDChangeListeners() { | 253 void SkPixelRef::callGenIDChangeListeners() { |
| 254 // We don't invalidate ourselves if we think another SkPixelRef is sharing o
ur genID. | 254 // We don't invalidate ourselves if we think another SkPixelRef is sharing o
ur genID. |
| 255 if (this->genIDIsUnique()) { | 255 if (this->genIDIsUnique()) { |
| 256 for (int i = 0; i < fGenIDChangeListeners.count(); i++) { | 256 for (int i = 0; i < fGenIDChangeListeners.count(); i++) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 | 345 |
| 346 result->fUnlockProc = unlock_legacy_result; | 346 result->fUnlockProc = unlock_legacy_result; |
| 347 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc | 347 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc |
| 348 result->fCTable = fRec.fColorTable; | 348 result->fCTable = fRec.fColorTable; |
| 349 result->fPixels = fRec.fPixels; | 349 result->fPixels = fRec.fPixels; |
| 350 result->fRowBytes = fRec.fRowBytes; | 350 result->fRowBytes = fRec.fRowBytes; |
| 351 result->fSize.set(fInfo.width(), fInfo.height()); | 351 result->fSize.set(fInfo.width(), fInfo.height()); |
| 352 return true; | 352 return true; |
| 353 } | 353 } |
| OLD | NEW |