Bug 1491442 - Add CompositorWidget::DoCompositorCleanup() to give the widget a chance to clean up any state from PreRender/PostRender on the correct thread. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D40514

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-08-16 01:09:26 +00:00
parent 327b689a51
commit 62430de27f
8 changed files with 19 additions and 0 deletions

View File

@ -76,6 +76,9 @@ Compositor::Compositor(widget::CompositorWidget* aWidget,
Compositor::~Compositor() { ReadUnlockTextures(); }
// Called just before DetachWidget.
void Compositor::DoWidgetCleanup() { mWidget->DoCompositorCleanup(); }
void Compositor::Destroy() {
TextureSourceProvider::Destroy();
mIsDestroyed = true;

View File

@ -190,6 +190,7 @@ class Compositor : public TextureSourceProvider {
void Destroy() override;
bool IsDestroyed() const { return mIsDestroyed; }
virtual void DoWidgetCleanup();
virtual void DetachWidget() { mWidget = nullptr; }
/**

View File

@ -499,6 +499,7 @@ void CompositorBridgeParent::StopAndClearResources() {
}
if (mCompositor) {
mCompositor->DoWidgetCleanup();
mCompositor->DetachWidget();
mCompositor->Destroy();
mCompositor = nullptr;

View File

@ -68,6 +68,7 @@ RendererOGL::~RendererOGL() {
// Leak resources!
return;
}
mCompositor->GetWidget()->DoCompositorCleanup();
wr_renderer_delete(mRenderer);
}

View File

@ -116,6 +116,13 @@ class CompositorWidget {
*/
virtual void PostRender(WidgetRenderingContext* aContext) {}
/**
* Called on the same thread as PreRender/PostRender during destruction.
* This method gives the widget a chance to do any cleanup for state that it
* created during PreRender / PostRender.
*/
virtual void DoCompositorCleanup() {}
/**
* Called before the LayerManager draws the layer tree.
*

View File

@ -44,6 +44,10 @@ void InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext) {
mWidget->PostRender(aContext);
}
void InProcessCompositorWidget::DoCompositorCleanup() {
mWidget->DoCompositorCleanup();
}
void InProcessCompositorWidget::DrawWindowUnderlay(
WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
mWidget->DrawWindowUnderlay(aContext, aRect);

View File

@ -19,6 +19,7 @@ class InProcessCompositorWidget : public CompositorWidget {
virtual bool PreRender(WidgetRenderingContext* aManager) override;
virtual void PostRender(WidgetRenderingContext* aManager) override;
virtual void DoCompositorCleanup() override;
virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) override;
virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,

View File

@ -448,6 +448,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
return true;
}
virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) {}
virtual void DoCompositorCleanup() {}
virtual void DrawWindowUnderlay(
mozilla::widget::WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) {}