From efc17ce2caf3e51a344f4544a210156eedfa00c7 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Fri, 7 Aug 2020 12:14:14 -0400 Subject: [PATCH] Fix bug in SkMipmapCache::AddAndRef factory selection. Discovered via ClangTidy `readability-static-accessed-through-instance`. Change-Id: I646e3293853e65b5cc2419c8687c035aab4b669a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308659 Commit-Queue: John Stiles Commit-Queue: Mike Klein Reviewed-by: Mike Klein Reviewed-by: Brian Osman --- src/core/SkBitmapCache.cpp | 2 +- tests/SkResourceCacheTest.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp index abb4a125d4..d5d334b18e 100644 --- a/src/core/SkBitmapCache.cpp +++ b/src/core/SkBitmapCache.cpp @@ -280,7 +280,7 @@ const SkMipmap* SkMipmapCache::FindAndRef(const SkBitmapCacheDesc& desc, } static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache) { - return localCache ? localCache->GetDiscardableFactory() + return localCache ? localCache->discardableFactory() : SkResourceCache::GetDiscardableFactory(); } diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp index 1e9ac88c10..89339cd6be 100644 --- a/tests/SkResourceCacheTest.cpp +++ b/tests/SkResourceCacheTest.cpp @@ -110,8 +110,11 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca #include "src/lazy/SkDiscardableMemoryPool.h" static SkDiscardableMemoryPool* gPool = nullptr; +static int gFactoryCalls = 0; + static SkDiscardableMemory* pool_factory(size_t bytes) { SkASSERT(gPool); + gFactoryCalls++; return gPool->create(bytes); } @@ -134,6 +137,7 @@ DEF_TEST(BitmapCache_discarded_bitmap, reporter) { SkResourceCache cache(factory); testBitmapCache_discarded_bitmap(reporter, &cache, factory); } + REPORTER_ASSERT(reporter, gFactoryCalls > 0); } static void test_discarded_image(skiatest::Reporter* reporter, const SkMatrix& transform,