Purge GrTextBlobCache entries on SkTextBlob deletion
Similar to the SkImage purge mechanism.
Change-Id: I0b7fb1bad507a3c7f30a4f7514bedd894d1748ac
Reviewed-on: https://skia-review.googlesource.com/9631
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h
index 1d17f4d..956c6a0 100644
--- a/include/core/SkTextBlob.h
+++ b/include/core/SkTextBlob.h
@@ -9,6 +9,7 @@
#define SkTextBlob_DEFINED
#include "../private/SkTemplates.h"
+#include "../private/SkAtomics.h"
#include "SkPaint.h"
#include "SkString.h"
#include "SkRefCnt.h"
@@ -75,11 +76,19 @@
static unsigned ScalarsPerGlyph(GlyphPositioning pos);
+ // Call when this blob is part of the key to a cache entry. This allows the cache
+ // to know automatically those entries can be purged when this SkTextBlob is deleted.
+ void notifyAddedToCache() const {
+ fAddedToCache.store(true);
+ }
+
+ friend class GrTextBlobCache;
friend class SkTextBlobBuilder;
friend class SkTextBlobRunIterator;
- const SkRect fBounds;
- const uint32_t fUniqueID;
+ const SkRect fBounds;
+ const uint32_t fUniqueID;
+ mutable SkAtomic<bool> fAddedToCache;
SkDEBUGCODE(size_t fStorageSize;)