Bug 991513 - Part 3: Combine BeginPaint/PrepareFrame and EndPaint/OnTransaction. r=nrc

This commit is contained in:
Matt Woodrow 2014-04-09 21:15:19 +12:00
parent aad218ca64
commit 69a8c9458d
3 changed files with 24 additions and 22 deletions

View File

@ -38,8 +38,6 @@ ClientThebesLayer::PaintThebes()
NS_ASSERTION(ClientManager()->InDrawing(),
"Can only draw in drawing phase");
mContentClient->PrepareFrame();
uint32_t flags = RotatedContentBuffer::PAINT_CAN_DRAW_ROTATED;
#ifndef MOZ_WIDGET_ANDROID
if (ClientManager()->CompositorMightResample()) {
@ -124,18 +122,6 @@ ClientThebesLayer::RenderLayer()
mContentClient->BeginPaint();
PaintThebes();
mContentClient->EndPaint();
// It is very important that this is called after EndPaint, because destroying
// textures is a three stage process:
// 1. We are done with the buffer and move it to ContentClient::mOldTextures,
// that happens in DestroyBuffers which is may be called indirectly from
// PaintThebes.
// 2. The content client calls RemoveTextureClient on the texture clients in
// mOldTextures and forgets them. They then become invalid. The compositable
// client keeps a record of IDs. This happens in EndPaint.
// 3. An IPC message is sent to destroy the corresponding texture host. That
// happens from OnTransaction.
// It is important that these steps happen in order.
mContentClient->OnTransaction();
}
already_AddRefed<ThebesLayer>

View File

@ -89,6 +89,23 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
return new ContentClientSingleBuffered(aForwarder);
}
void
ContentClient::EndPaint()
{
// It is very important that this is called after any overridden EndPaint behaviour,
// because destroying textures is a three stage process:
// 1. We are done with the buffer and move it to ContentClient::mOldTextures,
// that happens in DestroyBuffers which is may be called indirectly from
// PaintThebes.
// 2. The content client calls RemoveTextureClient on the texture clients in
// mOldTextures and forgets them. They then become invalid. The compositable
// client keeps a record of IDs. This happens in EndPaint.
// 3. An IPC message is sent to destroy the corresponding texture host. That
// happens from OnTransaction.
// It is important that these steps happen in order.
OnTransaction();
}
// We pass a null pointer for the ContentClient Forwarder argument, which means
// this client will not have a ContentHost on the other side.
ContentClientBasic::ContentClientBasic()
@ -162,6 +179,7 @@ ContentClientRemoteBuffer::EndPaint()
if (mTextureClientOnWhite && mTextureClientOnWhite->IsLocked()) {
mTextureClientOnWhite->Unlock();
}
ContentClientRemote::EndPaint();
}
bool
@ -378,8 +396,10 @@ ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
}
void
ContentClientDoubleBuffered::PrepareFrame()
ContentClientDoubleBuffered::BeginPaint()
{
ContentClientRemoteBuffer::BeginPaint();
mIsNewBuffer = false;
if (!mFrontAndBackBufferDiffer) {

View File

@ -63,7 +63,6 @@ class ThebesLayer;
* it alive anymore, so we clear mOldTextures.
*
* The sequence for painting is: call BeginPaint on the content client;
* call PrepareFrame on the content client;
* call BeginPaintBuffer on the content client. That will initialise the buffer
* for painting, by calling RotatedContentBuffer::BeginPaint (usually) which
* will call back to ContentClient::FinalizeFrame to finalize update of the
@ -71,7 +70,6 @@ class ThebesLayer;
* BorrowDrawTargetForPainting to get a DrawTarget to paint into. Then paint.
* Then return that DrawTarget using ReturnDrawTarget.
* Call EndPaint on the content client;
* call OnTransaction on the content client.
*
* SwapBuffers is called in response to the transaction reply from the compositor.
*/
@ -99,8 +97,6 @@ public:
RotatedContentBuffer::DrawIterator* aIter = nullptr) = 0;
virtual void ReturnDrawTargetToBuffer(gfx::DrawTarget*& aReturned) = 0;
virtual void PrepareFrame() {}
// Called as part of the layers transation reply. Conveys data about our
// buffer(s) from the compositor. If appropriate we should swap references
// to our buffers.
@ -108,8 +104,7 @@ public:
// call before and after painting into this content client
virtual void BeginPaint() {}
virtual void EndPaint() {}
virtual void EndPaint();
};
/**
@ -333,7 +328,7 @@ public:
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) MOZ_OVERRIDE;
virtual void PrepareFrame() MOZ_OVERRIDE;
virtual void BeginPaint() MOZ_OVERRIDE;
virtual void FinalizeFrame(const nsIntRegion& aRegionToDraw) MOZ_OVERRIDE;
@ -439,6 +434,7 @@ public:
if (IsSurfaceDescriptorValid(mUpdateDescriptorOnWhite)) {
mForwarder->DestroySharedSurface(&mUpdateDescriptorOnWhite);
}
ContentClientRemote::EndPaint();
}
private: