Rename GrThreadSafeUniquelyKeyedProxyViewCache
Once triangulated paths are added this will no longer just be storing proxy views.
Bug: 1108408
Change-Id: I82fa47b0b85f738d9a25330c29bc2892c9bfeda4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323999
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 30d1866..8e3fa06 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -250,8 +250,8 @@
"$_src/gpu/GrTextureResolveManager.h",
"$_src/gpu/GrTextureResolveRenderTask.cpp",
"$_src/gpu/GrTextureResolveRenderTask.h",
- "$_src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.cpp",
- "$_src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h",
+ "$_src/gpu/GrThreadSafeCache.cpp",
+ "$_src/gpu/GrThreadSafeCache.h",
"$_src/gpu/GrTracing.h",
"$_src/gpu/GrTransferFromRenderTask.cpp",
"$_src/gpu/GrTransferFromRenderTask.h",
diff --git a/gn/tests.gni b/gn/tests.gni
index fb8e303..301a76b 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -122,7 +122,7 @@
"$_tests/GrTestingBackendTextureUploadTest.cpp",
"$_tests/GrTextBlobTest.cpp",
"$_tests/GrTextureMipMapInvalidationTest.cpp",
- "$_tests/GrThreadSafeViewCacheTest.cpp",
+ "$_tests/GrThreadSafeCacheTest.cpp",
"$_tests/GrUploadPixelsTests.cpp",
"$_tests/GradientTest.cpp",
"$_tests/HSVRoundTripTest.cpp",
diff --git a/include/gpu/GrContextThreadSafeProxy.h b/include/gpu/GrContextThreadSafeProxy.h
index 04e49e4..00b111e 100644
--- a/include/gpu/GrContextThreadSafeProxy.h
+++ b/include/gpu/GrContextThreadSafeProxy.h
@@ -19,7 +19,7 @@
class GrCaps;
class GrContextThreadSafeProxyPriv;
class GrTextBlobCache;
-class GrThreadSafeUniquelyKeyedProxyViewCache;
+class GrThreadSafeCache;
class SkSurfaceCharacterization;
class SkSurfaceProps;
@@ -113,13 +113,13 @@
// `init` method on GrContext_Base).
void init(sk_sp<const GrCaps>);
- const GrBackendApi fBackend;
- const GrContextOptions fOptions;
- const uint32_t fContextID;
- sk_sp<const GrCaps> fCaps;
- std::unique_ptr<GrTextBlobCache> fTextBlobCache;
- std::unique_ptr<GrThreadSafeUniquelyKeyedProxyViewCache> fThreadSafeViewCache;
- std::atomic<bool> fAbandoned{false};
+ const GrBackendApi fBackend;
+ const GrContextOptions fOptions;
+ const uint32_t fContextID;
+ sk_sp<const GrCaps> fCaps;
+ std::unique_ptr<GrTextBlobCache> fTextBlobCache;
+ std::unique_ptr<GrThreadSafeCache> fThreadSafeCache;
+ std::atomic<bool> fAbandoned{false};
};
#endif
diff --git a/include/gpu/GrRecordingContext.h b/include/gpu/GrRecordingContext.h
index e010c37..9cf7bb5 100644
--- a/include/gpu/GrRecordingContext.h
+++ b/include/gpu/GrRecordingContext.h
@@ -23,7 +23,7 @@
class GrSurfaceContext;
class GrSurfaceProxy;
class GrTextBlobCache;
-class GrThreadSafeUniquelyKeyedProxyViewCache;
+class GrThreadSafeCache;
class SkArenaAlloc;
class SkJSONWriter;
@@ -174,8 +174,8 @@
GrTextBlobCache* getTextBlobCache();
const GrTextBlobCache* getTextBlobCache() const;
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache();
- const GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() const;
+ GrThreadSafeCache* threadSafeCache();
+ const GrThreadSafeCache* threadSafeCache() const;
/**
* Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.)
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index f31791a..3343363 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -20,7 +20,7 @@
#include "src/gpu/GrSoftwarePathRenderer.h"
#include "src/gpu/GrStyle.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/geometry/GrStyledShape.h"
@@ -126,13 +126,13 @@
SkASSERT(filter);
SkASSERT(!shape.style().applies());
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
GrSurfaceProxyView filteredMaskView;
sk_sp<SkData> data;
if (key->isValid()) {
- std::tie(filteredMaskView, data) = threadSafeViewCache->findWithData(*key);
+ std::tie(filteredMaskView, data) = threadSafeCache->findWithData(*key);
}
if (filteredMaskView) {
@@ -196,8 +196,7 @@
if (key->isValid()) {
key->setCustomData(create_data(*drawRect, unclippedDevShapeBounds));
- std::tie(filteredMaskView, data) = threadSafeViewCache->addWithData(*key,
- filteredMaskView);
+ std::tie(filteredMaskView, data) = threadSafeCache->addWithData(*key, filteredMaskView);
// If we got a different view back from 'addWithData' it could have a different drawRect
*drawRect = extract_draw_rect_from_data(data.get(), unclippedDevShapeBounds);
}
@@ -400,15 +399,15 @@
return {};
}
- auto threadSafeViewCache = dContext->priv().threadSafeViewCache();
+ auto threadSafeCache = dContext->priv().threadSafeCache();
GrSurfaceProxyView lazyView;
- sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline> trampoline;
+ sk_sp<GrThreadSafeCache::Trampoline> trampoline;
if (key->isValid()) {
// In this case, we want GPU-filtered masks to have priority over SW-generated ones so
// we pre-emptively add a lazy-view to the cache and fill it in later.
- std::tie(lazyView, trampoline) = GrThreadSafeUniquelyKeyedProxyViewCache::CreateLazyView(
+ std::tie(lazyView, trampoline) = GrThreadSafeCache::CreateLazyView(
dContext, GrColorType::kAlpha_8, maskRect->size(),
kMaskOrigin, SkBackingFit::kApprox);
if (!lazyView) {
@@ -416,7 +415,7 @@
}
key->setCustomData(create_data(*maskRect, unclippedDevShapeBounds));
- auto [cachedView, data] = threadSafeViewCache->findOrAddWithData(*key, lazyView);
+ auto [cachedView, data] = threadSafeCache->findOrAddWithData(*key, lazyView);
if (cachedView != lazyView) {
// In this case, the gpu-thread lost out to a recording thread - use its result.
SkASSERT(data);
@@ -440,7 +439,7 @@
// succeeded but, if it does, remove the lazy-view from the cache and fallback to
// a SW-created mask. Note that any recording threads that glommed onto the
// lazy-view will have to, later, drop those draws.
- threadSafeViewCache->remove(*key);
+ threadSafeCache->remove(*key);
}
return {};
}
@@ -456,7 +455,7 @@
// Remove the lazy-view from the cache and fallback to a SW-created mask. Note that
// any recording threads that glommed onto the lazy-view will have to, later, drop
// those draws.
- threadSafeViewCache->remove(*key);
+ threadSafeCache->remove(*key);
}
return {};
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f0b07e6..91f328f 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -27,7 +27,7 @@
#include "src/gpu/GrSemaphore.h"
#include "src/gpu/GrShaderUtils.h"
#include "src/gpu/GrSoftwarePathRenderer.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/GrTracing.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
@@ -74,7 +74,7 @@
}
SkASSERT(this->getTextBlobCache());
- SkASSERT(this->threadSafeViewCache());
+ SkASSERT(this->threadSafeCache());
if (fGpu) {
fStrikeCache = std::make_unique<GrStrikeCache>();
@@ -85,7 +85,7 @@
if (fResourceCache) {
fResourceCache->setProxyProvider(this->proxyProvider());
- fResourceCache->setThreadSafeViewCache(this->threadSafeViewCache());
+ fResourceCache->setThreadSafeCache(this->threadSafeCache());
}
fDidTestPMConversions = false;
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 3ac7be2..2823a1d 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -58,9 +58,7 @@
GrStrikeCache* getGrStrikeCache() { return fContext->fStrikeCache.get(); }
GrTextBlobCache* getTextBlobCache() { return fContext->getTextBlobCache(); }
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() {
- return fContext->threadSafeViewCache();
- }
+ GrThreadSafeCache* threadSafeCache() { return fContext->threadSafeCache(); }
/**
* Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.)
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index 5ebb306..120699f 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -13,7 +13,7 @@
#include "include/core/SkSurfaceCharacterization.h"
#include "src/gpu/GrBaseContextPriv.h"
#include "src/gpu/GrCaps.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrSkSLFP.h"
#include "src/image/SkSurface_Gpu.h"
@@ -40,7 +40,7 @@
void GrContextThreadSafeProxy::init(sk_sp<const GrCaps> caps) {
fCaps = std::move(caps);
fTextBlobCache = std::make_unique<GrTextBlobCache>(fContextID);
- fThreadSafeViewCache = std::make_unique<GrThreadSafeUniquelyKeyedProxyViewCache>();
+ fThreadSafeCache = std::make_unique<GrThreadSafeCache>();
}
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
diff --git a/src/gpu/GrContextThreadSafeProxyPriv.h b/src/gpu/GrContextThreadSafeProxyPriv.h
index 2a31f68..606aa16 100644
--- a/src/gpu/GrContextThreadSafeProxyPriv.h
+++ b/src/gpu/GrContextThreadSafeProxyPriv.h
@@ -39,12 +39,8 @@
GrTextBlobCache* getTextBlobCache() { return fProxy->fTextBlobCache.get(); }
const GrTextBlobCache* getTextBlobCache() const { return fProxy->fTextBlobCache.get(); }
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() {
- return fProxy->fThreadSafeViewCache.get();
- }
- const GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() const {
- return fProxy->fThreadSafeViewCache.get();
- }
+ GrThreadSafeCache* threadSafeCache() { return fProxy->fThreadSafeCache.get(); }
+ const GrThreadSafeCache* threadSafeCache() const { return fProxy->fThreadSafeCache.get(); }
void abandonContext() { fProxy->abandonContext(); }
bool abandoned() const { return fProxy->abandoned(); }
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index 26fa0f2..7e49922 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -131,12 +131,12 @@
return fThreadSafeProxy->priv().getTextBlobCache();
}
-GrThreadSafeUniquelyKeyedProxyViewCache* GrRecordingContext::threadSafeViewCache() {
- return fThreadSafeProxy->priv().threadSafeViewCache();
+GrThreadSafeCache* GrRecordingContext::threadSafeCache() {
+ return fThreadSafeProxy->priv().threadSafeCache();
}
-const GrThreadSafeUniquelyKeyedProxyViewCache* GrRecordingContext::threadSafeViewCache() const {
- return fThreadSafeProxy->priv().threadSafeViewCache();
+const GrThreadSafeCache* GrRecordingContext::threadSafeCache() const {
+ return fThreadSafeProxy->priv().threadSafeCache();
}
void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) {
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index 0deee47..3f6fb33 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -57,9 +57,7 @@
GrTextBlobCache* getTextBlobCache() { return fContext->getTextBlobCache(); }
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() {
- return fContext->threadSafeViewCache();
- }
+ GrThreadSafeCache* threadSafeCache() { return fContext->threadSafeCache(); }
void moveRenderTasksToDDL(SkDeferredDisplayList*);
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 5a0910e..f6378db 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -21,7 +21,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxyCacheAccess.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/GrTracing.h"
#include "src/gpu/SkGr.h"
@@ -201,7 +201,7 @@
void GrResourceCache::abandonAll() {
AutoValidate av(this);
- fThreadSafeViewCache->dropAllRefs();
+ fThreadSafeCache->dropAllRefs();
// We need to make sure to free any resources that were waiting on a free message but never
// received one.
@@ -233,7 +233,7 @@
void GrResourceCache::releaseAll() {
AutoValidate av(this);
- fThreadSafeViewCache->dropAllRefs();
+ fThreadSafeCache->dropAllRefs();
this->processFreedGpuResources();
@@ -242,7 +242,7 @@
fTexturesAwaitingUnref.reset();
SkASSERT(fProxyProvider); // better have called setProxyProvider
- SkASSERT(fThreadSafeViewCache); // better have called setThreadSafeViewCache too
+ SkASSERT(fThreadSafeCache); // better have called setThreadSafeCache too
// We must remove the uniqueKeys from the proxies here. While they possess a uniqueKey
// they also have a raw pointer back to this class (which is presumably going away)!
@@ -530,7 +530,7 @@
}
if (stillOverbudget) {
- fThreadSafeViewCache->dropUniqueRefs(this);
+ fThreadSafeCache->dropUniqueRefs(this);
while (stillOverbudget && fPurgeableQueue.count()) {
GrGpuResource* resource = fPurgeableQueue.peek();
@@ -546,7 +546,7 @@
void GrResourceCache::purgeUnlockedResources(bool scratchResourcesOnly) {
if (!scratchResourcesOnly) {
- fThreadSafeViewCache->dropUniqueRefs(nullptr);
+ fThreadSafeCache->dropUniqueRefs(nullptr);
// We could disable maintaining the heap property here, but it would add a lot of
// complexity. Moreover, this is rarely called.
@@ -580,7 +580,7 @@
}
void GrResourceCache::purgeResourcesNotUsedSince(GrStdSteadyClock::time_point purgeTime) {
- fThreadSafeViewCache->dropUniqueRefsOlderThan(purgeTime);
+ fThreadSafeCache->dropUniqueRefsOlderThan(purgeTime);
while (fPurgeableQueue.count()) {
const GrStdSteadyClock::time_point resourceTime =
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 08a5f65..f3b90a5 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -26,7 +26,7 @@
class SkTraceMemoryDump;
class GrSingleOwner;
class GrTexture;
-class GrThreadSafeUniquelyKeyedProxyViewCache;
+class GrThreadSafeCache;
struct GrTextureFreedMessage {
GrTexture* fTexture;
@@ -239,8 +239,8 @@
void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
void setProxyProvider(GrProxyProvider* proxyProvider) { fProxyProvider = proxyProvider; }
- void setThreadSafeViewCache(GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache) {
- fThreadSafeViewCache = threadSafeViewCache;
+ void setThreadSafeCache(GrThreadSafeCache* threadSafeCache) {
+ fThreadSafeCache = threadSafeCache;
}
private:
@@ -327,7 +327,7 @@
typedef SkTDArray<GrGpuResource*> ResourceArray;
GrProxyProvider* fProxyProvider = nullptr;
- GrThreadSafeUniquelyKeyedProxyViewCache* fThreadSafeViewCache = nullptr;
+ GrThreadSafeCache* fThreadSafeCache = nullptr;
// Whenever a resource is added to the cache or the result of a cache lookup, fTimestamp is
// assigned as the resource's timestamp and then incremented. fPurgeableQueue orders the
diff --git a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.cpp b/src/gpu/GrThreadSafeCache.cpp
similarity index 74%
rename from src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.cpp
rename to src/gpu/GrThreadSafeCache.cpp
index 312e2ba..0db8002 100644
--- a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.cpp
+++ b/src/gpu/GrThreadSafeCache.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h"
@@ -13,29 +13,29 @@
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrResourceCache.h"
-GrThreadSafeUniquelyKeyedProxyViewCache::GrThreadSafeUniquelyKeyedProxyViewCache()
+GrThreadSafeCache::GrThreadSafeCache()
: fFreeEntryList(nullptr) {
}
-GrThreadSafeUniquelyKeyedProxyViewCache::~GrThreadSafeUniquelyKeyedProxyViewCache() {
+GrThreadSafeCache::~GrThreadSafeCache() {
this->dropAllRefs();
}
#if GR_TEST_UTILS
-int GrThreadSafeUniquelyKeyedProxyViewCache::numEntries() const {
+int GrThreadSafeCache::numEntries() const {
SkAutoSpinlock lock{fSpinLock};
return fUniquelyKeyedProxyViewMap.count();
}
-size_t GrThreadSafeUniquelyKeyedProxyViewCache::approxBytesUsedForHash() const {
+size_t GrThreadSafeCache::approxBytesUsedForHash() const {
SkAutoSpinlock lock{fSpinLock};
return fUniquelyKeyedProxyViewMap.approxBytesUsed();
}
#endif
-void GrThreadSafeUniquelyKeyedProxyViewCache::dropAllRefs() {
+void GrThreadSafeCache::dropAllRefs() {
SkAutoSpinlock lock{fSpinLock};
fUniquelyKeyedProxyViewMap.reset();
@@ -48,7 +48,7 @@
// TODO: If iterating becomes too expensive switch to using something like GrIORef for the
// GrSurfaceProxy
-void GrThreadSafeUniquelyKeyedProxyViewCache::dropUniqueRefs(GrResourceCache* resourceCache) {
+void GrThreadSafeCache::dropUniqueRefs(GrResourceCache* resourceCache) {
SkAutoSpinlock lock{fSpinLock};
// Iterate from LRU to MRU
@@ -71,8 +71,7 @@
}
}
-void GrThreadSafeUniquelyKeyedProxyViewCache::dropUniqueRefsOlderThan(
- GrStdSteadyClock::time_point purgeTime) {
+void GrThreadSafeCache::dropUniqueRefsOlderThan(GrStdSteadyClock::time_point purgeTime) {
SkAutoSpinlock lock{fSpinLock};
// Iterate from LRU to MRU
@@ -96,7 +95,7 @@
}
}
-std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeUniquelyKeyedProxyViewCache::internalFind(
+std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalFind(
const GrUniqueKey& key) {
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
if (tmp) {
@@ -111,7 +110,7 @@
return {};
}
-GrSurfaceProxyView GrThreadSafeUniquelyKeyedProxyViewCache::find(const GrUniqueKey& key) {
+GrSurfaceProxyView GrThreadSafeCache::find(const GrUniqueKey& key) {
SkAutoSpinlock lock{fSpinLock};
GrSurfaceProxyView view;
@@ -119,16 +118,15 @@
return view;
}
-std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeUniquelyKeyedProxyViewCache::findWithData(
+std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::findWithData(
const GrUniqueKey& key) {
SkAutoSpinlock lock{fSpinLock};
return this->internalFind(key);
}
-GrThreadSafeUniquelyKeyedProxyViewCache::Entry*
-GrThreadSafeUniquelyKeyedProxyViewCache::getEntry(const GrUniqueKey& key,
- const GrSurfaceProxyView& view) {
+GrThreadSafeCache::Entry* GrThreadSafeCache::getEntry(const GrUniqueKey& key,
+ const GrSurfaceProxyView& view) {
Entry* entry;
if (fFreeEntryList) {
@@ -149,7 +147,7 @@
return entry;
}
-void GrThreadSafeUniquelyKeyedProxyViewCache::recycleEntry(Entry* dead) {
+void GrThreadSafeCache::recycleEntry(Entry* dead) {
SkASSERT(!dead->fPrev && !dead->fNext && !dead->fList);
dead->fKey.reset();
@@ -159,7 +157,7 @@
fFreeEntryList = dead;
}
-std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeUniquelyKeyedProxyViewCache::internalAdd(
+std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalAdd(
const GrUniqueKey& key,
const GrSurfaceProxyView& view) {
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
@@ -172,8 +170,7 @@
return { tmp->fView, tmp->fKey.refCustomData() };
}
-GrSurfaceProxyView GrThreadSafeUniquelyKeyedProxyViewCache::add(const GrUniqueKey& key,
- const GrSurfaceProxyView& view) {
+GrSurfaceProxyView GrThreadSafeCache::add(const GrUniqueKey& key, const GrSurfaceProxyView& view) {
SkAutoSpinlock lock{fSpinLock};
GrSurfaceProxyView newView;
@@ -181,7 +178,7 @@
return newView;
}
-std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeUniquelyKeyedProxyViewCache::addWithData(
+std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::addWithData(
const GrUniqueKey& key,
const GrSurfaceProxyView& view) {
SkAutoSpinlock lock{fSpinLock};
@@ -189,8 +186,8 @@
return this->internalAdd(key, view);
}
-GrSurfaceProxyView GrThreadSafeUniquelyKeyedProxyViewCache::findOrAdd(const GrUniqueKey& key,
- const GrSurfaceProxyView& v) {
+GrSurfaceProxyView GrThreadSafeCache::findOrAdd(const GrUniqueKey& key,
+ const GrSurfaceProxyView& v) {
SkAutoSpinlock lock{fSpinLock};
GrSurfaceProxyView view;
@@ -203,7 +200,7 @@
return view;
}
-std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeUniquelyKeyedProxyViewCache::findOrAddWithData(
+std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::findOrAddWithData(
const GrUniqueKey& key,
const GrSurfaceProxyView& v) {
SkAutoSpinlock lock{fSpinLock};
@@ -216,7 +213,7 @@
return this->internalAdd(key, v);
}
-void GrThreadSafeUniquelyKeyedProxyViewCache::remove(const GrUniqueKey& key) {
+void GrThreadSafeCache::remove(const GrUniqueKey& key) {
SkAutoSpinlock lock{fSpinLock};
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
@@ -227,12 +224,12 @@
}
}
-std::tuple<GrSurfaceProxyView, sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline>>
-GrThreadSafeUniquelyKeyedProxyViewCache::CreateLazyView(GrDirectContext* dContext,
- GrColorType origCT,
- SkISize dimensions,
- GrSurfaceOrigin origin,
- SkBackingFit fit) {
+std::tuple<GrSurfaceProxyView, sk_sp<GrThreadSafeCache::Trampoline>>
+GrThreadSafeCache::CreateLazyView(GrDirectContext* dContext,
+ GrColorType origCT,
+ SkISize dimensions,
+ GrSurfaceOrigin origin,
+ SkBackingFit fit) {
GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
constexpr int kSampleCnt = 1;
diff --git a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h b/src/gpu/GrThreadSafeCache.h
similarity index 95%
rename from src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h
rename to src/gpu/GrThreadSafeCache.h
index 3c5d975..27a990e 100644
--- a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h
+++ b/src/gpu/GrThreadSafeCache.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrThreadSafeUniquelyKeyedProxyViewCache_DEFINED
-#define GrThreadSafeUniquelyKeyedProxyViewCache_DEFINED
+#ifndef GrThreadSafeCache_DEFINED
+#define GrThreadSafeCache_DEFINED
#include "include/private/SkSpinlock.h"
#include "src/core/SkArenaAlloc.h"
@@ -60,10 +60,10 @@
//
// For GrContext::performDeferredCleanup, any uniquely held resources that haven't been accessed
// w/in 'msNotUsed' will be released from this cache prior to the resource cache being cleaned.
-class GrThreadSafeUniquelyKeyedProxyViewCache {
+class GrThreadSafeCache {
public:
- GrThreadSafeUniquelyKeyedProxyViewCache();
- ~GrThreadSafeUniquelyKeyedProxyViewCache();
+ GrThreadSafeCache();
+ ~GrThreadSafeCache();
#if GR_TEST_UTILS
int numEntries() const SK_EXCLUDES(fSpinLock);
@@ -146,4 +146,4 @@
Entry* fFreeEntryList SK_GUARDED_BY(fSpinLock);
};
-#endif // GrThreadSafeUniquelyKeyedProxyViewCache_DEFINED
+#endif // GrThreadSafeCache_DEFINED
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index fa8c5e4..e333eb5 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -42,7 +42,7 @@
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
- #include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+ #include "src/gpu/GrThreadSafeCache.h"
// Computes an unnormalized half kernel (right side). Returns the summation of all the half
// kernel values.
@@ -205,7 +205,7 @@
return nullptr;
}
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
// Profile textures are cached by the ratio of sigma to circle radius and by the size of the
// profile texture (binned by powers of 2).
@@ -247,7 +247,7 @@
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
- GrSurfaceProxyView profileView = threadSafeViewCache->find(key);
+ GrSurfaceProxyView profileView = threadSafeCache->find(key);
if (profileView) {
SkASSERT(profileView.asTextureProxy());
SkASSERT(profileView.origin() == kTopLeft_GrSurfaceOrigin);
@@ -276,7 +276,7 @@
return nullptr;
}
- profileView = threadSafeViewCache->add(key, profileView);
+ profileView = threadSafeCache->add(key, profileView);
return GrTextureEffect::Make(std::move(profileView), kPremul_SkAlphaType, texM);
}
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 0e65ede..778dc27 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -13,7 +13,7 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
@@ -102,12 +102,12 @@
}
// Find or create a texture.
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
SkColorType colorType = useA16 ? kA16_float_SkColorType : kAlpha_8_SkColorType;
GrSurfaceProxyView view;
- if (kCacheKernelTexture && (view = threadSafeViewCache->find(key))) {
+ if (kCacheKernelTexture && (view = threadSafeCache->find(key))) {
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
auto kernelFP = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType);
return {result, std::move(kernelFP)};
@@ -135,7 +135,7 @@
}
if (kCacheKernelTexture) {
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
}
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index 11d8035..8230359 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -48,7 +48,7 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrStyle.h"
- #include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+ #include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
static constexpr auto kBlurredRRectMaskOrigin = kTopLeft_GrSurfaceOrigin;
@@ -76,7 +76,7 @@
static bool fillin_view_on_gpu(
GrDirectContext* dContext,
const GrSurfaceProxyView& lazyView,
- sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline> trampoline,
+ sk_sp<GrThreadSafeCache::Trampoline> trampoline,
const SkRRect& rrectToDraw,
const SkISize& dimensions,
float xformedSigma) {
@@ -254,7 +254,7 @@
GrUniqueKey key;
make_blurred_rrect_key(&key, rrectToDraw, xformedSigma);
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
// It seems like we could omit this matrix and modify the shader code to not normalize
// the coords used to sample the texture effect. However, the "proxyDims" value in the
@@ -269,14 +269,14 @@
if (GrDirectContext* dContext = rContext->asDirectContext()) {
// The gpu thread gets priority over the recording threads. If the gpu thread is first,
// it crams a lazy proxy into the cache and then fills it in later.
- auto[lazyView, trampoline] = GrThreadSafeUniquelyKeyedProxyViewCache::CreateLazyView(
+ auto[lazyView, trampoline] = GrThreadSafeCache::CreateLazyView(
dContext, GrColorType::kAlpha_8, dimensions,
kBlurredRRectMaskOrigin, SkBackingFit::kExact);
if (!lazyView) {
return nullptr;
}
- view = threadSafeViewCache->findOrAdd(key, lazyView);
+ view = threadSafeCache->findOrAdd(key, lazyView);
if (view != lazyView) {
SkASSERT(view.asTextureProxy());
SkASSERT(view.origin() == kBlurredRRectMaskOrigin);
@@ -287,11 +287,11 @@
rrectToDraw, dimensions, xformedSigma)) {
// In this case something has gone disastrously wrong so set up to drop the draw
// that needed this resource and reduce future pollution of the cache.
- threadSafeViewCache->remove(key);
+ threadSafeCache->remove(key);
return nullptr;
}
} else {
- view = threadSafeViewCache->find(key);
+ view = threadSafeCache->find(key);
if (view) {
SkASSERT(view.asTextureProxy());
SkASSERT(view.origin() == kBlurredRRectMaskOrigin);
@@ -303,7 +303,7 @@
return nullptr;
}
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
}
SkASSERT(view.asTextureProxy());
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index c92d969..3b0c912 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -17,7 +17,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrShaderCaps.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
}
@@ -54,7 +54,7 @@
@class {
static std::unique_ptr<GrFragmentProcessor> MakeIntegralFP(GrRecordingContext* rContext,
float sixSigma) {
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
int width = SkCreateIntegralTable(sixSigma, nullptr);
@@ -66,7 +66,7 @@
SkMatrix m = SkMatrix::Scale(width/sixSigma, 1.f);
- GrSurfaceProxyView view = threadSafeViewCache->find(key);
+ GrSurfaceProxyView view = threadSafeCache->find(key);
if (view) {
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
@@ -85,7 +85,7 @@
return {};
}
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
return GrTextureEffect::Make(
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index 1e13968..2b1ac09 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -14,7 +14,7 @@
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
// Computes an unnormalized half kernel (right side). Returns the summation of all the half
// kernel values.
@@ -187,7 +187,7 @@
return nullptr;
}
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
// Profile textures are cached by the ratio of sigma to circle radius and by the size of the
// profile texture (binned by powers of 2).
@@ -229,7 +229,7 @@
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
- GrSurfaceProxyView profileView = threadSafeViewCache->find(key);
+ GrSurfaceProxyView profileView = threadSafeCache->find(key);
if (profileView) {
SkASSERT(profileView.asTextureProxy());
SkASSERT(profileView.origin() == kTopLeft_GrSurfaceOrigin);
@@ -258,7 +258,7 @@
return nullptr;
}
- profileView = threadSafeViewCache->add(key, profileView);
+ profileView = threadSafeCache->add(key, profileView);
return GrTextureEffect::Make(std::move(profileView), kPremul_SkAlphaType, texM);
}
@@ -307,18 +307,18 @@
args.fUniformHandler->getUniformCStr(circleDataVar),
args.fUniformHandler->getUniformCStr(circleDataVar),
args.fUniformHandler->getUniformCStr(circleDataVar));
- SkString _sample13801 = this->invokeChild(0, args);
+ SkString _sample13763 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;)SkSL",
- _sample13801.c_str());
- SkString _coords13849("float2(half2(dist, 0.5))");
- SkString _sample13849 = this->invokeChild(1, args, _coords13849.c_str());
+ _sample13763.c_str());
+ SkString _coords13811("float2(half2(dist, 0.5))");
+ SkString _sample13811 = this->invokeChild(1, args, _coords13811.c_str());
fragBuilder->codeAppendf(
R"SkSL(
%s = inputColor * %s.w;
)SkSL",
- args.fOutputColor, _sample13849.c_str());
+ args.fOutputColor, _sample13811.c_str());
}
private:
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.cpp b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
index 42543b5..4a5c62c 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
@@ -24,7 +24,7 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrStyle.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
static constexpr auto kBlurredRRectMaskOrigin = kTopLeft_GrSurfaceOrigin;
@@ -48,13 +48,12 @@
builder.finish();
}
-static bool fillin_view_on_gpu(
- GrDirectContext* dContext,
- const GrSurfaceProxyView& lazyView,
- sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline> trampoline,
- const SkRRect& rrectToDraw,
- const SkISize& dimensions,
- float xformedSigma) {
+static bool fillin_view_on_gpu(GrDirectContext* dContext,
+ const GrSurfaceProxyView& lazyView,
+ sk_sp<GrThreadSafeCache::Trampoline> trampoline,
+ const SkRRect& rrectToDraw,
+ const SkISize& dimensions,
+ float xformedSigma) {
std::unique_ptr<GrRenderTargetContext> rtc = GrRenderTargetContext::MakeWithFallback(
dContext, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions, 1,
GrMipmapped::kNo, GrProtected::kNo, kBlurredRRectMaskOrigin);
@@ -232,7 +231,7 @@
GrUniqueKey key;
make_blurred_rrect_key(&key, rrectToDraw, xformedSigma);
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
// It seems like we could omit this matrix and modify the shader code to not normalize
// the coords used to sample the texture effect. However, the "proxyDims" value in the
@@ -247,14 +246,14 @@
if (GrDirectContext* dContext = rContext->asDirectContext()) {
// The gpu thread gets priority over the recording threads. If the gpu thread is first,
// it crams a lazy proxy into the cache and then fills it in later.
- auto[lazyView, trampoline] = GrThreadSafeUniquelyKeyedProxyViewCache::CreateLazyView(
- dContext, GrColorType::kAlpha_8, dimensions, kBlurredRRectMaskOrigin,
- SkBackingFit::kExact);
+ auto[lazyView, trampoline] =
+ GrThreadSafeCache::CreateLazyView(dContext, GrColorType::kAlpha_8, dimensions,
+ kBlurredRRectMaskOrigin, SkBackingFit::kExact);
if (!lazyView) {
return nullptr;
}
- view = threadSafeViewCache->findOrAdd(key, lazyView);
+ view = threadSafeCache->findOrAdd(key, lazyView);
if (view != lazyView) {
SkASSERT(view.asTextureProxy());
SkASSERT(view.origin() == kBlurredRRectMaskOrigin);
@@ -265,11 +264,11 @@
xformedSigma)) {
// In this case something has gone disastrously wrong so set up to drop the draw
// that needed this resource and reduce future pollution of the cache.
- threadSafeViewCache->remove(key);
+ threadSafeCache->remove(key);
return nullptr;
}
} else {
- view = threadSafeViewCache->find(key);
+ view = threadSafeCache->find(key);
if (view) {
SkASSERT(view.asTextureProxy());
SkASSERT(view.origin() == kBlurredRRectMaskOrigin);
@@ -281,7 +280,7 @@
return nullptr;
}
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
}
SkASSERT(view.asTextureProxy());
@@ -377,18 +376,18 @@
args.fUniformHandler->getUniformCStr(proxyRectVar),
args.fUniformHandler->getUniformCStr(blurRadiusVar),
args.fUniformHandler->getUniformCStr(cornerRadiusVar));
- SkString _sample17268 = this->invokeChild(0, args);
+ SkString _sample17178 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;)SkSL",
- _sample17268.c_str());
- SkString _coords17316("float2(texCoord)");
- SkString _sample17316 = this->invokeChild(1, args, _coords17316.c_str());
+ _sample17178.c_str());
+ SkString _coords17226("float2(texCoord)");
+ SkString _sample17226 = this->invokeChild(1, args, _coords17226.c_str());
fragBuilder->codeAppendf(
R"SkSL(
%s = inputColor * %s;
)SkSL",
- args.fOutputColor, _sample17316.c_str());
+ args.fOutputColor, _sample17226.c_str());
}
private:
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.cpp b/src/gpu/effects/generated/GrRectBlurEffect.cpp
index 9763f3f..e0ed896 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRectBlurEffect.cpp
@@ -70,14 +70,14 @@
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)");
- SkString _coords8175("float2(half2(xy.x, 0.5))");
- SkString _sample8175 = this->invokeChild(1, args, _coords8175.c_str());
+ SkString _coords8137("float2(half2(xy.x, 0.5))");
+ SkString _sample8137 = this->invokeChild(1, args, _coords8137.c_str());
fragBuilder->codeAppendf(
R"SkSL(
xCoverage = %s.w;)SkSL",
- _sample8175.c_str());
- SkString _coords8233("float2(half2(xy.y, 0.5))");
- SkString _sample8233 = this->invokeChild(1, args, _coords8233.c_str());
+ _sample8137.c_str());
+ SkString _coords8195("float2(half2(xy.y, 0.5))");
+ SkString _sample8195 = this->invokeChild(1, args, _coords8195.c_str());
fragBuilder->codeAppendf(
R"SkSL(
yCoverage = %s.w;
@@ -90,35 +90,35 @@
rect.xy = half2(float2(%s.xy) - pos);
rect.zw = half2(pos - float2(%s.zw));
})SkSL",
- _sample8233.c_str(),
+ _sample8195.c_str(),
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)");
- SkString _coords9552("float2(half2(rect.x, 0.5))");
- SkString _sample9552 = this->invokeChild(1, args, _coords9552.c_str());
- SkString _coords9615("float2(half2(rect.z, 0.5))");
- SkString _sample9615 = this->invokeChild(1, args, _coords9615.c_str());
+ SkString _coords9514("float2(half2(rect.x, 0.5))");
+ SkString _sample9514 = this->invokeChild(1, args, _coords9514.c_str());
+ SkString _coords9577("float2(half2(rect.z, 0.5))");
+ SkString _sample9577 = this->invokeChild(1, args, _coords9577.c_str());
fragBuilder->codeAppendf(
R"SkSL(
xCoverage = (1.0 - %s.w) - %s.w;)SkSL",
- _sample9552.c_str(), _sample9615.c_str());
- SkString _coords9679("float2(half2(rect.y, 0.5))");
- SkString _sample9679 = this->invokeChild(1, args, _coords9679.c_str());
- SkString _coords9742("float2(half2(rect.w, 0.5))");
- SkString _sample9742 = this->invokeChild(1, args, _coords9742.c_str());
+ _sample9514.c_str(), _sample9577.c_str());
+ SkString _coords9641("float2(half2(rect.y, 0.5))");
+ SkString _sample9641 = this->invokeChild(1, args, _coords9641.c_str());
+ SkString _coords9704("float2(half2(rect.w, 0.5))");
+ SkString _sample9704 = this->invokeChild(1, args, _coords9704.c_str());
fragBuilder->codeAppendf(
R"SkSL(
yCoverage = (1.0 - %s.w) - %s.w;
})SkSL",
- _sample9679.c_str(), _sample9742.c_str());
- SkString _sample9811 = this->invokeChild(0, args);
+ _sample9641.c_str(), _sample9704.c_str());
+ SkString _sample9773 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;
%s = (inputColor * xCoverage) * yCoverage;
)SkSL",
- _sample9811.c_str(), args.fOutputColor);
+ _sample9773.c_str(), args.fOutputColor);
}
private:
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index 0e67f7e..9dce2cc 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -25,7 +25,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrShaderCaps.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/GrFragmentProcessor.h"
@@ -34,7 +34,7 @@
public:
static std::unique_ptr<GrFragmentProcessor> MakeIntegralFP(GrRecordingContext* rContext,
float sixSigma) {
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
int width = SkCreateIntegralTable(sixSigma, nullptr);
@@ -46,7 +46,7 @@
SkMatrix m = SkMatrix::Scale(width / sixSigma, 1.f);
- GrSurfaceProxyView view = threadSafeViewCache->find(key);
+ GrSurfaceProxyView view = threadSafeCache->find(key);
if (view) {
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
@@ -65,7 +65,7 @@
return {};
}
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
return GrTextureEffect::Make(std::move(view), kPremul_SkAlphaType, m,
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index fd4cd10..65ff5a2 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -16,7 +16,7 @@
#include "src/gpu/GrProgramInfo.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "src/gpu/effects/GrShadowGeoProc.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
@@ -669,9 +669,9 @@
GrUniqueKey::Builder builder(&key, kDomain, 0, "Shadow Gaussian Falloff");
builder.finish();
- auto threadSafeViewCache = rContext->priv().threadSafeViewCache();
+ auto threadSafeCache = rContext->priv().threadSafeCache();
- GrSurfaceProxyView view = threadSafeViewCache->find(key);
+ GrSurfaceProxyView view = threadSafeCache->find(key);
if (view) {
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
return view;
@@ -697,7 +697,7 @@
return {};
}
- view = threadSafeViewCache->add(key, view);
+ view = threadSafeCache->add(key, view);
SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
return view;
}
diff --git a/tests/GrThreadSafeViewCacheTest.cpp b/tests/GrThreadSafeCacheTest.cpp
similarity index 90%
rename from tests/GrThreadSafeViewCacheTest.cpp
rename to tests/GrThreadSafeCacheTest.cpp
index eabd7a3..0f0a0c2 100644
--- a/tests/GrThreadSafeViewCacheTest.cpp
+++ b/tests/GrThreadSafeCacheTest.cpp
@@ -13,7 +13,7 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrStyle.h"
-#include "src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h"
+#include "src/gpu/GrThreadSafeCache.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
@@ -102,7 +102,7 @@
Stats* stats() { return &fStats; }
- int numCacheEntries() const { return this->threadSafeViewCache()->numEntries(); }
+ int numCacheEntries() const { return this->threadSafeCache()->numEntries(); }
GrDirectContext* dContext() { return fDContext; }
@@ -128,13 +128,8 @@
return nullptr;
}
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() {
- return fDContext->priv().threadSafeViewCache();
- }
-
- const GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache() const {
- return fDContext->priv().threadSafeViewCache();
- }
+ GrThreadSafeCache* threadSafeCache() { return fDContext->priv().threadSafeCache(); }
+ const GrThreadSafeCache* threadSafeCache() const { return fDContext->priv().threadSafeCache(); }
// Add a draw on 'canvas' that will introduce a ref on the 'wh' view
void accessCachedView(SkCanvas* canvas,
@@ -144,7 +139,7 @@
bool failFillingIn = false) {
GrRecordingContext* rContext = canvas->recordingContext();
- auto view = AccessCachedView(rContext, this->threadSafeViewCache(),
+ auto view = AccessCachedView(rContext, this->threadSafeCache(),
wh, failLookup, failFillingIn, id, &fStats);
SkASSERT(view);
@@ -178,9 +173,9 @@
GrUniqueKey key;
create_key(&key, wh, kNoID);
- auto threadSafeViewCache = this->threadSafeViewCache();
+ auto threadSafeCache = this->threadSafeCache();
- auto [view, data] = threadSafeViewCache->findWithData(key);
+ auto [view, data] = threadSafeCache->findWithData(key);
if (!view.proxy()) {
return false;
}
@@ -289,14 +284,14 @@
private:
static GrSurfaceProxyView AccessCachedView(GrRecordingContext*,
- GrThreadSafeUniquelyKeyedProxyViewCache*,
+ GrThreadSafeCache*,
int wh,
bool failLookup, bool failFillingIn, int id,
Stats*);
static GrSurfaceProxyView CreateViewOnCpu(GrRecordingContext*, int wh, Stats*);
static bool FillInViewOnGpu(GrDirectContext*, int wh, Stats*,
const GrSurfaceProxyView& lazyView,
- sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline>);
+ sk_sp<GrThreadSafeCache::Trampoline>);
Stats fStats;
GrDirectContext* fDContext = nullptr;
@@ -325,10 +320,9 @@
return {std::move(proxy), kImageOrigin, swizzle};
}
-bool TestHelper::FillInViewOnGpu(
- GrDirectContext* dContext, int wh, Stats* stats,
- const GrSurfaceProxyView& lazyView,
- sk_sp<GrThreadSafeUniquelyKeyedProxyViewCache::Trampoline> trampoline) {
+bool TestHelper::FillInViewOnGpu(GrDirectContext* dContext, int wh, Stats* stats,
+ const GrSurfaceProxyView& lazyView,
+ sk_sp<GrThreadSafeCache::Trampoline> trampoline) {
std::unique_ptr<GrRenderTargetContext> rtc = new_RTC(dContext, wh);
@@ -349,23 +343,22 @@
return true;
}
-GrSurfaceProxyView TestHelper::AccessCachedView(
- GrRecordingContext* rContext,
- GrThreadSafeUniquelyKeyedProxyViewCache* threadSafeViewCache,
- int wh,
- bool failLookup, bool failFillingIn, int id,
- Stats* stats) {
+GrSurfaceProxyView TestHelper::AccessCachedView(GrRecordingContext* rContext,
+ GrThreadSafeCache* threadSafeCache,
+ int wh,
+ bool failLookup, bool failFillingIn, int id,
+ Stats* stats) {
GrUniqueKey key;
create_key(&key, wh, id);
if (GrDirectContext* dContext = rContext->asDirectContext()) {
// The gpu thread gets priority over the recording threads. If the gpu thread is first,
// it crams a lazy proxy into the cache and then fills it in later.
- auto [lazyView, trampoline] = GrThreadSafeUniquelyKeyedProxyViewCache::CreateLazyView(
+ auto [lazyView, trampoline] = GrThreadSafeCache::CreateLazyView(
dContext, GrColorType::kRGBA_8888, {wh, wh}, kImageOrigin, SkBackingFit::kExact);
++stats->fNumLazyCreations;
- auto [view, data] = threadSafeViewCache->findOrAddWithData(key, lazyView);
+ auto [view, data] = threadSafeCache->findOrAddWithData(key, lazyView);
if (view != lazyView) {
++stats->fCacheHits;
return view;
@@ -387,7 +380,7 @@
if (!FillInViewOnGpu(dContext, wh, stats, lazyView, std::move(trampoline))) {
// In this case something has gone disastrously wrong so set up to drop the draw
// that needed this resource and reduce future pollution of the cache.
- threadSafeViewCache->remove(key);
+ threadSafeCache->remove(key);
return {};
}
@@ -396,7 +389,7 @@
GrSurfaceProxyView view;
// We can "fail the lookup" to simulate a threaded race condition
- if (view = threadSafeViewCache->find(key); !failLookup && view) {
+ if (view = threadSafeCache->find(key); !failLookup && view) {
++stats->fCacheHits;
return view;
}
@@ -406,7 +399,7 @@
view = CreateViewOnCpu(rContext, wh, stats);
SkASSERT(view);
- auto [newView, data] = threadSafeViewCache->addWithData(key, view);
+ auto [newView, data] = threadSafeCache->addWithData(key, view);
if (view == newView && id != kNoID) {
// Make sure, in this case, that the customData stuck
SkASSERT(data);
@@ -418,7 +411,7 @@
}
// Case 1: ensure two DDL recorders share the view
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache1, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache1, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.ddlCanvas1(), kImageWH, 1);
@@ -439,7 +432,7 @@
}
// Case 2: ensure that, if the direct context version wins, it is reused by the DDL recorders
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache2, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache2, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.liveCanvas(), kImageWH, 1);
@@ -465,7 +458,7 @@
}
// Case 3: ensure that, if the cpu-version wins, it is reused by the direct context
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache3, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache3, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.ddlCanvas1(), kImageWH, 1);
@@ -486,7 +479,7 @@
}
// Case 4: ensure that, if two DDL recorders get in a race, they still end up sharing a single view
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache4, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache4, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.ddlCanvas1(), kImageWH, 1);
@@ -509,7 +502,7 @@
// Case 4.5: check that, if a live rendering and a DDL recording get into a race, the live
// rendering takes precedence.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache4_5, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache4_5, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.liveCanvas(), kImageWH, 1);
@@ -537,7 +530,7 @@
// Case 4.75: check that, if a live rendering fails to generate the content needed to instantiate
// its lazy proxy, life goes on
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache4_75, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache4_75, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
TestHelper helper(dContext);
@@ -565,17 +558,17 @@
}
// Case 5: ensure that expanding the map works (esp. wrt custom data)
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache5, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache5, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
- auto threadSafeViewCache = helper.threadSafeViewCache();
+ auto threadSafeCache = helper.threadSafeCache();
int size = 16;
helper.accessCachedView(helper.ddlCanvas1(), size, /*id*/ size);
- size_t initialSize = threadSafeViewCache->approxBytesUsedForHash();
+ size_t initialSize = threadSafeCache->approxBytesUsedForHash();
- while (initialSize == threadSafeViewCache->approxBytesUsedForHash()) {
+ while (initialSize == threadSafeCache->approxBytesUsedForHash()) {
size *= 2;
helper.accessCachedView(helper.ddlCanvas1(), size, /*id*/ size);
}
@@ -584,7 +577,7 @@
REPORTER_ASSERT(reporter, helper.checkView(helper.ddlCanvas1(),
/*wh*/ i,
/*hits*/ 0,
- /*misses*/ threadSafeViewCache->numEntries(),
+ /*misses*/ threadSafeCache->numEntries(),
/*refs*/ 1,
/*id*/ i));
}
@@ -592,7 +585,7 @@
// Case 6: Check on dropping refs. In particular, that the cache has its own ref to keep
// the backing resource alive and locked.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache6, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache6, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.ddlCanvas1(), kImageWH);
@@ -624,7 +617,7 @@
// Case 7: Check that invoking dropAllRefs and dropUniqueRefs directly works as expected; i.e.,
// dropAllRefs removes everything while dropUniqueRefs is more measured.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache7, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache7, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.ddlCanvas1(), kImageWH);
@@ -639,17 +632,17 @@
REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
- helper.threadSafeViewCache()->dropUniqueRefs(nullptr);
+ helper.threadSafeCache()->dropUniqueRefs(nullptr);
REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
ddl1 = nullptr;
- helper.threadSafeViewCache()->dropUniqueRefs(nullptr);
+ helper.threadSafeCache()->dropUniqueRefs(nullptr);
REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
REPORTER_ASSERT(reporter, helper.checkView(nullptr, 2*kImageWH,
/*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
- helper.threadSafeViewCache()->dropAllRefs();
+ helper.threadSafeCache()->dropAllRefs();
REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
ddl2 = nullptr;
@@ -658,7 +651,7 @@
// Case 8: This checks that GrContext::abandonContext works as expected wrt the thread
// safe cache. This simulates the case where we have one DDL that has finished
// recording but one still recording when the abandonContext fires.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache8, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache8, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.liveCanvas(), kImageWH);
@@ -692,7 +685,7 @@
// Case 9: This checks that GrContext::releaseResourcesAndAbandonContext works as expected wrt
// the thread safe cache. This simulates the case where we have one DDL that has finished
// recording but one still recording when the releaseResourcesAndAbandonContext fires.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache9, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache9, reporter, ctxInfo) {
TestHelper helper(ctxInfo.directContext());
helper.accessCachedView(helper.liveCanvas(), kImageWH);
@@ -726,7 +719,7 @@
// Case 10: This checks that the GrContext::purgeUnlockedResources(size_t) variant works as
// expected wrt the thread safe cache. It, in particular, tests out the MRU behavior
// of the shared cache.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache10, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache10, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
if (GrBackendApi::kOpenGL != dContext->backend()) {
@@ -791,7 +784,7 @@
// Case 11: This checks that scratch-only variant of GrContext::purgeUnlockedResources works as
// expected wrt the thread safe cache. In particular, that when 'scratchResourcesOnly'
// is true, the call has no effect on the cache.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache11, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache11, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
TestHelper helper(dContext);
@@ -826,7 +819,7 @@
// Case 12: Test out purges caused by resetting the cache budget to 0. Note that, due to
// the how the cache operates (i.e., not directly driven by ref/unrefs) there
// needs to be an explicit kick to purge the cache.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache12, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache12, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
TestHelper helper(dContext);
@@ -865,7 +858,7 @@
}
// Case 13: Test out the 'msNotUsed' parameter to GrContext::performDeferredCleanup.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeViewCache13, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache13, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
TestHelper helper(dContext);