Expose functionality to purge the GPU texture cache while running SampleApp.

Press 'p' to purge the cache.  A summary of the number of bytes of video memory
released is output to the command prompt.
Review URL: https://codereview.appspot.com/5587045

git-svn-id: http://skia.googlecode.com/svn/trunk@3097 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
twiz@google.com 2012-01-27 19:12:00 +00:00
Родитель 78c6ed0a59
Коммит 05e70247c3
4 изменённых файлов: 25 добавлений и 2 удалений

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

@ -75,6 +75,11 @@ public:
*/
void freeGpuResources();
/**
* Returns the number of bytes of GPU memory hosted by the texture cache.
*/
size_t getGpuTextureCacheBytes() const;
///////////////////////////////////////////////////////////////////////////
// Textures
@ -858,4 +863,3 @@ private:
};
#endif

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

@ -1537,6 +1537,17 @@ bool SampleWindow::onHandleChar(SkUnichar uni) {
this->updateTitle();
}
return true;
case 'p':
{
GrContext* grContext = this->getGrContext();
if (grContext) {
size_t cacheBytes = grContext->getGpuTextureCacheBytes();
grContext->freeGpuResources();
SkDebugf("Purged %d bytes from the GPU resource cache.\n",
cacheBytes);
}
}
return true;
case 's':
fScale = !fScale;
this->inval(NULL);

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

@ -115,6 +115,10 @@ void GrContext::freeGpuResources() {
GrSafeSetNull(fPathRendererChain);
}
size_t GrContext::getGpuTextureCacheBytes() const {
return fTextureCache->getCachedResourceBytes();
}
////////////////////////////////////////////////////////////////////////////////
int GrContext::PaintStageVertexLayoutBits(

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

@ -208,6 +208,11 @@ public:
*/
void setLimits(int maxResource, size_t maxResourceBytes);
/**
* Returns the number of bytes consumed by cached resources.
*/
size_t getCachedResourceBytes() const { return fEntryBytes; }
/**
* Controls whether locks should be nestable or not.
*/
@ -315,4 +320,3 @@ private:
#endif
#endif