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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 * modifications will be lost when unlockPixels() is called.) | 120 * modifications will be lost when unlockPixels() is called.) |
121 */ | 121 */ |
122 bool lockPixelsAreWritable() const; | 122 bool lockPixelsAreWritable() const; |
123 | 123 |
124 /** Returns a non-zero, unique value corresponding to the pixels in this | 124 /** Returns a non-zero, unique value corresponding to the pixels in this |
125 pixelref. Each time the pixels are changed (and notifyPixelsChanged is | 125 pixelref. Each time the pixels are changed (and notifyPixelsChanged is |
126 called), a different generation ID will be returned. | 126 called), a different generation ID will be returned. |
127 */ | 127 */ |
128 uint32_t getGenerationID() const; | 128 uint32_t getGenerationID() const; |
129 | 129 |
| 130 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 131 /** Returns a non-zero, unique value corresponding to this SkPixelRef. |
| 132 Unlike the generation ID, this ID remains the same even when the pixels |
| 133 are changed. IDs are not reused (until uint32_t wraps), so it is safe |
| 134 to consider this ID unique even after this SkPixelRef is deleted. |
| 135 |
| 136 Can be used as a key which uniquely identifies this SkPixelRef |
| 137 regardless of changes to its pixels or deletion of this object. |
| 138 */ |
| 139 uint32_t getStableID() const { return fStableID; } |
| 140 #endif |
| 141 |
130 /** | 142 /** |
131 * Call this if you have changed the contents of the pixels. This will in- | 143 * Call this if you have changed the contents of the pixels. This will in- |
132 * turn cause a different generation ID value to be returned from | 144 * turn cause a different generation ID value to be returned from |
133 * getGenerationID(). | 145 * getGenerationID(). |
134 */ | 146 */ |
135 void notifyPixelsChanged(); | 147 void notifyPixelsChanged(); |
136 | 148 |
137 /** | 149 /** |
138 * Change the info's AlphaType. Note that this does not automatically | 150 * Change the info's AlphaType. Note that this does not automatically |
139 * invalidate the generation ID. If the pixel values themselves have | 151 * invalidate the generation ID. If the pixel values themselves have |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 363 |
352 // mostly const. fInfo.fAlpahType can be changed at runtime. | 364 // mostly const. fInfo.fAlpahType can be changed at runtime. |
353 const SkImageInfo fInfo; | 365 const SkImageInfo fInfo; |
354 | 366 |
355 // LockRec is only valid if we're in a locked state (isLocked()) | 367 // LockRec is only valid if we're in a locked state (isLocked()) |
356 LockRec fRec; | 368 LockRec fRec; |
357 int fLockCount; | 369 int fLockCount; |
358 | 370 |
359 mutable SkTRacy<uint32_t> fGenerationID; | 371 mutable SkTRacy<uint32_t> fGenerationID; |
360 mutable SkTRacy<bool> fUniqueGenerationID; | 372 mutable SkTRacy<bool> fUniqueGenerationID; |
| 373 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 374 const uint32_t fStableID; |
| 375 #endif |
361 | 376 |
362 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d | 377 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d |
363 | 378 |
364 SkString fURI; | 379 SkString fURI; |
365 | 380 |
366 // can go from false to true, but never from true to false | 381 // can go from false to true, but never from true to false |
367 bool fIsImmutable; | 382 bool fIsImmutable; |
368 // only ever set in constructor, const after that | 383 // only ever set in constructor, const after that |
369 bool fPreLocked; | 384 bool fPreLocked; |
370 | 385 |
(...skipping 15 matching lines...) Expand all Loading... |
386 /** | 401 /** |
387 * Allocate a new pixelref matching the specified ImageInfo, allocating | 402 * Allocate a new pixelref matching the specified ImageInfo, allocating |
388 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 403 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
389 * the pixelref will ref() the colortable. | 404 * the pixelref will ref() the colortable. |
390 * On failure return NULL. | 405 * On failure return NULL. |
391 */ | 406 */ |
392 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 407 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
393 }; | 408 }; |
394 | 409 |
395 #endif | 410 #endif |
OLD | NEW |