fAddedToCache tidy up

Change-Id: I943dea5a60664ff9fdd93638efab2154c9a9ea30
Reviewed-on: https://skia-review.googlesource.com/c/162101
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Klein 2018-10-15 11:13:34 -04:00 committed by Skia Commit-Bot
parent 6e68376b99
commit 72fbfe8b3f

View File

@ -35,6 +35,7 @@ SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes)
, fHeight(height)
, fPixels(pixels)
, fRowBytes(rowBytes)
, fAddedToCache(false)
{
#ifdef SK_TRACE_PIXELREF_LIFETIME
SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter));
@ -42,7 +43,6 @@ SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes)
this->needsNewGenID();
fMutability = kMutable;
fAddedToCache.store(false);
}
SkPixelRef::~SkPixelRef() {
@ -102,10 +102,8 @@ void SkPixelRef::callGenIDChangeListeners() {
fGenIDChangeListeners[i]->onChange();
}
// TODO: SkAtomic could add "old_value = atomic.xchg(new_value)" to make this clearer.
if (fAddedToCache.load()) {
if (fAddedToCache.exchange(false)) {
SkNotifyBitmapGenIDIsStale(this->getGenerationID());
fAddedToCache.store(false);
}
}
// Listeners get at most one shot, so whether these triggered or not, blow them away.