cleanup GrContext resource cache api

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/275563005

git-svn-id: http://skia.googlecode.com/svn/trunk@14669 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-09 14:29:32 +00:00
Родитель 063e6b40a3
Коммит 95c2003740
9 изменённых файлов: 153 добавлений и 123 удалений

Просмотреть файл

@ -433,14 +433,14 @@ int tool_main(int argc, char** argv) {
size_t bytes;
int count;
context->getTextureCacheLimits(&count, &bytes);
context->getResourceCacheLimits(&count, &bytes);
if (-1 != FLAGS_gpuCacheBytes) {
bytes = static_cast<size_t>(FLAGS_gpuCacheBytes);
}
if (-1 != FLAGS_gpuCacheCount) {
count = FLAGS_gpuCacheCount;
}
context->setTextureCacheLimits(count, bytes);
context->setResourceCacheLimits(count, bytes);
#endif
}

Просмотреть файл

@ -1774,14 +1774,14 @@ ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm,
// Set the user specified cache limits if non-default.
size_t bytes;
int count;
gr->getTextureCacheLimits(&count, &bytes);
gr->getResourceCacheLimits(&count, &bytes);
if (DEFAULT_CACHE_VALUE != gGpuCacheSizeBytes) {
bytes = static_cast<size_t>(gGpuCacheSizeBytes);
}
if (DEFAULT_CACHE_VALUE != gGpuCacheSizeCount) {
count = gGpuCacheSizeCount;
}
gr->setTextureCacheLimits(count, bytes);
gr->setResourceCacheLimits(count, bytes);
}
}
if (!grSuccess) {

Просмотреть файл

@ -102,6 +102,62 @@ public:
*/
void contextDestroyed();
///////////////////////////////////////////////////////////////////////////
// Resource Cache
/**
* Return the current GPU resource cache limits.
*
* @param maxResources If non-null, returns maximum number of resources that
* can be held in the cache.
* @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;
SK_ATTR_DEPRECATED("This function has been renamed to getResourceCacheLimits().")
void getTextureCacheLimits(int* maxTextures, size_t* maxTextureBytes) const {
this->getResourceCacheLimits(maxTextures, maxTextureBytes);
}
/**
* 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;
SK_ATTR_DEPRECATED("Use getResourceCacheUsage().")
size_t getGpuTextureCacheBytes() const {
size_t bytes;
this->getResourceCacheUsage(NULL, &bytes);
return bytes;
}
SK_ATTR_DEPRECATED("Use getResourceCacheUsage().")
int getGpuTextureCacheResourceCount() const {
int count;
this->getResourceCacheUsage(&count, NULL);
return count;
}
/**
* Specify the GPU resource cache limits. If the current cache exceeds either
* of these, it will be purged (LRU) to keep the cache within these limits.
*
* @param maxResources The maximum number of resources that can be held in
* the cache.
* @param maxResourceBytes The maximum number of bytes of video memory
* that can be held in the cache.
*/
void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
SK_ATTR_DEPRECATED("This function has been renamed to setResourceCacheLimits().")
void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes) {
this->setResourceCacheLimits(maxTextures, maxTextureBytes);
}
/**
* Frees GPU created by the context. Can be called to reduce GPU memory
* pressure.
@ -109,14 +165,32 @@ public:
void freeGpuResources();
/**
* Returns the number of bytes of GPU memory hosted by the texture cache.
* This method should be called whenever a GrResource is unreffed or
* switched from exclusive to non-exclusive. This
* gives the resource cache a chance to discard unneeded resources.
* Note: this entry point will be removed once totally ref-driven
* cache maintenance is implemented.
*/
size_t getGpuTextureCacheBytes() const;
void purgeCache();
/**
* Returns the number of resources hosted by the texture cache.
* Purge all the unlocked resources from the cache.
* This entry point is mainly meant for timing texture uploads
* and is not defined in normal builds of Skia.
*/
int getGpuTextureCacheResourceCount() const;
void purgeAllUnlockedResources();
/**
* Stores a custom resource in the cache, based on the specified key.
*/
void addResourceToCache(const GrResourceKey&, GrCacheable*);
/**
* Finds a resource in the cache, based on the specified key. This is intended for use in
* conjunction with addResourceToCache(). The return value will be NULL if not found. The
* caller must balance with a call to unref().
*/
GrCacheable* findAndRefCachedResource(const GrResourceKey&);
///////////////////////////////////////////////////////////////////////////
// Textures
@ -207,22 +281,6 @@ public:
*/
void unlockScratchTexture(GrTexture* texture);
/**
* This method should be called whenever a GrTexture is unreffed or
* switched from exclusive to non-exclusive. This
* gives the resource cache a chance to discard unneeded textures.
* Note: this entry point will be removed once totally ref-driven
* cache maintenance is implemented
*/
void purgeCache();
/**
* Purge all the unlocked resources from the cache.
* This entry point is mainly meant for timing texture uploads
* and is not defined in normal builds of Skia.
*/
void purgeAllUnlockedResources();
/**
* Creates a texture that is outside the cache. Does not count against
* cache's budget.
@ -241,27 +299,6 @@ public:
int width,
int height) const;
/**
* Return the current texture cache limits.
*
* @param maxTextures If non-null, returns maximum number of textures that
* can be held in the cache.
* @param maxTextureBytes If non-null, returns maximum number of bytes of
* texture memory that can be held in the cache.
*/
void getTextureCacheLimits(int* maxTextures, size_t* maxTextureBytes) const;
/**
* Specify the texture cache limits. If the current cache exceeds either
* of these, it will be purged (LRU) to keep the cache within these limits.
*
* @param maxTextures The maximum number of textures that can be held in
* the cache.
* @param maxTextureBytes The maximum number of bytes of texture memory
* that can be held in the cache.
*/
void setTextureCacheLimits(int maxTextures, size_t maxTextureBytes);
/**
* Return the max width or height of a texture supported by the current GPU.
*/
@ -294,8 +331,6 @@ public:
const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); }
GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; }
/**
* Can the provided configuration act as a color render target?
*/
@ -642,7 +677,6 @@ public:
size_t rowBytes,
uint32_t pixelOpsFlags = 0);
/**
* Copies a rectangle of texels from src to dst. The size of dst is the size of the rectangle
* copied and topLeft is the position of the rect in src. The rectangle is clipped to src's
@ -875,6 +909,7 @@ public:
GrLayerCache* getLayerCache() { return fLayerCache.get(); }
GrDrawTarget* getTextTarget();
const GrIndexBuffer* getQuadIndexBuffer() const;
GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; }
// Called by tests that draw directly to the context via GrDrawTarget
void getTestTarget(GrTestTarget*);
@ -899,18 +934,6 @@ public:
GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType,
GrPathRendererChain::StencilSupport* stencilSupport = NULL);
/**
* Stores a custom resource in the cache, based on the specified key.
*/
void addResourceToCache(const GrResourceKey&, GrCacheable*);
/**
* Finds a resource in the cache, based on the specified key. This is intended for use in
* conjunction with addResourceToCache(). The return value will be NULL if not found. The
* caller must balance with a call to unref().
*/
GrCacheable* findAndRefCachedResource(const GrResourceKey&);
#if GR_CACHE_STATS
void printCacheStats() const;
#endif
@ -929,7 +952,7 @@ private:
const GrClipData* fClip; // TODO: make this ref counted
GrDrawState* fDrawState;
GrResourceCache* fTextureCache;
GrResourceCache* fResourceCache;
GrFontCache* fFontCache;
SkAutoTDelete<GrLayerCache> fLayerCache;

Просмотреть файл

@ -1863,10 +1863,10 @@ bool SampleWindow::onHandleChar(SkUnichar uni) {
{
GrContext* grContext = this->getGrContext();
if (grContext) {
size_t cacheBytes = grContext->getGpuTextureCacheBytes();
size_t cacheBytes;
grContext->getResourceCacheUsage(NULL, &cacheBytes);
grContext->freeGpuResources();
SkDebugf("Purged %d bytes from the GPU resource cache.\n",
cacheBytes);
SkDebugf("Purged %d bytes from the GPU resource cache.\n", cacheBytes);
}
}
return true;

Просмотреть файл

@ -94,7 +94,7 @@ GrContext::GrContext() {
fClip = NULL;
fPathRendererChain = NULL;
fSoftwarePathRenderer = NULL;
fTextureCache = NULL;
fResourceCache = NULL;
fFontCache = NULL;
fDrawBuffer = NULL;
fDrawBufferVBAllocPool = NULL;
@ -118,10 +118,9 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
fDrawState = SkNEW(GrDrawState);
fGpu->setDrawState(fDrawState);
fTextureCache = SkNEW_ARGS(GrResourceCache,
(MAX_RESOURCE_CACHE_COUNT,
MAX_RESOURCE_CACHE_BYTES));
fTextureCache->setOverbudgetCallback(OverbudgetCB, this);
fResourceCache = SkNEW_ARGS(GrResourceCache, (MAX_RESOURCE_CACHE_COUNT,
MAX_RESOURCE_CACHE_BYTES));
fResourceCache->setOverbudgetCallback(OverbudgetCB, this);
fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
@ -154,8 +153,8 @@ GrContext::~GrContext() {
// of them before freeing the texture cache
fGpu->purgeResources();
delete fTextureCache;
fTextureCache = NULL;
delete fResourceCache;
fResourceCache = NULL;
delete fFontCache;
delete fDrawBuffer;
delete fDrawBufferVBAllocPool;
@ -197,7 +196,7 @@ void GrContext::contextDestroyed() {
fAARectRenderer->reset();
fOvalRenderer->reset();
fTextureCache->purgeAllUnlocked();
fResourceCache->purgeAllUnlocked();
fFontCache->freeAll();
fLayerCache->freeAll();
@ -216,7 +215,7 @@ void GrContext::freeGpuResources() {
fAARectRenderer->reset();
fOvalRenderer->reset();
fTextureCache->purgeAllUnlocked();
fResourceCache->purgeAllUnlocked();
fFontCache->freeAll();
fLayerCache->freeAll();
// a path renderer may be holding onto resources
@ -224,12 +223,13 @@ void GrContext::freeGpuResources() {
SkSafeSetNull(fSoftwarePathRenderer);
}
size_t GrContext::getGpuTextureCacheBytes() const {
return fTextureCache->getCachedResourceBytes();
}
int GrContext::getGpuTextureCacheResourceCount() const {
return fTextureCache->getCachedResourceCount();
void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
if (NULL != resourceCount) {
*resourceCount = fResourceCache->getCachedResourceCount();
}
if (NULL != resourceBytes) {
*resourceBytes = fResourceCache->getCachedResourceBytes();
}
}
////////////////////////////////////////////////////////////////////////////////
@ -238,7 +238,7 @@ GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) {
GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID);
GrCacheable* resource = fTextureCache->find(resourceKey);
GrCacheable* resource = fResourceCache->find(resourceKey);
SkSafeRef(resource);
return static_cast<GrTexture*>(resource);
}
@ -247,7 +247,7 @@ bool GrContext::isTextureInCache(const GrTextureDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) const {
GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID);
return fTextureCache->hasKey(resourceKey);
return fResourceCache->hasKey(resourceKey);
}
void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
@ -256,7 +256,7 @@ void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
sb->height(),
sb->numSamples());
fTextureCache->addResource(resourceKey, sb);
fResourceCache->addResource(resourceKey, sb);
}
GrStencilBuffer* GrContext::findStencilBuffer(int width, int height,
@ -264,7 +264,7 @@ GrStencilBuffer* GrContext::findStencilBuffer(int width, int height,
GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width,
height,
sampleCnt);
GrCacheable* resource = fTextureCache->find(resourceKey);
GrCacheable* resource = fResourceCache->find(resourceKey);
return static_cast<GrStencilBuffer*>(resource);
}
@ -397,8 +397,8 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params,
if (NULL != texture) {
// Adding a resource could put us overbudget. Try to free up the
// necessary space before adding it.
fTextureCache->purgeAsNeeded(1, texture->gpuMemorySize());
fTextureCache->addResource(resourceKey, texture);
fResourceCache->purgeAsNeeded(1, texture->gpuMemorySize());
fResourceCache->addResource(resourceKey, texture);
if (NULL != cacheKey) {
*cacheKey = resourceKey;
@ -409,16 +409,16 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params,
}
static GrTexture* create_scratch_texture(GrGpu* gpu,
GrResourceCache* textureCache,
GrResourceCache* resourceCache,
const GrTextureDesc& desc) {
GrTexture* texture = gpu->createTexture(desc, NULL, 0);
if (NULL != texture) {
GrResourceKey key = GrTexture::ComputeScratchKey(texture->desc());
// Adding a resource could put us overbudget. Try to free up the
// necessary space before adding it.
textureCache->purgeAsNeeded(1, texture->gpuMemorySize());
resourceCache->purgeAsNeeded(1, texture->gpuMemorySize());
// Make the resource exclusive so future 'find' calls don't return it
textureCache->addResource(key, texture, GrResourceCache::kHide_OwnershipFlag);
resourceCache->addResource(key, texture, GrResourceCache::kHide_OwnershipFlag);
}
return texture;
}
@ -436,7 +436,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
if (!fGpu->caps()->reuseScratchTextures() &&
!(inDesc.fFlags & kRenderTarget_GrTextureFlagBit)) {
// If we're never recycling this texture we can always make it the right size
return create_scratch_texture(fGpu, fTextureCache, inDesc);
return create_scratch_texture(fGpu, fResourceCache, inDesc);
}
GrTextureDesc desc = inDesc;
@ -455,7 +455,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
do {
GrResourceKey key = GrTexture::ComputeScratchKey(desc);
// Ensure we have exclusive access to the texture so future 'find' calls don't return it
resource = fTextureCache->find(key, GrResourceCache::kHide_OwnershipFlag);
resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFlag);
if (NULL != resource) {
resource->ref();
break;
@ -480,7 +480,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
desc.fFlags = inDesc.fFlags;
desc.fWidth = origWidth;
desc.fHeight = origHeight;
resource = create_scratch_texture(fGpu, fTextureCache, desc);
resource = create_scratch_texture(fGpu, fResourceCache, desc);
}
return static_cast<GrTexture*>(resource);
@ -503,13 +503,13 @@ void GrContext::addExistingTextureToCache(GrTexture* texture) {
if (fGpu->caps()->reuseScratchTextures() || NULL != texture->asRenderTarget()) {
// Since this texture came from an AutoScratchTexture it should
// still be in the exclusive pile. Recycle it.
fTextureCache->makeNonExclusive(texture->getCacheEntry());
fResourceCache->makeNonExclusive(texture->getCacheEntry());
this->purgeCache();
} else if (texture->getDeferredRefCount() <= 0) {
// When we aren't reusing textures we know this scratch texture
// will never be reused and would be just wasting time in the cache
fTextureCache->makeNonExclusive(texture->getCacheEntry());
fTextureCache->deleteResource(texture->getCacheEntry());
fResourceCache->makeNonExclusive(texture->getCacheEntry());
fResourceCache->deleteResource(texture->getCacheEntry());
} else {
// In this case (fDeferredRefCount > 0) but the cache is the only
// one holding a real ref. Mark the object so when the deferred
@ -529,14 +529,14 @@ void GrContext::unlockScratchTexture(GrTexture* texture) {
// the same texture).
if (texture->getCacheEntry()->key().isScratch()) {
if (fGpu->caps()->reuseScratchTextures() || NULL != texture->asRenderTarget()) {
fTextureCache->makeNonExclusive(texture->getCacheEntry());
fResourceCache->makeNonExclusive(texture->getCacheEntry());
this->purgeCache();
} else if (texture->unique() && texture->getDeferredRefCount() <= 0) {
// Only the cache now knows about this texture. Since we're never
// reusing scratch textures (in this code path) it would just be
// wasting time sitting in the cache.
fTextureCache->makeNonExclusive(texture->getCacheEntry());
fTextureCache->deleteResource(texture->getCacheEntry());
fResourceCache->makeNonExclusive(texture->getCacheEntry());
fResourceCache->deleteResource(texture->getCacheEntry());
} else {
// In this case (fRefCnt > 1 || defRefCnt > 0) but we don't really
// want to readd it to the cache (since it will never be reused).
@ -551,8 +551,8 @@ void GrContext::unlockScratchTexture(GrTexture* texture) {
}
void GrContext::purgeCache() {
if (NULL != fTextureCache) {
fTextureCache->purgeAsNeeded();
if (NULL != fResourceCache) {
fResourceCache->purgeAsNeeded();
}
}
@ -575,13 +575,12 @@ GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn,
return fGpu->createTexture(descCopy, srcData, rowBytes);
}
void GrContext::getTextureCacheLimits(int* maxTextures,
size_t* maxTextureBytes) const {
fTextureCache->getLimits(maxTextures, maxTextureBytes);
void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const {
fResourceCache->getLimits(maxTextures, maxTextureBytes);
}
void GrContext::setTextureCacheLimits(int maxTextures, size_t maxTextureBytes) {
fTextureCache->setLimits(maxTextures, maxTextureBytes);
void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
fResourceCache->setLimits(maxTextures, maxTextureBytes);
}
int GrContext::getMaxTextureSize() const {
@ -1812,26 +1811,26 @@ const GrEffectRef* GrContext::createUPMToPMEffect(GrTexture* texture,
GrPath* GrContext::createPath(const SkPath& inPath, const SkStrokeRec& stroke) {
SkASSERT(fGpu->caps()->pathRenderingSupport());
// TODO: now we add to fTextureCache. This should change to fResourceCache.
// TODO: now we add to fResourceCache. This should change to fResourceCache.
GrResourceKey resourceKey = GrPath::ComputeKey(inPath, stroke);
GrPath* path = static_cast<GrPath*>(fTextureCache->find(resourceKey));
GrPath* path = static_cast<GrPath*>(fResourceCache->find(resourceKey));
if (NULL != path && path->isEqualTo(inPath, stroke)) {
path->ref();
} else {
path = fGpu->createPath(inPath, stroke);
fTextureCache->purgeAsNeeded(1, path->gpuMemorySize());
fTextureCache->addResource(resourceKey, path);
fResourceCache->purgeAsNeeded(1, path->gpuMemorySize());
fResourceCache->addResource(resourceKey, path);
}
return path;
}
void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrCacheable* resource) {
fTextureCache->purgeAsNeeded(1, resource->gpuMemorySize());
fTextureCache->addResource(resourceKey, resource);
fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize());
fResourceCache->addResource(resourceKey, resource);
}
GrCacheable* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKey) {
GrCacheable* resource = fTextureCache->find(resourceKey);
GrCacheable* resource = fResourceCache->find(resourceKey);
SkSafeRef(resource);
return resource;
}
@ -1839,6 +1838,6 @@ GrCacheable* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKe
///////////////////////////////////////////////////////////////////////////////
#if GR_CACHE_STATS
void GrContext::printCacheStats() const {
fTextureCache->printStats();
fResourceCache->printStats();
}
#endif

Просмотреть файл

@ -38,5 +38,5 @@ void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) {
}
void GrContext::purgeAllUnlockedResources() {
fTextureCache->purgeAllUnlocked();
fResourceCache->purgeAllUnlocked();
}

Просмотреть файл

@ -1080,7 +1080,7 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
// a texture
size_t bmpSize = bitmap.getSize();
size_t cacheSize;
fContext->getTextureCacheLimits(NULL, &cacheSize);
fContext->getResourceCacheLimits(NULL, &cacheSize);
if (bmpSize < cacheSize / 2) {
return false;
}

Просмотреть файл

@ -26,16 +26,17 @@ static void test_cache(skiatest::Reporter* reporter,
src.eraseColor(SK_ColorBLACK);
size_t srcSize = src.getSize();
size_t initialCacheSize = context->getGpuTextureCacheBytes();
size_t initialCacheSize;
context->getResourceCacheUsage(NULL, &initialCacheSize);
int oldMaxNum;
size_t oldMaxBytes;
context->getTextureCacheLimits(&oldMaxNum, &oldMaxBytes);
context->getResourceCacheLimits(&oldMaxNum, &oldMaxBytes);
// Set the cache limits so we can fit 10 "src" images and the
// max number of textures doesn't matter
size_t maxCacheSize = initialCacheSize + 10*srcSize;
context->setTextureCacheLimits(1000, maxCacheSize);
context->setResourceCacheLimits(1000, maxCacheSize);
SkBitmap readback;
readback.allocN32Pixels(size.width(), size.height());
@ -47,13 +48,14 @@ static void test_cache(skiatest::Reporter* reporter,
// "modify" the src texture
src.notifyPixelsChanged();
size_t curCacheSize = context->getGpuTextureCacheBytes();
size_t curCacheSize;
context->getResourceCacheUsage(NULL, &curCacheSize);
// we should never go over the size limit
REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize);
}
context->setTextureCacheLimits(oldMaxNum, oldMaxBytes);
context->setResourceCacheLimits(oldMaxNum, oldMaxBytes);
}
class TestResource : public GrCacheable {

Просмотреть файл

@ -304,21 +304,27 @@ static void TestSurfaceInCache(skiatest::Reporter* reporter,
SurfaceType surfaceType,
GrContext* context) {
context->freeGpuResources();
REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount());
int resourceCount;
context->getResourceCacheUsage(&resourceCount, NULL);
REPORTER_ASSERT(reporter, 0 == resourceCount);
SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context));
// Note: the stencil buffer is always cached, so kGpu_SurfaceType uses
// one cached resource, and kGpuScratch_SurfaceType uses two.
int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1;
REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureCacheResourceCount());
context->getResourceCacheUsage(&resourceCount, NULL);
REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
// Verify that all the cached resources are locked in cache.
context->freeGpuResources();
REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureCacheResourceCount());
context->getResourceCacheUsage(&resourceCount, NULL);
REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
// Verify that all the cached resources are unlocked upon surface release
surface.reset(0);
context->freeGpuResources();
REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount());
context->getResourceCacheUsage(&resourceCount, NULL);
REPORTER_ASSERT(reporter, 0 == resourceCount);
}
static void Test_crbug263329(skiatest::Reporter* reporter,