Expand SkMessageBus to support different unique key types
Bug: skia:11728
Change-Id: I16fb8250fa5c04ce3fe369a50d0c61a0bee46811
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/383696
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 4e08ecc..620e18c 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -37,7 +37,7 @@
// Generator has been freed, and no one is borrowing the texture. Notify the original cache
// that it can free the last ref, so it happens on the correct thread.
GrTextureFreedMessage msg { fOriginalTexture, fOwningContextID };
- SkMessageBus<GrTextureFreedMessage>::Post(msg);
+ SkMessageBus<GrTextureFreedMessage, uint32_t>::Post(msg);
}
std::unique_ptr<SkImageGenerator>
diff --git a/src/gpu/GrClientMappedBufferManager.cpp b/src/gpu/GrClientMappedBufferManager.cpp
index 1dd3860..10fa4d5 100644
--- a/src/gpu/GrClientMappedBufferManager.cpp
+++ b/src/gpu/GrClientMappedBufferManager.cpp
@@ -63,7 +63,7 @@
//////////////////////////////////////////////////////////////////////////////
-DECLARE_SKMESSAGEBUS_MESSAGE(GrClientMappedBufferManager::BufferFinishedMessage, false)
+DECLARE_SKMESSAGEBUS_MESSAGE(GrClientMappedBufferManager::BufferFinishedMessage, uint32_t, false)
bool SkShouldPostMessageToBus(const GrClientMappedBufferManager::BufferFinishedMessage& m,
uint32_t msgBusUniqueID) {
diff --git a/src/gpu/GrClientMappedBufferManager.h b/src/gpu/GrClientMappedBufferManager.h
index 20ef457..9ba0954 100644
--- a/src/gpu/GrClientMappedBufferManager.h
+++ b/src/gpu/GrClientMappedBufferManager.h
@@ -39,7 +39,7 @@
sk_sp<GrGpuBuffer> fBuffer;
uint32_t fInboxID;
};
- using BufferFinishedMessageBus = SkMessageBus<BufferFinishedMessage, false>;
+ using BufferFinishedMessageBus = SkMessageBus<BufferFinishedMessage, uint32_t, false>;
GrClientMappedBufferManager(uint32_t contextID);
GrClientMappedBufferManager(const GrClientMappedBufferManager&) = delete;
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 535538d..19722bb 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -51,7 +51,7 @@
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(this->singleOwner())
-GrDirectContext::DirectContextID GrDirectContext::DirectContextID::NextID() {
+GrDirectContext::DirectContextID GrDirectContext::DirectContextID::Next() {
static std::atomic<uint32_t> nextID{1};
uint32_t id;
do {
@@ -62,7 +62,7 @@
GrDirectContext::GrDirectContext(GrBackendApi backend, const GrContextOptions& options)
: INHERITED(GrContextThreadSafeProxyPriv::Make(backend, options))
- , fDirectContextID(DirectContextID::NextID()) {
+ , fDirectContextID(DirectContextID::Next()) {
}
GrDirectContext::~GrDirectContext() {
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index f0b09b9..ac22385 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -25,9 +25,9 @@
#include "src/gpu/GrTracing.h"
#include "src/gpu/SkGr.h"
-DECLARE_SKMESSAGEBUS_MESSAGE(GrUniqueKeyInvalidatedMessage, true);
+DECLARE_SKMESSAGEBUS_MESSAGE(GrUniqueKeyInvalidatedMessage, uint32_t, true);
-DECLARE_SKMESSAGEBUS_MESSAGE(GrTextureFreedMessage, true);
+DECLARE_SKMESSAGEBUS_MESSAGE(GrTextureFreedMessage, uint32_t, true);
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fSingleOwner)
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 2c13917..e1706a3 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -321,8 +321,8 @@
return res->cacheAccess().accessCacheIndex();
}
- typedef SkMessageBus<GrUniqueKeyInvalidatedMessage>::Inbox InvalidUniqueKeyInbox;
- typedef SkMessageBus<GrTextureFreedMessage>::Inbox FreedTextureInbox;
+ typedef SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Inbox InvalidUniqueKeyInbox;
+ typedef SkMessageBus<GrTextureFreedMessage, uint32_t>::Inbox FreedTextureInbox;
typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue;
typedef SkTDArray<GrGpuResource*> ResourceArray;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 6d85242..89220b3 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -69,7 +69,9 @@
public:
Listener(const GrUniqueKey& key, uint32_t contextUniqueID) : fMsg(key, contextUniqueID) {}
- void changed() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(fMsg); }
+ void changed() override {
+ SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Post(fMsg);
+ }
private:
GrUniqueKeyInvalidatedMessage fMsg;
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index 18c4e7f..4f16d80 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -13,7 +13,7 @@
static constexpr int kMaxKeyDataCountU32 = 256; // 1kB of uint32_t's.
-DECLARE_SKMESSAGEBUS_MESSAGE(sk_sp<GrCCPathCache::Key>, true);
+DECLARE_SKMESSAGEBUS_MESSAGE(sk_sp<GrCCPathCache::Key>, uint32_t, true);
static inline uint32_t next_path_cache_id() {
static std::atomic<uint32_t> gNextID(1);
@@ -89,7 +89,7 @@
void GrCCPathCache::Key::changed() {
// Our key's corresponding path was invalidated. Post a thread-safe eviction message.
- SkMessageBus<sk_sp<Key>>::Post(sk_ref_sp(this));
+ SkMessageBus<sk_sp<Key>, uint32_t>::Post(sk_ref_sp(this));
}
GrCCPathCache::GrCCPathCache(uint32_t contextUniqueID)
@@ -107,11 +107,11 @@
// Now take all the atlas textures we just invalidated and purge them from the GrResourceCache.
// We just purge via message bus since we don't have any access to the resource cache right now.
for (const sk_sp<GrTextureProxy>& proxy : fInvalidatedProxies) {
- SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
+ SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Post(
GrUniqueKeyInvalidatedMessage(proxy->getUniqueKey(), fContextUniqueID));
}
for (const GrUniqueKey& key : fInvalidatedProxyUniqueKeys) {
- SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
+ SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Post(
GrUniqueKeyInvalidatedMessage(key, fContextUniqueID));
}
}
diff --git a/src/gpu/ccpr/GrCCPathCache.h b/src/gpu/ccpr/GrCCPathCache.h
index ae9925c..6a521ae 100644
--- a/src/gpu/ccpr/GrCCPathCache.h
+++ b/src/gpu/ccpr/GrCCPathCache.h
@@ -172,7 +172,7 @@
SkTHashTable<HashNode, const Key&> fHashTable;
SkTInternalLList<GrCCPathCacheEntry> fLRU;
- SkMessageBus<sk_sp<Key>>::Inbox fInvalidatedKeysInbox;
+ SkMessageBus<sk_sp<Key>, uint32_t>::Inbox fInvalidatedKeysInbox;
sk_sp<Key> fScratchKey; // Reused for creating a temporary key in the find() method.
// We only read the clock once per flush, and cache it in this variable. This prevents us from
diff --git a/src/gpu/ops/GrTriangulatingPathRenderer.cpp b/src/gpu/ops/GrTriangulatingPathRenderer.cpp
index 495f96d..f3b9ef5 100644
--- a/src/gpu/ops/GrTriangulatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTriangulatingPathRenderer.cpp
@@ -89,7 +89,7 @@
private:
GrUniqueKeyInvalidatedMessage fMsg;
- void changed() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(fMsg); }
+ void changed() override { SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Post(fMsg); }
};
class StaticVertexAllocator : public GrEagerVertexAllocator {
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index de94501..e7cca26 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -7,7 +7,7 @@
#include "src/gpu/text/GrTextBlobCache.h"
-DECLARE_SKMESSAGEBUS_MESSAGE(GrTextBlobCache::PurgeBlobMessage, true)
+DECLARE_SKMESSAGEBUS_MESSAGE(GrTextBlobCache::PurgeBlobMessage, uint32_t, true)
// This function is captured by the above macro using implementations from SkMessageBus.h
static inline bool SkShouldPostMessageToBus(
@@ -75,7 +75,7 @@
void GrTextBlobCache::PostPurgeBlobMessage(uint32_t blobID, uint32_t cacheID) {
SkASSERT(blobID != SK_InvalidGenID);
- SkMessageBus<PurgeBlobMessage>::Post(PurgeBlobMessage(blobID, cacheID));
+ SkMessageBus<PurgeBlobMessage, uint32_t>::Post(PurgeBlobMessage(blobID, cacheID));
}
void GrTextBlobCache::purgeStaleBlobs() {
diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h
index 8e86092d..adff3b9 100644
--- a/src/gpu/text/GrTextBlobCache.h
+++ b/src/gpu/text/GrTextBlobCache.h
@@ -89,7 +89,7 @@
// In practice 'messageBusID' is always the unique ID of the owning GrContext
const uint32_t fMessageBusID;
- SkMessageBus<PurgeBlobMessage>::Inbox fPurgeBlobInbox SK_GUARDED_BY(fSpinLock);
+ SkMessageBus<PurgeBlobMessage, uint32_t>::Inbox fPurgeBlobInbox SK_GUARDED_BY(fSpinLock);
};
#endif