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