Bug 1820066 [2/3] - Allow in-process use of the compositor window r=sotaro

The in-process compositor assumes that no compositor window was present.
This is not guaranteed to be true if, for example, the preference
`gfx.webrender.flip-sequential` is set.

Make the in-process compositor more closely mirror the out-of-process
compositor. (At present this effectively just means calling ::SetParent
on the compositor window.)

Differential Revision: https://phabricator.services.mozilla.com/D172733
This commit is contained in:
Ray Kraesig 2023-03-22 15:09:24 +00:00
parent 0fe41b776a
commit cfe1fff87e
4 changed files with 19 additions and 5 deletions

View File

@ -259,6 +259,9 @@ void CompositorBridgeParent::InitSameProcess(widget::CompositorWidget* aWidget,
mWidget = aWidget;
mRootLayerTreeID = aLayerTreeId;
#if defined(XP_WIN)
mWidget->AsWindows()->SetRootLayerTreeID(mRootLayerTreeID);
#endif
Initialize();
}

View File

@ -360,4 +360,15 @@ void InProcessWinCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
}
}
void InProcessWinCompositorWidget::UpdateCompositorWnd(
const HWND aCompositorWnd, const HWND aParentWnd) {
MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread());
MOZ_ASSERT(aCompositorWnd && aParentWnd);
MOZ_ASSERT(aParentWnd == mWnd);
// Since we're in the parent process anyway, we can just call SetParent
// directly.
::SetParent(aCompositorWnd, aParentWnd);
mSetParentCompleted = true;
}
} // namespace mozilla::widget

View File

@ -71,7 +71,7 @@ class InProcessWinCompositorWidget final
nsIWidget* RealWidget() override;
void UpdateCompositorWnd(const HWND aCompositorWnd,
const HWND aParentWnd) override {}
const HWND aParentWnd) override;
void SetRootLayerTreeID(const layers::LayersId& aRootLayerTreeId) override {}
private:

View File

@ -70,10 +70,10 @@ void WinCompositorWidget::UpdateCompositorWndSizeIfNecessary() {
return;
}
// This code is racing with the compositor, which needs to reparent
// the compositor surface to the actual window (mWnd). To avoid racing
// mutations, we refuse to proceed until ::SetParent() is called in parent
// process. After the ::SetParent() call, composition is scheduled in
// This code is racing with the compositor, which needs to reparent the
// compositor surface to the actual window (mWnd). To avoid racing mutations,
// we refuse to proceed until ::SetParent() is called in the parent process.
// After the ::SetParent() call, composition is scheduled in
// CompositorWidgetParent::UpdateCompositorWnd().
if (!mSetParentCompleted) {
// ::SetParent() is not completed yet.