diff options
author | John Reck <jreck@google.com> | 2014-11-24 15:20:55 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-11-24 15:20:55 -0800 |
commit | d397b3c2abec5c4eeb7f922f85ad140bdf5d8c0c (patch) | |
tree | b0e381bcdefa4977467bae02b6ef321a8a2d4d1c | |
parent | aaf65dfe8b376ff10907a4db4d8883cc7fed5527 (diff) | |
download | skia-d397b3c2abec5c4eeb7f922f85ad140bdf5d8c0c.tar.gz |
Add stable ids to SkPixelRefandroid-5.1.1_r5android-5.1.1_r12lollipop-mr1-dev
Bug: 18245805
Change-Id: I62045238cb7c52d88a3eefe27dd04ec4a1f7dce0
-rw-r--r-- | include/core/SkPixelRef.h | 14 | ||||
-rw-r--r-- | src/core/SkPixelRef.cpp | 17 |
2 files changed, 29 insertions, 2 deletions
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 339cea192a..375b3eac6b 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -126,6 +126,17 @@ public: */ uint32_t getGenerationID() const; +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + /** Returns a non-zero, unique value corresponding to this SkPixelRef, + which is unchanged when the pixels are changed and even when this + object is deleted. + + Can be used as a key which must remain unique across changes and + deletions. + */ + uint32_t getStableID() const { return fStableID; } +#endif + /** * Call this if you have changed the contents of the pixels. This will in- * turn cause a different generation ID value to be returned from @@ -343,6 +354,9 @@ private: mutable uint32_t fGenerationID; mutable bool fUniqueGenerationID; +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + const uint32_t fStableID; +#endif SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owned diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index bfa4ae24d9..420d32e249 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -83,7 +83,12 @@ void SkPixelRef::setMutex(SkBaseMutex* mutex) { // just need a > 0 value, so pick a funny one to aid in debugging #define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789 -SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) { +SkPixelRef::SkPixelRef(const SkImageInfo& info) + : fInfo(info) +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + , fStableID(SkNextPixelRefGenerationID()) +#endif +{ this->setMutex(NULL); fRec.zero(); fLockCount = 0; @@ -93,7 +98,12 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) { } -SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(info) { +SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) + : fInfo(info) +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + , fStableID(SkNextPixelRefGenerationID()) +#endif +{ this->setMutex(mutex); fRec.zero(); fLockCount = 0; @@ -111,6 +121,9 @@ static SkImageInfo read_info(SkReadBuffer& buffer) { SkPixelRef::SkPixelRef(SkReadBuffer& buffer, SkBaseMutex* mutex) : INHERITED(buffer) , fInfo(read_info(buffer)) +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + , fStableID(SkNextPixelRefGenerationID()) +#endif { this->setMutex(mutex); fRec.zero(); |