diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 19:21:16 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 19:21:16 +0000 |
commit | d0ea8772b73c1be1cc5f4c53233ee13d8bbe299f (patch) | |
tree | 824a390c9c8024879c745aa8966cb48ba8044800 | |
parent | 5aecd54686a0debdd8581deafdce873bdae92e0c (diff) | |
download | src-d0ea8772b73c1be1cc5f4c53233ee13d8bbe299f.tar.gz |
Allow custom resources in the GrContext's cache
Adds methods to GrContext for client code to store custom resources in
the cache.
BUG=skia:
R=bsalomon@google.com
Author: cdalton@nvidia.com
Review URL: https://codereview.chromium.org/261593009
git-svn-id: http://skia.googlecode.com/svn/trunk/src@14577 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gpu/GrContext.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gpu/GrContext.cpp b/gpu/GrContext.cpp index c518a1c8..d2664c3b 100644 --- a/gpu/GrContext.cpp +++ b/gpu/GrContext.cpp @@ -1825,6 +1825,17 @@ GrPath* GrContext::createPath(const SkPath& inPath, const SkStrokeRec& stroke) { return path; } +void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrCacheable* resource) { + fTextureCache->purgeAsNeeded(1, resource->gpuMemorySize()); + fTextureCache->addResource(resourceKey, resource); +} + +GrCacheable* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKey) { + GrCacheable* resource = fTextureCache->find(resourceKey); + SkSafeRef(resource); + return resource; +} + /////////////////////////////////////////////////////////////////////////////// #if GR_CACHE_STATS void GrContext::printCacheStats() const { |