Bug 1482956 - Use an AutoTArray in PaintTask to reduce heap allocations. r=nical

There should only ever be at most four TextureClients here, so
allocated a vector seems wasteful.

--HG--
extra : rebase_source : 6b0f9f7749461eb39cd3c6c6bf7917152ffc9aab
extra : histedit_source : b5539d02c294596a5147dc55b417ef7970f8c0cd
This commit is contained in:
Ryan Hunt 2018-08-13 12:22:18 -05:00
Родитель 2c62e46a50
Коммит 92823fa25e
5 изменённых файлов: 15 добавлений и 15 удалений

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

@ -36,7 +36,7 @@ using namespace gfx;
void
PaintTask::DropTextureClients()
{
mClients.clear();
mClients.Clear();
}
StaticAutoPtr<PaintThread> PaintThread::sSingleton;

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

@ -36,7 +36,7 @@ public:
RefPtr<gfx::DrawTarget> mTarget;
RefPtr<gfx::DrawTargetCapture> mCapture;
std::vector<RefPtr<TextureClient>> mClients;
AutoTArray<RefPtr<TextureClient>, 4> mClients;
protected:
virtual ~PaintTask() {}

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

@ -276,9 +276,9 @@ ContentClient::BeginPaint(PaintedLayer* aLayer,
if (result.mAsyncPaint) {
result.mAsyncTask->mTarget = mBuffer->GetBufferTarget();
result.mAsyncTask->mClients.push_back(mBuffer->GetClient());
result.mAsyncTask->mClients.AppendElement(mBuffer->GetClient());
if (mBuffer->GetClientOnWhite()) {
result.mAsyncTask->mClients.push_back(mBuffer->GetClientOnWhite());
result.mAsyncTask->mClients.AppendElement(mBuffer->GetClientOnWhite());
}
}
@ -887,9 +887,9 @@ ContentClientDoubleBuffered::FinalizeFrame(PaintState& aPaintState)
mBuffer->UpdateDestinationFrom(*mFrontBuffer, updateRegion.GetBounds());
if (aPaintState.mAsyncPaint) {
aPaintState.mAsyncTask->mClients.push_back(mFrontBuffer->GetClient());
aPaintState.mAsyncTask->mClients.AppendElement(mFrontBuffer->GetClient());
if (mFrontBuffer->GetClientOnWhite()) {
aPaintState.mAsyncTask->mClients.push_back(mFrontBuffer->GetClientOnWhite());
aPaintState.mAsyncTask->mClients.AppendElement(mFrontBuffer->GetClientOnWhite());
}
}

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

@ -435,7 +435,7 @@ TileClient::ValidateFromFront(const nsIntRegion& aDirtyRegion,
gfx::DrawTarget* aBackBuffer,
TilePaintFlags aFlags,
IntRect* aCopiedRect,
std::vector<RefPtr<TextureClient>>* aClients)
AutoTArray<RefPtr<TextureClient>, 4>* aClients)
{
if (!mBackBuffer || !mFrontBuffer) {
return;
@ -479,9 +479,9 @@ TileClient::ValidateFromFront(const nsIntRegion& aDirtyRegion,
aBackBuffer->CopySurface(frontSurface, rectToCopy, rectToCopy.TopLeft());
if (aFlags & TilePaintFlags::Async) {
aClients->push_back(mFrontBuffer);
aClients->AppendElement(mFrontBuffer);
if (mFrontBufferOnWhite) {
aClients->push_back(mFrontBufferOnWhite);
aClients->AppendElement(mFrontBufferOnWhite);
}
}
@ -716,10 +716,10 @@ TileClient::AcquireBackBuffer(CompositableClient& aCompositable,
}
// Gather texture clients
std::vector<RefPtr<TextureClient>> clients;
clients.push_back(RefPtr<TextureClient>(mBackBuffer));
AutoTArray<RefPtr<TextureClient>, 4> clients;
clients.AppendElement(RefPtr<TextureClient>(mBackBuffer));
if (mBackBufferOnWhite) {
clients.push_back(mBackBufferOnWhite);
clients.AppendElement(mBackBufferOnWhite);
}
// Copy from the front buerr to the back if necessary

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

@ -57,7 +57,7 @@ struct AcquiredBackBuffer
gfx::DrawTargetCapture* aCapture,
gfx::DrawTarget* aBackBuffer,
const gfx::IntRect& aUpdatedRect,
std::vector<RefPtr<TextureClient>>&& aTextureClients)
AutoTArray<RefPtr<TextureClient>, 4>&& aTextureClients)
: mTarget(aTarget)
, mCapture(aCapture)
, mBackBuffer(aBackBuffer)
@ -75,7 +75,7 @@ struct AcquiredBackBuffer
RefPtr<gfx::DrawTargetCapture> mCapture;
RefPtr<gfx::DrawTarget> mBackBuffer;
gfx::IntRect mUpdatedRect;
std::vector<RefPtr<TextureClient>> mTextureClients;
AutoTArray<RefPtr<TextureClient>, 4> mTextureClients;
};
/**
@ -204,7 +204,7 @@ private:
gfx::DrawTarget* aBackBuffer,
TilePaintFlags aFlags,
gfx::IntRect* aCopiedRegion,
std::vector<RefPtr<TextureClient>>* aClients);
AutoTArray<RefPtr<TextureClient>, 4>* aClients);
};
/**