| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | |
| 10 #ifndef SkPixelRef_DEFINED | 8 #ifndef SkPixelRef_DEFINED |
| 11 #define SkPixelRef_DEFINED | 9 #define SkPixelRef_DEFINED |
| 12 | 10 |
| 13 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 14 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
| 15 #include "SkString.h" | 13 #include "SkString.h" |
| 16 #include "SkFlattenable.h" | 14 #include "SkFlattenable.h" |
| 17 #include "SkImageInfo.h" | 15 #include "SkImageInfo.h" |
| 18 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 19 | 17 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 * modifications will be lost when unlockPixels() is called.) | 119 * modifications will be lost when unlockPixels() is called.) |
| 122 */ | 120 */ |
| 123 bool lockPixelsAreWritable() const; | 121 bool lockPixelsAreWritable() const; |
| 124 | 122 |
| 125 /** Returns a non-zero, unique value corresponding to the pixels in this | 123 /** Returns a non-zero, unique value corresponding to the pixels in this |
| 126 pixelref. Each time the pixels are changed (and notifyPixelsChanged is | 124 pixelref. Each time the pixels are changed (and notifyPixelsChanged is |
| 127 called), a different generation ID will be returned. | 125 called), a different generation ID will be returned. |
| 128 */ | 126 */ |
| 129 uint32_t getGenerationID() const; | 127 uint32_t getGenerationID() const; |
| 130 | 128 |
| 131 /** Call this if you have changed the contents of the pixels. This will in- | 129 /** |
| 132 turn cause a different generation ID value to be returned from | 130 * Call this if you have changed the contents of the pixels. This will in- |
| 133 getGenerationID(). | 131 * turn cause a different generation ID value to be returned from |
| 134 */ | 132 * getGenerationID(). |
| 135 void notifyPixelsChanged(); | 133 * |
| 134 * If the alphatype has also changed, specify its new value as well. If |
| 135 * the new pixels' alphatype is the same, this can be called with no |
| 136 * parameter. |
| 137 */ |
| 138 void notifyPixelsChanged(SkAlphaType); |
| 139 void notifyPixelsChanged() { |
| 140 this->notifyPixelsChanged(fInfo.fAlphaType); |
| 141 } |
| 136 | 142 |
| 137 /** Returns true if this pixelref is marked as immutable, meaning that the | 143 /** Returns true if this pixelref is marked as immutable, meaning that the |
| 138 contents of its pixels will not change for the lifetime of the pixelref. | 144 contents of its pixels will not change for the lifetime of the pixelref. |
| 139 */ | 145 */ |
| 140 bool isImmutable() const { return fIsImmutable; } | 146 bool isImmutable() const { return fIsImmutable; } |
| 141 | 147 |
| 142 /** Marks this pixelref is immutable, meaning that the contents of its | 148 /** Marks this pixelref is immutable, meaning that the contents of its |
| 143 pixels will not change for the lifetime of the pixelref. This state can | 149 pixels will not change for the lifetime of the pixelref. This state can |
| 144 be set on a pixelref, but it cannot be cleared once it is set. | 150 be set on a pixelref, but it cannot be cleared once it is set. |
| 145 */ | 151 */ |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 332 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| 327 | 333 |
| 328 // only call from constructor. Flags this to always be locked, removing | 334 // only call from constructor. Flags this to always be locked, removing |
| 329 // the need to grab the mutex and call onLockPixels/onUnlockPixels. | 335 // the need to grab the mutex and call onLockPixels/onUnlockPixels. |
| 330 // Performance tweak to avoid those calls (esp. in multi-thread use case). | 336 // Performance tweak to avoid those calls (esp. in multi-thread use case). |
| 331 void setPreLocked(void*, size_t rowBytes, SkColorTable*); | 337 void setPreLocked(void*, size_t rowBytes, SkColorTable*); |
| 332 | 338 |
| 333 private: | 339 private: |
| 334 SkBaseMutex* fMutex; // must remain in scope for the life of this object | 340 SkBaseMutex* fMutex; // must remain in scope for the life of this object |
| 335 | 341 |
| 342 // mostly const. fInfo.fAlpahType can be changed at runtime. |
| 336 const SkImageInfo fInfo; | 343 const SkImageInfo fInfo; |
| 337 | 344 |
| 338 // LockRec is only valid if we're in a locked state (isLocked()) | 345 // LockRec is only valid if we're in a locked state (isLocked()) |
| 339 LockRec fRec; | 346 LockRec fRec; |
| 340 int fLockCount; | 347 int fLockCount; |
| 341 | 348 |
| 342 mutable uint32_t fGenerationID; | 349 mutable uint32_t fGenerationID; |
| 343 mutable bool fUniqueGenerationID; | 350 mutable bool fUniqueGenerationID; |
| 344 | 351 |
| 345 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d | 352 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d |
| (...skipping 23 matching lines...) Expand all Loading... |
| 369 /** | 376 /** |
| 370 * Allocate a new pixelref matching the specified ImageInfo, allocating | 377 * Allocate a new pixelref matching the specified ImageInfo, allocating |
| 371 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 378 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
| 372 * the pixelref will ref() the colortable. | 379 * the pixelref will ref() the colortable. |
| 373 * On failure return NULL. | 380 * On failure return NULL. |
| 374 */ | 381 */ |
| 375 virtual SkPixelRef* create(const SkImageInfo&, SkColorTable*) = 0; | 382 virtual SkPixelRef* create(const SkImageInfo&, SkColorTable*) = 0; |
| 376 }; | 383 }; |
| 377 | 384 |
| 378 #endif | 385 #endif |
| OLD | NEW |