зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1060200 (Part 2) - Add SurfaceCache::RemoveIfPresent so invalid entries can be freed eagerly. r=dholbert
This commit is contained in:
Родитель
9b9d1e1c9f
Коммит
721363b4e5
|
@ -339,6 +339,20 @@ public:
|
|||
return ref;
|
||||
}
|
||||
|
||||
void RemoveIfPresent(const ImageKey aImageKey,
|
||||
const SurfaceKey& aSurfaceKey)
|
||||
{
|
||||
nsRefPtr<ImageSurfaceCache> cache = GetImageCache(aImageKey);
|
||||
if (!cache)
|
||||
return; // No cached surfaces for this image.
|
||||
|
||||
nsRefPtr<CachedSurface> surface = cache->Lookup(aSurfaceKey);
|
||||
if (!surface)
|
||||
return; // Lookup in the per-image cache missed.
|
||||
|
||||
Remove(surface);
|
||||
}
|
||||
|
||||
bool CanHold(const Cost aCost) const
|
||||
{
|
||||
return aCost <= mMaxCost;
|
||||
|
@ -537,6 +551,16 @@ SurfaceCache::CanHold(const IntSize& aSize)
|
|||
return sInstance->CanHold(cost);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
SurfaceCache::RemoveIfPresent(const ImageKey aImageKey,
|
||||
const SurfaceKey& aSurfaceKey)
|
||||
{
|
||||
MOZ_ASSERT(sInstance, "Should be initialized");
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
return sInstance->RemoveIfPresent(aImageKey, aSurfaceKey);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
SurfaceCache::Discard(Image* aImageKey)
|
||||
{
|
||||
|
|
|
@ -183,6 +183,18 @@ struct SurfaceCache
|
|||
*/
|
||||
static bool CanHold(const IntSize& aSize);
|
||||
|
||||
/*
|
||||
* Removes a surface from the cache, if it's present.
|
||||
*
|
||||
* Use this function to remove individual surfaces that have become invalid.
|
||||
* Prefer Discard() or DiscardAll() when they're applicable, as they have much
|
||||
* better performance than calling this function repeatedly.
|
||||
*
|
||||
* @param aImageKey Key data identifying which image the surface belongs to.
|
||||
* @param aSurfaceKey Key data which uniquely identifies the requested surface.
|
||||
*/
|
||||
static void RemoveIfPresent(const ImageKey aImageKey,
|
||||
const SurfaceKey& aSurfaceKey);
|
||||
/*
|
||||
* Evicts any cached surfaces associated with the given image from the cache.
|
||||
* This MUST be called, at a minimum, when the image is destroyed. If
|
||||
|
|
Загрузка…
Ссылка в новой задаче