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 | 12 |
12 #ifdef SK_BUILD_FOR_WIN32 | 13 #ifdef SK_BUILD_FOR_WIN32 |
13 // We don't have SK_BASE_MUTEX_INIT on Windows. | 14 // We don't have SK_BASE_MUTEX_INIT on Windows. |
14 | 15 |
15 // must be a power-of-2. undef to just use 1 mutex | 16 // must be a power-of-2. undef to just use 1 mutex |
16 #define PIXELREF_MUTEX_RING_COUNT 32 | 17 #define PIXELREF_MUTEX_RING_COUNT 32 |
17 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT]; | 18 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT]; |
18 | 19 |
19 #else | 20 #else |
20 static SkBaseMutex gPixelRefMutexRing[] = { | 21 static SkBaseMutex gPixelRefMutexRing[] = { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 fRec.fRowBytes = rowBytes; | 149 fRec.fRowBytes = rowBytes; |
149 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; | 150 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; |
150 fPreLocked = true; | 151 fPreLocked = true; |
151 #endif | 152 #endif |
152 } | 153 } |
153 | 154 |
154 bool SkPixelRef::lockPixels(LockRec* rec) { | 155 bool SkPixelRef::lockPixels(LockRec* rec) { |
155 SkASSERT(!fPreLocked || SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount); | 156 SkASSERT(!fPreLocked || SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount); |
156 | 157 |
157 if (!fPreLocked) { | 158 if (!fPreLocked) { |
| 159 TRACE_EVENT_BEGIN0("skia", "SkPixelRef::lockPixelsMutex"); |
158 SkAutoMutexAcquire ac(*fMutex); | 160 SkAutoMutexAcquire ac(*fMutex); |
| 161 TRACE_EVENT_END0("skia", "SkPixelRef::lockPixelsMutex"); |
159 | 162 |
160 if (1 == ++fLockCount) { | 163 if (1 == ++fLockCount) { |
161 SkASSERT(fRec.isZero()); | 164 SkASSERT(fRec.isZero()); |
162 | 165 |
163 LockRec rec; | 166 LockRec rec; |
164 if (!this->onNewLockPixels(&rec)) { | 167 if (!this->onNewLockPixels(&rec)) { |
165 return false; | 168 return false; |
166 } | 169 } |
167 SkASSERT(!rec.isZero()); // else why did onNewLock return true? | 170 SkASSERT(!rec.isZero()); // else why did onNewLock return true? |
168 fRec = rec; | 171 fRec = rec; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 281 |
279 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 282 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
280 SkYUVColorSpace* colorSpace) { | 283 SkYUVColorSpace* colorSpace) { |
281 return false; | 284 return false; |
282 } | 285 } |
283 | 286 |
284 size_t SkPixelRef::getAllocatedSizeInBytes() const { | 287 size_t SkPixelRef::getAllocatedSizeInBytes() const { |
285 return 0; | 288 return 0; |
286 } | 289 } |
287 | 290 |
OLD | NEW |