Migrate resource cache methods to GrDirectContext
Cut and paste job.
Change-Id: If9b7e0f74b16b2559dc4149f81720df96b09761e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325461
Auto-Submit: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 9436c44..dcdcc47 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -225,6 +225,47 @@
return true;
}
+void GrDirectContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
+ ASSERT_SINGLE_OWNER
+
+ if (resourceCount) {
+ *resourceCount = fResourceCache->getBudgetedResourceCount();
+ }
+ if (resourceBytes) {
+ *resourceBytes = fResourceCache->getBudgetedResourceBytes();
+ }
+}
+
+size_t GrDirectContext::getResourceCachePurgeableBytes() const {
+ ASSERT_SINGLE_OWNER
+ return fResourceCache->getPurgeableBytes();
+}
+
+void GrDirectContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const {
+ ASSERT_SINGLE_OWNER
+ if (maxResources) {
+ *maxResources = -1;
+ }
+ if (maxResourceBytes) {
+ *maxResourceBytes = this->getResourceCacheLimit();
+ }
+}
+
+size_t GrDirectContext::getResourceCacheLimit() const {
+ ASSERT_SINGLE_OWNER
+ return fResourceCache->getMaxResourceBytes();
+}
+
+void GrDirectContext::setResourceCacheLimits(int unused, size_t maxResourceBytes) {
+ ASSERT_SINGLE_OWNER
+ this->setResourceCacheLimit(maxResourceBytes);
+}
+
+void GrDirectContext::setResourceCacheLimit(size_t maxResourceBytes) {
+ ASSERT_SINGLE_OWNER
+ fResourceCache->setLimit(maxResourceBytes);
+}
+
GrSmallPathAtlasMgr* GrDirectContext::onGetSmallPathAtlasMgr() {
if (!fSmallPathAtlasMgr) {
fSmallPathAtlasMgr = std::make_unique<GrSmallPathAtlasMgr>();