OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 #ifndef SkPixelRef_DEFINED | 8 #ifndef SkPixelRef_DEFINED |
9 #define SkPixelRef_DEFINED | 9 #define SkPixelRef_DEFINED |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 */ | 68 */ |
69 SkColorTable* colorTable() const { return fRec.fColorTable; } | 69 SkColorTable* colorTable() const { return fRec.fColorTable; } |
70 | 70 |
71 size_t rowBytes() const { return fRec.fRowBytes; } | 71 size_t rowBytes() const { return fRec.fRowBytes; } |
72 | 72 |
73 /** | 73 /** |
74 * To access the actual pixels of a pixelref, it must be "locked". | 74 * To access the actual pixels of a pixelref, it must be "locked". |
75 * Calling lockPixels returns a LockRec struct (on success). | 75 * Calling lockPixels returns a LockRec struct (on success). |
76 */ | 76 */ |
77 struct LockRec { | 77 struct LockRec { |
| 78 LockRec() : fPixels(NULL), fColorTable(NULL) {} |
| 79 |
78 void* fPixels; | 80 void* fPixels; |
79 SkColorTable* fColorTable; | 81 SkColorTable* fColorTable; |
80 size_t fRowBytes; | 82 size_t fRowBytes; |
81 | 83 |
82 void zero() { sk_bzero(this, sizeof(*this)); } | 84 void zero() { sk_bzero(this, sizeof(*this)); } |
83 | 85 |
84 bool isZero() const { | 86 bool isZero() const { |
85 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes; | 87 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes; |
86 } | 88 } |
87 }; | 89 }; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 SkData* refEncodedData() { | 194 SkData* refEncodedData() { |
193 return this->onRefEncodedData(); | 195 return this->onRefEncodedData(); |
194 } | 196 } |
195 | 197 |
196 struct LockRequest { | 198 struct LockRequest { |
197 SkISize fSize; | 199 SkISize fSize; |
198 SkFilterQuality fQuality; | 200 SkFilterQuality fQuality; |
199 }; | 201 }; |
200 | 202 |
201 struct LockResult { | 203 struct LockResult { |
| 204 LockResult() : fPixels(NULL), fCTable(NULL) {} |
| 205 |
202 void (*fUnlockProc)(void* ctx); | 206 void (*fUnlockProc)(void* ctx); |
203 void* fUnlockContext; | 207 void* fUnlockContext; |
204 | 208 |
| 209 const void* fPixels; |
205 SkColorTable* fCTable; // should be NULL unless colortype is kIndex8 | 210 SkColorTable* fCTable; // should be NULL unless colortype is kIndex8 |
206 const void* fPixels; | |
207 size_t fRowBytes; | 211 size_t fRowBytes; |
208 SkISize fSize; | 212 SkISize fSize; |
209 | 213 |
210 void unlock() { | 214 void unlock() { |
211 if (fUnlockProc) { | 215 if (fUnlockProc) { |
212 fUnlockProc(fUnlockContext); | 216 fUnlockProc(fUnlockContext); |
213 fUnlockProc = NULL; // can't unlock twice! | 217 fUnlockProc = NULL; // can't unlock twice! |
214 } | 218 } |
215 } | 219 } |
216 }; | 220 }; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 private: | 342 private: |
339 SkBaseMutex* fMutex; // must remain in scope for the life of this object | 343 SkBaseMutex* fMutex; // must remain in scope for the life of this object |
340 | 344 |
341 // mostly const. fInfo.fAlpahType can be changed at runtime. | 345 // mostly const. fInfo.fAlpahType can be changed at runtime. |
342 const SkImageInfo fInfo; | 346 const SkImageInfo fInfo; |
343 | 347 |
344 // LockRec is only valid if we're in a locked state (isLocked()) | 348 // LockRec is only valid if we're in a locked state (isLocked()) |
345 LockRec fRec; | 349 LockRec fRec; |
346 int fLockCount; | 350 int fLockCount; |
347 | 351 |
348 bool lockPixelsInsideMutex(LockRec* rec); | 352 bool lockPixelsInsideMutex(); |
349 | 353 |
350 // Bottom bit indicates the Gen ID is unique. | 354 // Bottom bit indicates the Gen ID is unique. |
351 bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); } | 355 bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); } |
352 mutable SkAtomic<uint32_t> fTaggedGenID; | 356 mutable SkAtomic<uint32_t> fTaggedGenID; |
353 | 357 |
354 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 358 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
355 const uint32_t fStableID; | 359 const uint32_t fStableID; |
356 #endif | 360 #endif |
357 | 361 |
358 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d | 362 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d |
(...skipping 25 matching lines...) Expand all Loading... |
384 /** | 388 /** |
385 * Allocate a new pixelref matching the specified ImageInfo, allocating | 389 * Allocate a new pixelref matching the specified ImageInfo, allocating |
386 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 390 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
387 * the pixelref will ref() the colortable. | 391 * the pixelref will ref() the colortable. |
388 * On failure return NULL. | 392 * On failure return NULL. |
389 */ | 393 */ |
390 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 394 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
391 }; | 395 }; |
392 | 396 |
393 #endif | 397 #endif |
OLD | NEW |