diff --git a/gfx/layers/client/ClientThebesLayer.cpp b/gfx/layers/client/ClientThebesLayer.cpp index 6ac25ffaba95..47711ef838f0 100644 --- a/gfx/layers/client/ClientThebesLayer.cpp +++ b/gfx/layers/client/ClientThebesLayer.cpp @@ -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 diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 3d46c136962c..78bd30ebbb89 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -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) { diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index 780ad4db53af..12bfe0bb77f6 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -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: