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 "SkPixelRef.h" | 9 #include "SkPixelRef.h" |
10 #include "SkThread.h" | 10 #include "SkThread.h" |
11 #include "SkTraceEvent.h" | 11 #include "SkTraceEvent.h" |
12 | 12 |
| 13 //#define SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT |
13 //#define SK_TRACE_PIXELREF_LIFETIME | 14 //#define SK_TRACE_PIXELREF_LIFETIME |
14 | 15 |
15 #ifdef SK_BUILD_FOR_WIN32 | 16 #ifdef SK_BUILD_FOR_WIN32 |
16 // We don't have SK_BASE_MUTEX_INIT on Windows. | 17 // We don't have SK_BASE_MUTEX_INIT on Windows. |
17 | 18 |
18 // must be a power-of-2. undef to just use 1 mutex | 19 // must be a power-of-2. undef to just use 1 mutex |
19 #define PIXELREF_MUTEX_RING_COUNT 32 | 20 #define PIXELREF_MUTEX_RING_COUNT 32 |
20 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT]; | 21 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT]; |
21 | 22 |
22 #else | 23 #else |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 this->setMutex(mutex); | 124 this->setMutex(mutex); |
124 fRec.zero(); | 125 fRec.zero(); |
125 fLockCount = 0; | 126 fLockCount = 0; |
126 this->needsNewGenID(); | 127 this->needsNewGenID(); |
127 fIsImmutable = false; | 128 fIsImmutable = false; |
128 fPreLocked = false; | 129 fPreLocked = false; |
129 fAddedToCache.store(false); | 130 fAddedToCache.store(false); |
130 } | 131 } |
131 | 132 |
132 SkPixelRef::~SkPixelRef() { | 133 SkPixelRef::~SkPixelRef() { |
| 134 #ifndef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT |
| 135 SkASSERT(SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount || 0 == fLockCount); |
| 136 #endif |
| 137 |
133 #ifdef SK_TRACE_PIXELREF_LIFETIME | 138 #ifdef SK_TRACE_PIXELREF_LIFETIME |
134 SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1); | 139 SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1); |
135 #endif | 140 #endif |
136 this->callGenIDChangeListeners(); | 141 this->callGenIDChangeListeners(); |
137 } | 142 } |
138 | 143 |
139 void SkPixelRef::needsNewGenID() { | 144 void SkPixelRef::needsNewGenID() { |
140 fTaggedGenID.store(0); | 145 fTaggedGenID.store(0); |
141 SkASSERT(!this->genIDIsUnique()); // This method isn't threadsafe, so the as
sert should be fine. | 146 SkASSERT(!this->genIDIsUnique()); // This method isn't threadsafe, so the as
sert should be fine. |
142 } | 147 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 301 |
297 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 302 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
298 SkYUVColorSpace* colorSpace) { | 303 SkYUVColorSpace* colorSpace) { |
299 return false; | 304 return false; |
300 } | 305 } |
301 | 306 |
302 size_t SkPixelRef::getAllocatedSizeInBytes() const { | 307 size_t SkPixelRef::getAllocatedSizeInBytes() const { |
303 return 0; | 308 return 0; |
304 } | 309 } |
305 | 310 |
OLD | NEW |