| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return info.makeAlphaType(newAlphaType); | 89 return info.makeAlphaType(newAlphaType); |
| 90 } | 90 } |
| 91 | 91 |
| 92 #ifdef SK_TRACE_PIXELREF_LIFETIME | 92 #ifdef SK_TRACE_PIXELREF_LIFETIME |
| 93 static int32_t gInstCounter; | 93 static int32_t gInstCounter; |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 SkPixelRef::SkPixelRef(const SkImageInfo& info) | 96 SkPixelRef::SkPixelRef(const SkImageInfo& info) |
| 97 : fInfo(validate_info(info)) | 97 : fInfo(validate_info(info)) |
| 98 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 98 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 99 , fStableID(next_gen_id()) | 99 , fStableID(SkNextID::ImageID()) |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 { | 102 { |
| 103 #ifdef SK_TRACE_PIXELREF_LIFETIME | 103 #ifdef SK_TRACE_PIXELREF_LIFETIME |
| 104 SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter)); | 104 SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter)); |
| 105 #endif | 105 #endif |
| 106 this->setMutex(NULL); | 106 this->setMutex(NULL); |
| 107 fRec.zero(); | 107 fRec.zero(); |
| 108 fLockCount = 0; | 108 fLockCount = 0; |
| 109 this->needsNewGenID(); | 109 this->needsNewGenID(); |
| 110 fMutability = kMutable; | 110 fMutability = kMutable; |
| 111 fPreLocked = false; | 111 fPreLocked = false; |
| 112 fAddedToCache.store(false); | 112 fAddedToCache.store(false); |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) | 116 SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) |
| 117 : fInfo(validate_info(info)) | 117 : fInfo(validate_info(info)) |
| 118 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 118 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 119 , fStableID(next_gen_id()) | 119 , fStableID(SkNextID::ImageID()) |
| 120 #endif | 120 #endif |
| 121 { | 121 { |
| 122 #ifdef SK_TRACE_PIXELREF_LIFETIME | 122 #ifdef SK_TRACE_PIXELREF_LIFETIME |
| 123 SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter)); | 123 SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter)); |
| 124 #endif | 124 #endif |
| 125 this->setMutex(mutex); | 125 this->setMutex(mutex); |
| 126 fRec.zero(); | 126 fRec.zero(); |
| 127 fLockCount = 0; | 127 fLockCount = 0; |
| 128 this->needsNewGenID(); | 128 this->needsNewGenID(); |
| 129 fMutability = kMutable; | 129 fMutability = kMutable; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 403 } |
| 404 | 404 |
| 405 result->fUnlockProc = unlock_legacy_result; | 405 result->fUnlockProc = unlock_legacy_result; |
| 406 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc | 406 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr
oc |
| 407 result->fCTable = fRec.fColorTable; | 407 result->fCTable = fRec.fColorTable; |
| 408 result->fPixels = fRec.fPixels; | 408 result->fPixels = fRec.fPixels; |
| 409 result->fRowBytes = fRec.fRowBytes; | 409 result->fRowBytes = fRec.fRowBytes; |
| 410 result->fSize.set(fInfo.width(), fInfo.height()); | 410 result->fSize.set(fInfo.width(), fInfo.height()); |
| 411 return true; | 411 return true; |
| 412 } | 412 } |
| OLD | NEW |