From d185ad884cf224d1b41e9c88ec0ff8efc4920c6f Mon Sep 17 00:00:00 2001 From: sotaro Date: Fri, 12 Mar 2021 12:52:16 +0000 Subject: [PATCH] Bug 1697981 - Do not allocate CompositorWindow for Software WebRender r=nical Since Bug 1688096 fix, WebRender and Software WebRender could be used at the same time. Differential Revision: https://phabricator.services.mozilla.com/D108141 --- gfx/layers/ipc/CompositorBridgeParent.cpp | 13 ++++++++++--- gfx/webrender_bindings/RenderCompositorANGLE.cpp | 12 ++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 26b25322af6a..cfb8237b1762 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1771,9 +1771,16 @@ PWebRenderBridgeParent* CompositorBridgeParent::AllocPWebRenderBridgeParent( MOZ_ASSERT(mWidget); #ifdef XP_WIN - if (mWidget && (DeviceManagerDx::Get()->CanUseDComp() || - gfxVars::UseWebRenderFlipSequentialWin())) { - mWidget->AsWindows()->EnsureCompositorWindow(); + if (mWidget && mWidget->AsWindows()) { + const auto options = mWidget->GetCompositorOptions(); + if (!options.UseSoftwareWebRender() && + (DeviceManagerDx::Get()->CanUseDComp() || + gfxVars::UseWebRenderFlipSequentialWin())) { + mWidget->AsWindows()->EnsureCompositorWindow(); + } else if (options.UseSoftwareWebRender() && + mWidget->AsWindows()->GetCompositorHwnd()) { + mWidget->AsWindows()->DestroyCompositorWindow(); + } } #endif diff --git a/gfx/webrender_bindings/RenderCompositorANGLE.cpp b/gfx/webrender_bindings/RenderCompositorANGLE.cpp index 1feaddaf2422..190e67793a1c 100644 --- a/gfx/webrender_bindings/RenderCompositorANGLE.cpp +++ b/gfx/webrender_bindings/RenderCompositorANGLE.cpp @@ -307,16 +307,16 @@ bool RenderCompositorANGLE::CreateSwapChain(nsACString& aError) { mUseTripleBuffering = useTripleBuffering; } else if (useFlipSequential) { gfxCriticalNoteOnce << "FLIP_SEQUENTIAL is not supported. Fallback"; - - if (mWidget->AsWindows()->GetCompositorHwnd()) { - // Destroy compositor window. - mWidget->AsWindows()->DestroyCompositorWindow(); - hwnd = mWidget->AsWindows()->GetHwnd(); - } } } if (!mSwapChain) { + if (mWidget->AsWindows()->GetCompositorHwnd()) { + // Destroy compositor window. + mWidget->AsWindows()->DestroyCompositorWindow(); + hwnd = mWidget->AsWindows()->GetHwnd(); + } + DXGI_SWAP_CHAIN_DESC swapDesc{}; swapDesc.BufferDesc.Width = 0; swapDesc.BufferDesc.Height = 0;