diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-12-14 13:00:05 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-14 18:52:49 +0000 |
commit | 474d68791965f20f8e0dfa2bfb4d87300f1f29e0 (patch) | |
tree | 538b3b1687625848ced2a730dfa5fb8355a76e3e /include | |
parent | de2b95ea976afa55e6dd41e3ad24b092faa33ae2 (diff) |
Send TextBlobCache purge messages only to owning cache.
Bug: 703297
Change-Id: I95cdaa5bdebadd5ce88ae3ee468c59baa08353c6
Reviewed-on: https://skia-review.googlesource.com/85046
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkTextBlob.h | 10 | ||||
-rw-r--r-- | include/private/SkMessageBus.h | 17 | ||||
-rw-r--r-- | include/private/SkTArray.h | 2 |
3 files changed, 17 insertions, 12 deletions
diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h index 228747a1c8..b27ec87773 100644 --- a/include/core/SkTextBlob.h +++ b/include/core/SkTextBlob.h @@ -98,17 +98,17 @@ private: // 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); + void notifyAddedToCache(uint32_t cacheID) const { + fCacheID.store(cacheID); } friend class GrTextBlobCache; friend class SkTextBlobBuilder; friend class SkTextBlobRunIterator; - const SkRect fBounds; - const uint32_t fUniqueID; - mutable SkAtomic<bool> fAddedToCache; + const SkRect fBounds; + const uint32_t fUniqueID; + mutable SkAtomic<uint32_t> fCacheID; SkDEBUGCODE(size_t fStorageSize;) diff --git a/include/private/SkMessageBus.h b/include/private/SkMessageBus.h index 79f5c026dc..6ddf82c446 100644 --- a/include/private/SkMessageBus.h +++ b/include/private/SkMessageBus.h @@ -17,12 +17,14 @@ template <typename Message> class SkMessageBus : SkNoncopyable { public: - // Post a message to be received by all Inboxes for this Message type. Threadsafe. - static void Post(const Message& m); + // Post a message to be received by Inboxes for this Message type. Threadsafe. + // If id is SK_InvalidUniqueID then it will be sent to all inboxes. + // Otherwise it will be sent to the inbox with that id. + static void Post(const Message& m, uint32_t destID = SK_InvalidUniqueID); class Inbox { public: - Inbox(); + Inbox(uint32_t uniqueID = SK_InvalidUniqueID); ~Inbox(); // Overwrite out with all the messages we've received since the last call. Threadsafe. @@ -31,6 +33,7 @@ public: private: SkTArray<Message> fMessages; SkMutex fMessagesMutex; + uint32_t fUniqueID; friend class SkMessageBus; void receive(const Message& m); // SkMessageBus is a friend only to call this. @@ -58,7 +61,7 @@ private: // ----------------------- Implementation of SkMessageBus::Inbox ----------------------- template<typename Message> -SkMessageBus<Message>::Inbox::Inbox() { +SkMessageBus<Message>::Inbox::Inbox(uint32_t uniqueID) : fUniqueID(uniqueID) { // Register ourselves with the corresponding message bus. SkMessageBus<Message>* bus = SkMessageBus<Message>::Get(); SkAutoMutexAcquire lock(bus->fInboxesMutex); @@ -99,11 +102,13 @@ template <typename Message> SkMessageBus<Message>::SkMessageBus() {} template <typename Message> -/*static*/ void SkMessageBus<Message>::Post(const Message& m) { +/*static*/ void SkMessageBus<Message>::Post(const Message& m, uint32_t destID) { SkMessageBus<Message>* bus = SkMessageBus<Message>::Get(); SkAutoMutexAcquire lock(bus->fInboxesMutex); for (int i = 0; i < bus->fInboxes.count(); i++) { - bus->fInboxes[i]->receive(m); + if (SK_InvalidUniqueID == destID || bus->fInboxes[i]->fUniqueID == destID) { + bus->fInboxes[i]->receive(m); + } } } diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h index 9e0b954fbf..3f4cc429b4 100644 --- a/include/private/SkTArray.h +++ b/include/private/SkTArray.h @@ -441,7 +441,7 @@ private: if (!count && !reserveCount) { fAllocCount = 0; fMemArray = nullptr; - fOwnMemory = false; + fOwnMemory = true; fReserved = false; } else { fAllocCount = SkTMax(count, SkTMax(kMinHeapAllocCount, reserveCount)); |