Skip to content

Commit

Permalink
Bug 1777664 [Linux] Don't pause/resume compositor by nsWindow::SetCom…
Browse files Browse the repository at this point in the history
…positorWidgetDelegate() r=emilio

nsWindow::SetCompositorWidgetDelegate() should not control compositor state as nsWindow::SetCompositorWidgetDelegate() itself is called by nsBaseWidget::CreateCompositor()/nsBaseWidget::DestroyCompositor().

In this patch we remove compositor pause/resume from nsWindow::SetCompositorWidgetDelegate() and update only GdkWindow/XWindow stored in remote widget.

Differential Revision: https://phabricator.services.mozilla.com/D152687
  • Loading branch information
stransky committed Jul 26, 2022
1 parent c2a7d21 commit 6164864
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5303,11 +5303,6 @@ static void GtkWidgetDisableUpdates(GtkWidget* aWidget) {
void nsWindow::EnableRenderingToWindow() {
LOG("nsWindow::EnableRenderingToWindow()");

if (mCompositorWidgetDelegate) {
mCompositorWidgetDelegate->EnableRendering(GetX11Window(),
GetShapedState());
}

if (GdkIsWaylandDisplay()) {
#ifdef MOZ_WAYLAND
moz_container_wayland_add_initial_draw_callback(
Expand Down Expand Up @@ -5417,6 +5412,11 @@ void nsWindow::ConfigureGdkWindow() {
mCompositorState = COMPOSITOR_PAUSED_MISSING_WINDOW;
}

if (mCompositorWidgetDelegate) {
mCompositorWidgetDelegate->EnableRendering(GetX11Window(),
GetShapedState());
}

EnableRenderingToWindow();

if (mHasMappedToplevel) {
Expand Down Expand Up @@ -8503,26 +8503,29 @@ void nsWindow::DidGetNonBlankPaint() {
/* nsWindow::SetCompositorWidgetDelegate() sets remote GtkCompositorWidget
* to render into with compositor.
*
* If we're already visible we need to recreate compositor/vsync state.
* SetCompositorWidgetDelegate(delegate) is called from
* nsBaseWidget::CreateCompositor(), i.e. nsWindow::GetWindowRenderer().
*
* SetCompositorWidgetDelegate(null) is called from
* nsBaseWidget::DestroyCompositor().
*/
void nsWindow::SetCompositorWidgetDelegate(CompositorWidgetDelegate* delegate) {
LOG("nsWindow::SetCompositorWidgetDelegate %p\n", delegate);

// There's a change of remote widget - stop compositor and VSync as
// we're going re-init it.
if (mCompositorWidgetDelegate && mIsMapped) {
DisableRenderingToWindow();
// Remove reference to GdkWindow/XWindow from remote widget.
if (mCompositorWidgetDelegate) {
mCompositorWidgetDelegate->DisableRendering();
}

if (delegate) {
mCompositorWidgetDelegate = delegate->AsPlatformSpecificDelegate();
MOZ_ASSERT(mCompositorWidgetDelegate,
"nsWindow::SetCompositorWidgetDelegate called with a "
"non-PlatformCompositorWidgetDelegate");
// This is called from nsBaseWidget::CreateCompositor() in which case
// we need to create a new EGL surface in RenderCompositorEGL on X11
// Pass recent GdkWindow/XWindow to remote widget.
if (mIsMapped) {
EnableRenderingToWindow();
mCompositorWidgetDelegate->EnableRendering(GetX11Window(),
GetShapedState());
}
} else {
mCompositorWidgetDelegate = nullptr;
Expand Down

0 comments on commit 6164864

Please sign in to comment.