зеркало из https://github.com/mozilla/moz-skia.git
add getter/setter for TextureCache, so that clients can make their budget
decisions at runtime or per-context, rather than just at compile-time. Leaving in the default values as is. git-svn-id: http://skia.googlecode.com/svn/trunk@709 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
63100f9e36
Коммит
01804b44f9
|
@ -287,6 +287,29 @@ public:
|
|||
GrRenderTarget* fPrevTarget;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/* -------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
|
|
@ -193,6 +193,27 @@ public:
|
|||
GrTextureCache(int maxCount, size_t maxBytes);
|
||||
~GrTextureCache(); // uses kFreeTexture_DeleteMode
|
||||
|
||||
/**
|
||||
* 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 getLimits(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 setLimits(int maxTextures, size_t maxTextureBytes);
|
||||
|
||||
/**
|
||||
* Search for an entry with the same Key. If found, "lock" it and return it.
|
||||
* If not found, return null.
|
||||
|
@ -254,8 +275,8 @@ private:
|
|||
GrTextureEntry* fTail;
|
||||
|
||||
// our budget, used in purgeAsNeeded()
|
||||
const int fMaxCount;
|
||||
const size_t fMaxBytes;
|
||||
int fMaxCount;
|
||||
size_t fMaxBytes;
|
||||
|
||||
// our current stats, related to our budget
|
||||
int fEntryCount;
|
||||
|
|
|
@ -232,6 +232,17 @@ GrTexture* GrContext::createUncachedTexture(const GrGpu::TextureDesc& desc,
|
|||
return fGpu->createTexture(desc, srcData, rowBytes);
|
||||
}
|
||||
|
||||
void GrContext::getTextureCacheLimits(int* maxTextures,
|
||||
size_t* maxTextureBytes) const {
|
||||
fTextureCache->getLimits(maxTextures, maxTextureBytes);
|
||||
}
|
||||
|
||||
void GrContext::setTextureCacheLimits(int maxTextures, size_t maxTextureBytes) {
|
||||
fTextureCache->setLimits(maxTextures, maxTextureBytes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrRenderTarget* GrContext::createPlatformRenderTarget(intptr_t platformRenderTarget,
|
||||
int width, int height) {
|
||||
return fGpu->createPlatformRenderTarget(platformRenderTarget,
|
||||
|
|
|
@ -58,6 +58,26 @@ GrTextureCache::~GrTextureCache() {
|
|||
this->deleteAll(kFreeTexture_DeleteMode);
|
||||
}
|
||||
|
||||
void GrTextureCache::getLimits(int* maxTextures, size_t* maxTextureBytes) const{
|
||||
if (maxTextures) {
|
||||
*maxTextures = fMaxCount;
|
||||
}
|
||||
if (maxTextureBytes) {
|
||||
*maxTextureBytes = fMaxBytes;
|
||||
}
|
||||
}
|
||||
|
||||
void GrTextureCache::setLimits(int maxTextures, size_t maxTextureBytes) {
|
||||
bool smaller = (maxTextures < fMaxCount) || (maxTextureBytes < fMaxBytes);
|
||||
|
||||
fMaxCount = maxTextures;
|
||||
fMaxBytes = maxTextureBytes;
|
||||
|
||||
if (smaller) {
|
||||
this->purgeAsNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
void GrTextureCache::internalDetach(GrTextureEntry* entry,
|
||||
bool clientDetach) {
|
||||
GrTextureEntry* prev = entry->fPrev;
|
||||
|
|
Загрузка…
Ссылка в новой задаче