diff --git a/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h index 6df48de128..022bad53d9 100644 --- a/include/gpu/GrDirectContext.h +++ b/include/gpu/GrDirectContext.h @@ -793,7 +793,7 @@ public: class DirectContextID { public: - static GrDirectContext::DirectContextID NextID(); + static GrDirectContext::DirectContextID Next(); DirectContextID() : fID(SK_InvalidUniqueID) {} diff --git a/src/core/SkMessageBus.h b/src/core/SkMessageBus.h index c6fe957d34..bbbf06a858 100644 --- a/src/core/SkMessageBus.h +++ b/src/core/SkMessageBus.h @@ -21,12 +21,13 @@ /** * The following method must have a specialization for type 'Message': * - * bool SkShouldPostMessageToBus(const Message&, uint32_t msgBusUniqueID) + * bool SkShouldPostMessageToBus(const Message&, IDType msgBusUniqueID) * * We may want to consider providing a default template implementation, to avoid this requirement by * sending to all inboxes when the specialization for type 'Message' is not present. */ -template class SkMessageBus : SkNoncopyable { +template +class SkMessageBus : SkNoncopyable { public: template struct is_sk_sp : std::false_type {}; template struct is_sk_sp> : std::true_type {}; @@ -43,18 +44,18 @@ public: class Inbox { public: - Inbox(uint32_t uniqueID = SK_InvalidUniqueID); + Inbox(IDType uniqueID); ~Inbox(); - uint32_t uniqueID() const { return fUniqueID; } + IDType uniqueID() const { return fUniqueID; } // Overwrite out with all the messages we've received since the last call. Threadsafe. void poll(SkTArray* out); private: - SkTArray fMessages; - SkMutex fMessagesMutex; - const uint32_t fUniqueID; + SkTArray fMessages; + SkMutex fMessagesMutex; + const IDType fUniqueID; friend class SkMessageBus; void receive(Message m); // SkMessageBus is a friend only to call this. @@ -70,30 +71,31 @@ private: // This must go in a single .cpp file, not some .h, or we risk creating more than one global // SkMessageBus per type when using shared libraries. NOTE: at most one per file will compile. -#define DECLARE_SKMESSAGEBUS_MESSAGE(Message, AllowCopyableMessage) \ - template <> \ - SkMessageBus* \ - SkMessageBus::Get() { \ - static SkOnce once; \ - static SkMessageBus* bus; \ - once([] { bus = new SkMessageBus(); }); \ - return bus; \ +#define DECLARE_SKMESSAGEBUS_MESSAGE(Message, IDType, AllowCopyableMessage) \ + template <> \ + SkMessageBus* \ + SkMessageBus::Get() { \ + static SkOnce once; \ + static SkMessageBus* bus; \ + once([] { bus = new SkMessageBus(); }); \ + return bus; \ } // ----------------------- Implementation of SkMessageBus::Inbox ----------------------- -template -SkMessageBus::Inbox::Inbox(uint32_t uniqueID) : fUniqueID(uniqueID) { +template +SkMessageBus::Inbox::Inbox(IDType uniqueID) + : fUniqueID(uniqueID) { // Register ourselves with the corresponding message bus. - auto* bus = SkMessageBus::Get(); + auto* bus = SkMessageBus::Get(); SkAutoMutexExclusive lock(bus->fInboxesMutex); bus->fInboxes.push_back(this); } -template -SkMessageBus::Inbox::~Inbox() { +template +SkMessageBus::Inbox::~Inbox() { // Remove ourselves from the corresponding message bus. - auto* bus = SkMessageBus::Get(); + auto* bus = SkMessageBus::Get(); SkAutoMutexExclusive lock(bus->fInboxesMutex); // This is a cheaper fInboxes.remove(fInboxes.find(this)) when order doesn't matter. for (int i = 0; i < bus->fInboxes.count(); i++) { @@ -104,14 +106,14 @@ SkMessageBus::Inbox::~Inbox() { } } -template -void SkMessageBus::Inbox::receive(Message m) { +template +void SkMessageBus::Inbox::receive(Message m) { SkAutoMutexExclusive lock(fMessagesMutex); fMessages.push_back(std::move(m)); } -template -void SkMessageBus::Inbox::poll(SkTArray* messages) { +template +void SkMessageBus::Inbox::poll(SkTArray* messages) { SkASSERT(messages); messages->reset(); SkAutoMutexExclusive lock(fMessagesMutex); @@ -120,12 +122,12 @@ void SkMessageBus::Inbox::poll(SkTArray* // ----------------------- Implementation of SkMessageBus ----------------------- -template -SkMessageBus::SkMessageBus() = default; +template +SkMessageBus::SkMessageBus() = default; -template -/*static*/ void SkMessageBus::Post(Message m) { - auto* bus = SkMessageBus::Get(); +template +/*static*/ void SkMessageBus::Post(Message m) { + auto* bus = SkMessageBus::Get(); SkAutoMutexExclusive lock(bus->fInboxesMutex); for (int i = 0; i < bus->fInboxes.count(); i++) { if (SkShouldPostMessageToBus(m, bus->fInboxes[i]->fUniqueID)) { diff --git a/src/core/SkPromiseImageTexture.cpp b/src/core/SkPromiseImageTexture.cpp index 6d627f5ced..e14f2172d0 100644 --- a/src/core/SkPromiseImageTexture.cpp +++ b/src/core/SkPromiseImageTexture.cpp @@ -20,7 +20,7 @@ SkPromiseImageTexture::SkPromiseImageTexture(const GrBackendTexture& backendText SkPromiseImageTexture::~SkPromiseImageTexture() { for (const auto& msg : fMessages) { - SkMessageBus::Post(msg); + SkMessageBus::Post(msg); } } diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp index ae100a4d18..016c38cdc1 100644 --- a/src/core/SkResourceCache.cpp +++ b/src/core/SkResourceCache.cpp @@ -19,7 +19,7 @@ #include #include -DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage, true) +DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage, uint32_t, true) static inline bool SkShouldPostMessageToBus( const SkResourceCache::PurgeSharedIDMessage&, uint32_t) { @@ -91,12 +91,14 @@ void SkResourceCache::init() { fDiscardableFactory = nullptr; } -SkResourceCache::SkResourceCache(DiscardableFactory factory) { +SkResourceCache::SkResourceCache(DiscardableFactory factory) + : fPurgeSharedIDInbox(SK_InvalidUniqueID) { this->init(); fDiscardableFactory = factory; } -SkResourceCache::SkResourceCache(size_t byteLimit) { +SkResourceCache::SkResourceCache(size_t byteLimit) + : fPurgeSharedIDInbox(SK_InvalidUniqueID) { this->init(); fTotalByteLimit = byteLimit; } @@ -542,7 +544,7 @@ void SkResourceCache::VisitAll(Visitor visitor, void* context) { void SkResourceCache::PostPurgeSharedID(uint64_t sharedID) { if (sharedID) { - SkMessageBus::Post(PurgeSharedIDMessage(sharedID)); + SkMessageBus::Post(PurgeSharedIDMessage(sharedID)); } } diff --git a/src/core/SkResourceCache.h b/src/core/SkResourceCache.h index c59e95da8e..a0cc75434b 100644 --- a/src/core/SkResourceCache.h +++ b/src/core/SkResourceCache.h @@ -271,7 +271,7 @@ private: size_t fSingleAllocationByteLimit; int fCount; - SkMessageBus::Inbox fPurgeSharedIDInbox; + SkMessageBus::Inbox fPurgeSharedIDInbox; void checkMessages(); void purgeAsNeeded(bool forcePurge = false); diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index 4e08ecc4aa..620e18c1ee 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -37,7 +37,7 @@ GrBackendTextureImageGenerator::RefHelper::~RefHelper() { // 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::Post(msg); + SkMessageBus::Post(msg); } std::unique_ptr diff --git a/src/gpu/GrClientMappedBufferManager.cpp b/src/gpu/GrClientMappedBufferManager.cpp index 1dd3860cb7..10fa4d50f9 100644 --- a/src/gpu/GrClientMappedBufferManager.cpp +++ b/src/gpu/GrClientMappedBufferManager.cpp @@ -63,7 +63,7 @@ void GrClientMappedBufferManager::remove(const sk_sp& b) { ////////////////////////////////////////////////////////////////////////////// -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 20ef457f44..9ba0954ce6 100644 --- a/src/gpu/GrClientMappedBufferManager.h +++ b/src/gpu/GrClientMappedBufferManager.h @@ -39,7 +39,7 @@ public: sk_sp fBuffer; uint32_t fInboxID; }; - using BufferFinishedMessageBus = SkMessageBus; + using BufferFinishedMessageBus = SkMessageBus; GrClientMappedBufferManager(uint32_t contextID); GrClientMappedBufferManager(const GrClientMappedBufferManager&) = delete; diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index 535538d878..19722bbf65 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 nextID{1}; uint32_t id; do { @@ -62,7 +62,7 @@ GrDirectContext::DirectContextID GrDirectContext::DirectContextID::NextID() { 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 f0b09b9421..ac2238527f 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 2c13917aea..e1706a3483 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -321,8 +321,8 @@ private: return res->cacheAccess().accessCacheIndex(); } - typedef SkMessageBus::Inbox InvalidUniqueKeyInbox; - typedef SkMessageBus::Inbox FreedTextureInbox; + typedef SkMessageBus::Inbox InvalidUniqueKeyInbox; + typedef SkMessageBus::Inbox FreedTextureInbox; typedef SkTDPQueue PurgeableQueue; typedef SkTDArray ResourceArray; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 6d85242dbe..89220b3b3e 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -69,7 +69,9 @@ sk_sp GrMakeUniqueKeyInvalidationListener(GrUniqueKey* key, public: Listener(const GrUniqueKey& key, uint32_t contextUniqueID) : fMsg(key, contextUniqueID) {} - void changed() override { SkMessageBus::Post(fMsg); } + void changed() override { + SkMessageBus::Post(fMsg); + } private: GrUniqueKeyInvalidatedMessage fMsg; diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp index 18c4e7f02c..4f16d80de2 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, true); +DECLARE_SKMESSAGEBUS_MESSAGE(sk_sp, uint32_t, true); static inline uint32_t next_path_cache_id() { static std::atomic gNextID(1); @@ -89,7 +89,7 @@ uint32_t* GrCCPathCache::Key::data() { void GrCCPathCache::Key::changed() { // Our key's corresponding path was invalidated. Post a thread-safe eviction message. - SkMessageBus>::Post(sk_ref_sp(this)); + SkMessageBus, uint32_t>::Post(sk_ref_sp(this)); } GrCCPathCache::GrCCPathCache(uint32_t contextUniqueID) @@ -107,11 +107,11 @@ GrCCPathCache::~GrCCPathCache() { // 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& proxy : fInvalidatedProxies) { - SkMessageBus::Post( + SkMessageBus::Post( GrUniqueKeyInvalidatedMessage(proxy->getUniqueKey(), fContextUniqueID)); } for (const GrUniqueKey& key : fInvalidatedProxyUniqueKeys) { - SkMessageBus::Post( + SkMessageBus::Post( GrUniqueKeyInvalidatedMessage(key, fContextUniqueID)); } } diff --git a/src/gpu/ccpr/GrCCPathCache.h b/src/gpu/ccpr/GrCCPathCache.h index ae9925cfc9..6a521ae863 100644 --- a/src/gpu/ccpr/GrCCPathCache.h +++ b/src/gpu/ccpr/GrCCPathCache.h @@ -172,7 +172,7 @@ private: SkTHashTable fHashTable; SkTInternalLList fLRU; - SkMessageBus>::Inbox fInvalidatedKeysInbox; + SkMessageBus, uint32_t>::Inbox fInvalidatedKeysInbox; sk_sp 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 495f96d459..f3b9ef5367 100644 --- a/src/gpu/ops/GrTriangulatingPathRenderer.cpp +++ b/src/gpu/ops/GrTriangulatingPathRenderer.cpp @@ -89,7 +89,7 @@ public: private: GrUniqueKeyInvalidatedMessage fMsg; - void changed() override { SkMessageBus::Post(fMsg); } + void changed() override { SkMessageBus::Post(fMsg); } }; class StaticVertexAllocator : public GrEagerVertexAllocator { diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp index de9450101d..e7cca260b9 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::freeAll() { void GrTextBlobCache::PostPurgeBlobMessage(uint32_t blobID, uint32_t cacheID) { SkASSERT(blobID != SK_InvalidGenID); - SkMessageBus::Post(PurgeBlobMessage(blobID, cacheID)); + SkMessageBus::Post(PurgeBlobMessage(blobID, cacheID)); } void GrTextBlobCache::purgeStaleBlobs() { diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h index 8e86092d12..adff3b9ee4 100644 --- a/src/gpu/text/GrTextBlobCache.h +++ b/src/gpu/text/GrTextBlobCache.h @@ -89,7 +89,7 @@ private: // In practice 'messageBusID' is always the unique ID of the owning GrContext const uint32_t fMessageBusID; - SkMessageBus::Inbox fPurgeBlobInbox SK_GUARDED_BY(fSpinLock); + SkMessageBus::Inbox fPurgeBlobInbox SK_GUARDED_BY(fSpinLock); }; #endif diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp index 840c6bcee4..ecaabbbbe1 100644 --- a/src/image/SkImage_GpuBase.cpp +++ b/src/image/SkImage_GpuBase.cpp @@ -259,7 +259,7 @@ sk_sp SkImage_GpuBase::MakePromiseImageLazyProxy( // In the future the GrSurface class hierarchy refactoring should eliminate this // difficulty by removing the virtual inheritance. if (fTexture) { - SkMessageBus::Post({fTexture, fTextureContextID}); + SkMessageBus::Post({fTexture, fTextureContextID}); } } diff --git a/tests/GrThreadSafeCacheTest.cpp b/tests/GrThreadSafeCacheTest.cpp index 7e459b0cb4..10601ee8c6 100644 --- a/tests/GrThreadSafeCacheTest.cpp +++ b/tests/GrThreadSafeCacheTest.cpp @@ -1431,7 +1431,7 @@ static void test_15(GrDirectContext* dContext, skiatest::Reporter* reporter, GrUniqueKeyInvalidatedMessage msg(key, dContext->priv().contextID(), /* inThreadSafeCache */ true); - SkMessageBus::Post(msg); + SkMessageBus::Post(msg); // This purge call is needed to process the invalidation messages dContext->purgeUnlockedResources(/* scratchResourcesOnly */ true); diff --git a/tests/MessageBusTest.cpp b/tests/MessageBusTest.cpp index 7d15e5d8f2..31716118dc 100644 --- a/tests/MessageBusTest.cpp +++ b/tests/MessageBusTest.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "include/gpu/GrDirectContext.h" #include "src/core/SkMessageBus.h" #include "tests/Test.h" @@ -23,12 +24,12 @@ static inline bool SkShouldPostMessageToBus(const TestMessage&, uint32_t) { } // namespace -DECLARE_SKMESSAGEBUS_MESSAGE(TestMessage, true) +DECLARE_SKMESSAGEBUS_MESSAGE(TestMessage, uint32_t, true) DEF_TEST(MessageBus, r) { - using TestMessageBus = SkMessageBus; + using TestMessageBus = SkMessageBus; // Register two inboxes to receive all TestMessages. - TestMessageBus::Inbox inbox1, inbox2; + TestMessageBus::Inbox inbox1(0), inbox2(0); // Send two messages. const TestMessage m1 = { 5, 4.2f }; @@ -77,12 +78,12 @@ static inline bool SkShouldPostMessageToBus(const sk_sp&, uin } // namespace -DECLARE_SKMESSAGEBUS_MESSAGE(sk_sp, false) +DECLARE_SKMESSAGEBUS_MESSAGE(sk_sp, uint32_t, false) DEF_TEST(MessageBusSp, r) { // Register two inboxes to receive all TestMessages. - using TestMessageBus = SkMessageBus, false>; - TestMessageBus::Inbox inbox1; + using TestMessageBus = SkMessageBus, uint32_t, false>; + TestMessageBus::Inbox inbox1(0); // Send two messages. auto m1 = sk_make_sp(5, 4.2f); @@ -119,12 +120,13 @@ DEF_TEST(MessageBusSp, r) { namespace { struct AddressedMessage { - uint32_t fInboxID; + GrDirectContext::DirectContextID fInboxID; }; -static inline bool SkShouldPostMessageToBus(const AddressedMessage& msg, uint32_t msgBusUniqueID) { - SkASSERT(msgBusUniqueID); - if (!msg.fInboxID) { +static inline bool SkShouldPostMessageToBus(const AddressedMessage& msg, + GrDirectContext::DirectContextID msgBusUniqueID) { + SkASSERT(msgBusUniqueID.isValid()); + if (!msg.fInboxID.isValid()) { return true; } return msgBusUniqueID == msg.fInboxID; @@ -132,29 +134,36 @@ static inline bool SkShouldPostMessageToBus(const AddressedMessage& msg, uint32_ } // namespace -DECLARE_SKMESSAGEBUS_MESSAGE(AddressedMessage, true) +DECLARE_SKMESSAGEBUS_MESSAGE(AddressedMessage, GrDirectContext::DirectContextID, true) DEF_TEST(MessageBus_SkShouldPostMessageToBus, r) { - using AddressedMessageBus = SkMessageBus; - AddressedMessageBus::Inbox inbox1(1), inbox2(2); + using ID = GrDirectContext::DirectContextID; + using AddressedMessageBus = SkMessageBus; - AddressedMessageBus::Post({0}); // Should go to both - AddressedMessageBus::Post({1}); // Should go to inbox1 - AddressedMessageBus::Post({2}); // Should go to inbox2 - AddressedMessageBus::Post({3}); // Should go nowhere + ID idInvalid; + ID id1 = ID::Next(), + id2 = ID::Next(), + id3 = ID::Next(); + + AddressedMessageBus::Inbox inbox1(id1), inbox2(id2); + + AddressedMessageBus::Post({idInvalid}); // Should go to both + AddressedMessageBus::Post({id1}); // Should go to inbox1 + AddressedMessageBus::Post({id2}); // Should go to inbox2 + AddressedMessageBus::Post({id3}); // Should go nowhere SkTArray messages; inbox1.poll(&messages); REPORTER_ASSERT(r, messages.count() == 2); if (messages.count() == 2) { - REPORTER_ASSERT(r, messages[0].fInboxID == 0); - REPORTER_ASSERT(r, messages[1].fInboxID == 1); + REPORTER_ASSERT(r, !messages[0].fInboxID.isValid()); + REPORTER_ASSERT(r, messages[1].fInboxID == id1); } inbox2.poll(&messages); REPORTER_ASSERT(r, messages.count() == 2); if (messages.count() == 2) { - REPORTER_ASSERT(r, messages[0].fInboxID == 0); - REPORTER_ASSERT(r, messages[1].fInboxID == 2); + REPORTER_ASSERT(r, !messages[0].fInboxID.isValid()); + REPORTER_ASSERT(r, messages[1].fInboxID == id2); } } diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index a6ecd40149..7e8fc84f2b 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -1080,7 +1080,7 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive()); typedef GrUniqueKeyInvalidatedMessage Msg; - typedef SkMessageBus Bus; + typedef SkMessageBus Bus; // Invalidate two of the three, they should be purged and no longer accessible via their keys. Bus::Post(Msg(key1, dContext->priv().contextID())); @@ -1562,14 +1562,14 @@ static void test_free_texture_messages(skiatest::Reporter* reporter) { // Send message to free the first resource GrTextureFreedMessage msg1{wrapped[0], dContext->priv().contextID()}; - SkMessageBus::Post(msg1); + SkMessageBus::Post(msg1); cache->purgeAsNeeded(); REPORTER_ASSERT(reporter, 1 == (freed[0] + freed[1] + freed[2])); REPORTER_ASSERT(reporter, 1 == freed[0]); GrTextureFreedMessage msg2{wrapped[2], dContext->priv().contextID()}; - SkMessageBus::Post(msg2); + SkMessageBus::Post(msg2); cache->purgeAsNeeded(); REPORTER_ASSERT(reporter, 2 == (freed[0] + freed[1] + freed[2])); @@ -1645,7 +1645,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceMessagesAfterAbandon, reporter, ctxIn // In the past, creating this message could cause an exception due to // an un-safe downcast from GrTexture to GrGpuResource GrTextureFreedMessage msg{tex, context->priv().contextID()}; - SkMessageBus::Post(msg); + SkMessageBus::Post(msg); // This doesn't actually do anything but it does trigger us to read messages context->purgeUnlockedResources(false); diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp index 3513e17849..cb409057a9 100644 --- a/tests/TextureProxyTest.cpp +++ b/tests/TextureProxyTest.cpp @@ -215,7 +215,7 @@ static void basic_test(GrDirectContext* dContext, if (expectResourceToOutliveProxy) { proxy.reset(); GrUniqueKeyInvalidatedMessage msg(texKey, dContext->priv().contextID()); - SkMessageBus::Post(msg); + SkMessageBus::Post(msg); cache->purgeAsNeeded(); expectedCacheCount -= cacheEntriesPerProxy; proxy = proxyProvider->findOrCreateProxyByUniqueKey(key); @@ -312,7 +312,7 @@ static void invalidation_and_instantiation_test(GrDirectContext* dContext, SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get())); // Send an invalidation message, which will be sitting in the cache's inbox - SkMessageBus::Post( + SkMessageBus::Post( GrUniqueKeyInvalidatedMessage(key, dContext->priv().contextID())); REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());