mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1299410 - Shrink TextureClientRecycleAllocator more aggressively r=nical
This commit is contained in:
parent
1cf8ba2093
commit
f4338e33b8
@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
explicit TextureClientHolder(TextureClient* aClient)
|
explicit TextureClientHolder(TextureClient* aClient)
|
||||||
: mTextureClient(aClient)
|
: mTextureClient(aClient)
|
||||||
|
, mWillRecycle(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TextureClient* GetTextureClient()
|
TextureClient* GetTextureClient()
|
||||||
@ -29,9 +30,20 @@ public:
|
|||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WillRecycle()
|
||||||
|
{
|
||||||
|
return mWillRecycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearWillRecycle()
|
||||||
|
{
|
||||||
|
mWillRecycle = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ClearTextureClient() { mTextureClient = nullptr; }
|
void ClearTextureClient() { mTextureClient = nullptr; }
|
||||||
protected:
|
protected:
|
||||||
RefPtr<TextureClient> mTextureClient;
|
RefPtr<TextureClient> mTextureClient;
|
||||||
|
bool mWillRecycle;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultTextureClientAllocationHelper : public ITextureClientAllocationHelper
|
class DefaultTextureClientAllocationHelper : public ITextureClientAllocationHelper
|
||||||
@ -221,16 +233,17 @@ TextureClientRecycleAllocator::Allocate(gfx::SurfaceFormat aFormat,
|
|||||||
void
|
void
|
||||||
TextureClientRecycleAllocator::ShrinkToMinimumSize()
|
TextureClientRecycleAllocator::ShrinkToMinimumSize()
|
||||||
{
|
{
|
||||||
RefPtr<TextureClientRecycleAllocator> kungFuDeathGrip(this);
|
MutexAutoLock lock(mLock);
|
||||||
std::map<TextureClient*, RefPtr<TextureClientHolder> > inUseClients;
|
while (!mPooledClients.empty()) {
|
||||||
{
|
mPooledClients.pop();
|
||||||
MutexAutoLock lock(mLock);
|
}
|
||||||
while (!mPooledClients.empty()) {
|
// We can not clear using TextureClients safely.
|
||||||
mPooledClients.pop();
|
// Just clear WillRecycle here.
|
||||||
}
|
std::map<TextureClient*, RefPtr<TextureClientHolder> >::iterator it;
|
||||||
mInUseClients.swap(inUseClients);
|
for (it = mInUseClients.begin(); it != mInUseClients.end(); it++) {
|
||||||
|
RefPtr<TextureClientHolder> holder = it->second;
|
||||||
|
holder->ClearWillRecycle();
|
||||||
}
|
}
|
||||||
inUseClients.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -256,7 +269,8 @@ TextureClientRecycleAllocator::RecycleTextureClient(TextureClient* aClient)
|
|||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
if (mInUseClients.find(aClient) != mInUseClients.end()) {
|
if (mInUseClients.find(aClient) != mInUseClients.end()) {
|
||||||
textureHolder = mInUseClients[aClient]; // Keep reference count of TextureClientHolder within lock.
|
textureHolder = mInUseClients[aClient]; // Keep reference count of TextureClientHolder within lock.
|
||||||
if (!mIsDestroyed && mPooledClients.size() < mMaxPooledSize) {
|
if (textureHolder->WillRecycle() &&
|
||||||
|
!mIsDestroyed && mPooledClients.size() < mMaxPooledSize) {
|
||||||
mPooledClients.push(textureHolder);
|
mPooledClients.push(textureHolder);
|
||||||
}
|
}
|
||||||
mInUseClients.erase(aClient);
|
mInUseClients.erase(aClient);
|
||||||
|
Loading…
Reference in New Issue
Block a user