| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return; // can't require ctable if the dimensions are empty | 166 return; // can't require ctable if the dimensions are empty |
| 167 } | 167 } |
| 168 if (kIndex_8_SkColorType == info.colorType()) { | 168 if (kIndex_8_SkColorType == info.colorType()) { |
| 169 SkASSERT(ctable); | 169 SkASSERT(ctable); |
| 170 } else { | 170 } else { |
| 171 SkASSERT(NULL == ctable); | 171 SkASSERT(NULL == ctable); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl
e) { | 175 void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl
e) { |
| 176 #ifndef SK_IGNORE_PIXELREF_SETPRELOCKED | |
| 177 SkASSERT(pixels); | 176 SkASSERT(pixels); |
| 178 validate_pixels_ctable(fInfo, ctable); | 177 validate_pixels_ctable(fInfo, ctable); |
| 179 // only call me in your constructor, otherwise fLockCount tracking can get | 178 // only call me in your constructor, otherwise fLockCount tracking can get |
| 180 // out of sync. | 179 // out of sync. |
| 181 fRec.fPixels = pixels; | 180 fRec.fPixels = pixels; |
| 182 fRec.fColorTable = ctable; | 181 fRec.fColorTable = ctable; |
| 183 fRec.fRowBytes = rowBytes; | 182 fRec.fRowBytes = rowBytes; |
| 184 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; | 183 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; |
| 185 fPreLocked = true; | 184 fPreLocked = true; |
| 186 #endif | |
| 187 } | 185 } |
| 188 | 186 |
| 189 // Increments fLockCount only on success | 187 // Increments fLockCount only on success |
| 190 bool SkPixelRef::lockPixelsInsideMutex() { | 188 bool SkPixelRef::lockPixelsInsideMutex() { |
| 191 fMutex->assertHeld(); | 189 fMutex->assertHeld(); |
| 192 | 190 |
| 193 if (1 == ++fLockCount) { | 191 if (1 == ++fLockCount) { |
| 194 SkASSERT(fRec.isZero()); | 192 SkASSERT(fRec.isZero()); |
| 195 if (!this->onNewLockPixels(&fRec)) { | 193 if (!this->onNewLockPixels(&fRec)) { |
| 196 fRec.zero(); | 194 fRec.zero(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 403 } |
| 406 | 404 |
| 407 result->fUnlockProc = unlock_legacy_result; | 405 result->fUnlockProc = unlock_legacy_result; |
| 408 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc | 406 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc |
| 409 result->fCTable = fRec.fColorTable; | 407 result->fCTable = fRec.fColorTable; |
| 410 result->fPixels = fRec.fPixels; | 408 result->fPixels = fRec.fPixels; |
| 411 result->fRowBytes = fRec.fRowBytes; | 409 result->fRowBytes = fRec.fRowBytes; |
| 412 result->fSize.set(fInfo.width(), fInfo.height()); | 410 result->fSize.set(fInfo.width(), fInfo.height()); |
| 413 return true; | 411 return true; |
| 414 } | 412 } |
| OLD | NEW |