| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 private: | 312 private: |
| 313 SkBaseMutex* fMutex; // must remain in scope for the life of this object | 313 SkBaseMutex* fMutex; // must remain in scope for the life of this object |
| 314 | 314 |
| 315 // mostly const. fInfo.fAlpahType can be changed at runtime. | 315 // mostly const. fInfo.fAlpahType can be changed at runtime. |
| 316 const SkImageInfo fInfo; | 316 const SkImageInfo fInfo; |
| 317 | 317 |
| 318 // LockRec is only valid if we're in a locked state (isLocked()) | 318 // LockRec is only valid if we're in a locked state (isLocked()) |
| 319 LockRec fRec; | 319 LockRec fRec; |
| 320 int fLockCount; | 320 int fLockCount; |
| 321 | 321 |
| 322 mutable SkAtomic<uint32_t> fGenerationID; | 322 // Bottom bit indicates the Gen ID is unique. |
| 323 mutable SkAtomic<bool> fUniqueGenerationID; | 323 bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); } |
| 324 SkAtomic<bool> fAddedToCache; | 324 mutable SkAtomic<uint32_t> fTaggedGenID; |
| 325 |
| 325 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 326 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 326 const uint32_t fStableID; | 327 const uint32_t fStableID; |
| 327 #endif | 328 #endif |
| 328 | 329 |
| 329 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d | 330 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d |
| 330 | 331 |
| 331 SkString fURI; | 332 SkString fURI; |
| 332 | 333 |
| 334 // Set true by caches when they cache content that's derived from the curren
t pixels. |
| 335 SkAtomic<bool> fAddedToCache; |
| 333 // can go from false to true, but never from true to false | 336 // can go from false to true, but never from true to false |
| 334 bool fIsImmutable; | 337 bool fIsImmutable; |
| 335 // only ever set in constructor, const after that | 338 // only ever set in constructor, const after that |
| 336 bool fPreLocked; | 339 bool fPreLocked; |
| 337 | 340 |
| 338 void needsNewGenID(); | 341 void needsNewGenID(); |
| 339 void callGenIDChangeListeners(); | 342 void callGenIDChangeListeners(); |
| 340 | 343 |
| 341 void setMutex(SkBaseMutex* mutex); | 344 void setMutex(SkBaseMutex* mutex); |
| 342 | 345 |
| 343 // When copying a bitmap to another with the same shape and config, we can s
afely | 346 // When copying a bitmap to another with the same shape and config, we can s
afely |
| 344 // clone the pixelref generation ID too, which makes them equivalent under c
aching. | 347 // clone the pixelref generation ID too, which makes them equivalent under c
aching. |
| 345 friend class SkBitmap; // only for cloneGenID | 348 friend class SkBitmap; // only for cloneGenID |
| 346 void cloneGenID(const SkPixelRef&); | 349 void cloneGenID(const SkPixelRef&); |
| 347 | 350 |
| 348 typedef SkRefCnt INHERITED; | 351 typedef SkRefCnt INHERITED; |
| 349 }; | 352 }; |
| 350 | 353 |
| 351 class SkPixelRefFactory : public SkRefCnt { | 354 class SkPixelRefFactory : public SkRefCnt { |
| 352 public: | 355 public: |
| 353 /** | 356 /** |
| 354 * Allocate a new pixelref matching the specified ImageInfo, allocating | 357 * Allocate a new pixelref matching the specified ImageInfo, allocating |
| 355 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 358 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
| 356 * the pixelref will ref() the colortable. | 359 * the pixelref will ref() the colortable. |
| 357 * On failure return NULL. | 360 * On failure return NULL. |
| 358 */ | 361 */ |
| 359 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 362 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
| 360 }; | 363 }; |
| 361 | 364 |
| 362 #endif | 365 #endif |
| OLD | NEW |