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/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h
index 4b85d9a..06037b1 100644
--- a/include/gpu/GrDirectContext.h
+++ b/include/gpu/GrDirectContext.h
@@ -151,6 +151,57 @@
      */
     void releaseResourcesAndAbandonContext();
 
+    ///////////////////////////////////////////////////////////////////////////
+    // Resource Cache
+
+    /** DEPRECATED
+     *  Return the current GPU resource cache limits.
+     *
+     *  @param maxResources If non-null, will be set to -1.
+     *  @param maxResourceBytes If non-null, returns maximum number of bytes of
+     *                          video memory that can be held in the cache.
+     */
+    void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const;
+
+    /**
+     *  Return the current GPU resource cache limit in bytes.
+     */
+    size_t getResourceCacheLimit() const;
+
+    /**
+     *  Gets the current GPU resource cache usage.
+     *
+     *  @param resourceCount If non-null, returns the number of resources that are held in the
+     *                       cache.
+     *  @param maxResourceBytes If non-null, returns the total number of bytes of video memory held
+     *                          in the cache.
+     */
+    void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const;
+
+    /**
+     *  Gets the number of bytes in the cache consumed by purgeable (e.g. unlocked) resources.
+     */
+    size_t getResourceCachePurgeableBytes() const;
+
+    /** DEPRECATED
+     *  Specify the GPU resource cache limits. If the current cache exceeds the maxResourceBytes
+     *  limit, it will be purged (LRU) to keep the cache within the limit.
+     *
+     *  @param maxResources Unused.
+     *  @param maxResourceBytes The maximum number of bytes of video memory
+     *                          that can be held in the cache.
+     */
+    void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
+
+    /**
+     *  Specify the GPU resource cache limit. If the cache currently exceeds this limit,
+     *  it will be purged (LRU) to keep the cache within the limit.
+     *
+     *  @param maxResourceBytes The maximum number of bytes of video memory
+     *                          that can be held in the cache.
+     */
+    void setResourceCacheLimit(size_t maxResourceBytes);
+
     void freeGpuResources() override;
 
 protected:
diff --git a/include/private/GrContext.h b/include/private/GrContext.h
index a573d04..d768fb7 100644
--- a/include/private/GrContext.h
+++ b/include/private/GrContext.h
@@ -57,57 +57,6 @@
 public:
     ~GrContext() override;
 
-    ///////////////////////////////////////////////////////////////////////////
-    // Resource Cache
-
-    /** DEPRECATED
-     *  Return the current GPU resource cache limits.
-     *
-     *  @param maxResources If non-null, will be set to -1.
-     *  @param maxResourceBytes If non-null, returns maximum number of bytes of
-     *                          video memory that can be held in the cache.
-     */
-    void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const;
-
-    /**
-     *  Return the current GPU resource cache limit in bytes.
-     */
-    size_t getResourceCacheLimit() const;
-
-    /**
-     *  Gets the current GPU resource cache usage.
-     *
-     *  @param resourceCount If non-null, returns the number of resources that are held in the
-     *                       cache.
-     *  @param maxResourceBytes If non-null, returns the total number of bytes of video memory held
-     *                          in the cache.
-     */
-    void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const;
-
-    /**
-     *  Gets the number of bytes in the cache consumed by purgeable (e.g. unlocked) resources.
-     */
-    size_t getResourceCachePurgeableBytes() const;
-
-    /** DEPRECATED
-     *  Specify the GPU resource cache limits. If the current cache exceeds the maxResourceBytes
-     *  limit, it will be purged (LRU) to keep the cache within the limit.
-     *
-     *  @param maxResources Unused.
-     *  @param maxResourceBytes The maximum number of bytes of video memory
-     *                          that can be held in the cache.
-     */
-    void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
-
-    /**
-     *  Specify the GPU resource cache limit. If the cache currently exceeds this limit,
-     *  it will be purged (LRU) to keep the cache within the limit.
-     *
-     *  @param maxResourceBytes The maximum number of bytes of video memory
-     *                          that can be held in the cache.
-     */
-    void setResourceCacheLimit(size_t maxResourceBytes);
-
     /**
      * Frees GPU created by the context. Can be called to reduce GPU memory
      * pressure.
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 4305a31..2788aae 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -122,22 +122,6 @@
     fResourceCache->purgeUnlockedResources(bytesToPurge, preferScratchResources);
 }
 
-void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
-    ASSERT_SINGLE_OWNER
-
-    if (resourceCount) {
-        *resourceCount = fResourceCache->getBudgetedResourceCount();
-    }
-    if (resourceBytes) {
-        *resourceBytes = fResourceCache->getBudgetedResourceBytes();
-    }
-}
-
-size_t GrContext::getResourceCachePurgeableBytes() const {
-    ASSERT_SINGLE_OWNER
-    return fResourceCache->getPurgeableBytes();
-}
-
 size_t GrContext::ComputeImageSize(sk_sp<SkImage> image, GrMipmapped mipMapped, bool useNextPow2) {
     if (!image->isTextureBacked()) {
         return 0;
@@ -232,33 +216,6 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
-
-void GrContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const {
-    ASSERT_SINGLE_OWNER
-    if (maxResources) {
-        *maxResources = -1;
-    }
-    if (maxResourceBytes) {
-        *maxResourceBytes = this->getResourceCacheLimit();
-    }
-}
-
-size_t GrContext::getResourceCacheLimit() const {
-    ASSERT_SINGLE_OWNER
-    return fResourceCache->getMaxResourceBytes();
-}
-
-void GrContext::setResourceCacheLimits(int unused, size_t maxResourceBytes) {
-    ASSERT_SINGLE_OWNER
-    this->setResourceCacheLimit(maxResourceBytes);
-}
-
-void GrContext::setResourceCacheLimit(size_t maxResourceBytes) {
-    ASSERT_SINGLE_OWNER
-    fResourceCache->setLimit(maxResourceBytes);
-}
-
-//////////////////////////////////////////////////////////////////////////////
 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
     ASSERT_SINGLE_OWNER
     fResourceCache->dumpMemoryStatistics(traceMemoryDump);
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>();