diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index 6e4b588c09ca..0e04a1e66cbd 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -25,14 +25,14 @@ TextureClientPool::TextureClientPool(LayersBackend aLayersBackend, gfx::IntSize aSize, TextureFlags aFlags, uint32_t aInitialPoolSize, - uint32_t aPoolIncrementSize, + uint32_t aPoolUnusedSize, TextureForwarder* aAllocator) : mBackend(aLayersBackend) , mFormat(aFormat) , mSize(aSize) , mFlags(aFlags) , mInitialPoolSize(aInitialPoolSize) - , mPoolIncrementSize(aPoolIncrementSize) + , mPoolUnusedSize(aPoolUnusedSize) , mOutstandingClients(0) , mSurfaceAllocator(aAllocator) , mDestroyed(false) @@ -91,10 +91,9 @@ TextureClientPool::GetTextureClient() // We initially allocate mInitialPoolSize for our pool. If we run // out of TextureClients, we allocate additional TextureClients to try and keep around - // mPoolIncrementSize + // mPoolUnusedSize if (!mTextureClients.size()) { - size_t size = mOutstandingClients ? mPoolIncrementSize : mInitialPoolSize; - AllocateTextureClients(size); + AllocateTextureClient(); } if (!mTextureClients.size()) { @@ -119,31 +118,30 @@ TextureClientPool::GetTextureClient() } void -TextureClientPool::AllocateTextureClients(size_t aSize) +TextureClientPool::AllocateTextureClient() { - TCP_LOG("TexturePool %p allocating %u clients, outstanding %u\n", - this, aSize, mOutstandingClients); + TCP_LOG("TexturePool %p allocating TextureClient, outstanding %u\n", + this, mOutstandingClients); RefPtr newClient; - while (mTextureClients.size() < aSize) { - if (gfxPrefs::ForceShmemTiles()) { - // gfx::BackendType::NONE means use the content backend - newClient = - TextureClient::CreateForRawBufferAccess(mSurfaceAllocator, - mFormat, mSize, - gfx::BackendType::NONE, - mFlags, ALLOC_DEFAULT); - } else { - newClient = - TextureClient::CreateForDrawing(mSurfaceAllocator, - mFormat, mSize, - mBackend, - BackendSelector::Content, - mFlags); - } - if (newClient) { - mTextureClients.push(newClient); - } + if (gfxPrefs::ForceShmemTiles()) { + // gfx::BackendType::NONE means use the content backend + newClient = + TextureClient::CreateForRawBufferAccess(mSurfaceAllocator, + mFormat, mSize, + gfx::BackendType::NONE, + mFlags, ALLOC_DEFAULT); + } else { + newClient = + TextureClient::CreateForDrawing(mSurfaceAllocator, + mFormat, mSize, + mBackend, + BackendSelector::Content, + mFlags); + } + + if (newClient) { + mTextureClients.push(newClient); } } @@ -196,17 +194,17 @@ TextureClientPool::ShrinkToMaximumSize() uint32_t totalUnusedTextureClients = mTextureClients.size() + mTextureClientsDeferred.size(); // If we have > mInitialPoolSize outstanding, then we want to keep around - // mPoolIncrementSize at a maximum. If we have fewer than mInitialPoolSize + // mPoolUnusedSize at a maximum. If we have fewer than mInitialPoolSize // outstanding, then keep around the entire initial pool size. uint32_t targetUnusedClients; if (mOutstandingClients > mInitialPoolSize) { - targetUnusedClients = mPoolIncrementSize; + targetUnusedClients = mPoolUnusedSize; } else { targetUnusedClients = mInitialPoolSize; } - TCP_LOG("TexturePool %p shrinking to maximum unused size %u; total outstanding %u\n", - this, targetUnusedClients, mOutstandingClients); + TCP_LOG("TexturePool %p shrinking to maximum unused size %u; current pool size %u; total outstanding %u\n", + this, targetUnusedClients, totalUnusedTextureClients, mOutstandingClients); while (totalUnusedTextureClients > targetUnusedClients) { if (mTextureClientsDeferred.size()) { @@ -288,7 +286,7 @@ void TextureClientPool::Destroy() Clear(); mDestroyed = true; mInitialPoolSize = 0; - mPoolIncrementSize = 0; + mPoolUnusedSize = 0; } } // namespace layers diff --git a/gfx/layers/client/TextureClientPool.h b/gfx/layers/client/TextureClientPool.h index 16e016f2f122..5638c1e5258b 100644 --- a/gfx/layers/client/TextureClientPool.h +++ b/gfx/layers/client/TextureClientPool.h @@ -49,7 +49,7 @@ public: gfx::IntSize aSize, TextureFlags aFlags, uint32_t aInitialPoolSize, - uint32_t aPoolIncrementSize, + uint32_t aPoolUnusedSize, TextureForwarder* aAllocator); /** @@ -111,11 +111,8 @@ public: private: void ReturnUnlockedClients(); - /// We maintain a number of unused texture clients for immediate return from - /// GetTextureClient(). This will normally be called if there are no - /// TextureClients available in the pool, which ideally should only ever - /// be at startup. - void AllocateTextureClients(size_t aSize); + /// Allocate a single TextureClient to be returned from the pool. + void AllocateTextureClient(); /// Backend passed to the TextureClient for buffer creation. LayersBackend mBackend; @@ -135,7 +132,7 @@ private: // How many unused texture clients to try and keep around if we go over // the initial allocation - uint32_t mPoolIncrementSize; + uint32_t mPoolUnusedSize; /// This is a total number of clients in the wild and in the stack of /// deferred clients (see below). So, the total number of clients in diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index f524f32e6647..43243a4c5316 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -948,7 +948,7 @@ CompositorBridgeChild::GetTexturePool(LayersBackend aBackend, gfxPlatform::GetPlatform()->GetTileHeight()), aFlags, gfxPrefs::LayersTileInitialPoolSize(), - gfxPrefs::LayersTilePoolIncrementSize(), + gfxPrefs::LayersTilePoolUnusedSize(), this)); return mTexturePools.LastElement(); diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 9f3d0e39baa5..ff9c7527475c 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -485,7 +485,7 @@ private: DECL_GFX_PREF(Once, "layers.tile-width", LayersTileWidth, int32_t, 256); DECL_GFX_PREF(Once, "layers.tile-height", LayersTileHeight, int32_t, 256); DECL_GFX_PREF(Once, "layers.tile-initial-pool-size", LayersTileInitialPoolSize, uint32_t, (uint32_t)50); - DECL_GFX_PREF(Once, "layers.tile-pool-increment-size", LayersTilePoolIncrementSize, uint32_t, (uint32_t)10); + DECL_GFX_PREF(Once, "layers.tile-pool-unused-size", LayersTilePoolUnusedSize, uint32_t, (uint32_t)10); DECL_GFX_PREF(Once, "layers.tiles.adjust", LayersTilesAdjust, bool, true); DECL_GFX_PREF(Once, "layers.tiles.edge-padding", TileEdgePaddingEnabled, bool, true); DECL_GFX_PREF(Live, "layers.tiles.fade-in.enabled", LayerTileFadeInEnabled, bool, false);