From 650f64603f47a81ef841c02b56bdb53efb97fe1a Mon Sep 17 00:00:00 2001 From: sotaro Date: Fri, 5 Jun 2020 05:03:40 +0000 Subject: [PATCH] Bug 1642839 - Implement WebRenderLayerManager::SendInvalidRegion() r=jrmuizel When DWM is disabled, each window does not have own back buffer. They would paint directly to a buffer that was to be displayed by the video card. WM_PAINT via SendInvalidRegion() requests necessary re-paint. With it, RenderCompositorANGLE does not need to disable partial present. Differential Revision: https://phabricator.services.mozilla.com/D77989 --- gfx/layers/wr/WebRenderLayerManager.cpp | 12 ++++++++++++ gfx/webrender_bindings/RenderCompositorANGLE.cpp | 12 +----------- widget/gtk/nsWindow.cpp | 6 ------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/gfx/layers/wr/WebRenderLayerManager.cpp b/gfx/layers/wr/WebRenderLayerManager.cpp index d5ab08043ecc..1778d6d22fcc 100644 --- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -671,6 +671,18 @@ void WebRenderLayerManager::WaitOnTransactionProcessed() { void WebRenderLayerManager::SendInvalidRegion(const nsIntRegion& aRegion) { // XXX Webrender does not support invalid region yet. + +#ifdef XP_WIN + // When DWM is disabled, each window does not have own back buffer. They would + // paint directly to a buffer that was to be displayed by the video card. + // WM_PAINT via SendInvalidRegion() requests necessary re-paint. + const bool needsInvalidate = !gfx::gfxVars::DwmCompositionEnabled(); +#else + const bool needsInvalidate = true; +#endif + if (needsInvalidate && WrBridge()) { + WrBridge()->SendInvalidateRenderedFrame(); + } } void WebRenderLayerManager::ScheduleComposite() { diff --git a/gfx/webrender_bindings/RenderCompositorANGLE.cpp b/gfx/webrender_bindings/RenderCompositorANGLE.cpp index b25ccdd23c63..1f2adfc1e6cd 100644 --- a/gfx/webrender_bindings/RenderCompositorANGLE.cpp +++ b/gfx/webrender_bindings/RenderCompositorANGLE.cpp @@ -928,17 +928,7 @@ void RenderCompositorANGLE::InitializeUsePartialPresent() { bool RenderCompositorANGLE::UsePartialPresent() { return mUsePartialPresent; } -bool RenderCompositorANGLE::RequestFullRender() { - if (!gfx::gfxVars::DwmCompositionEnabled()) { - // When DWM is disabled, background window needs to repaint its visible - // region with WM_PAINT. But invalid region is not supported yet by - // WebRenderLayerManager::SendInvalidRegion(). When partial present is - // enabled, there is a case that updated rectangle does not cover the - // invalid region. Then requests full render for now. - mFullRender = true; - } - return mFullRender; -} +bool RenderCompositorANGLE::RequestFullRender() { return mFullRender; } uint32_t RenderCompositorANGLE::GetMaxPartialPresentRects() { if (!mUsePartialPresent) { diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 65f0b1695327..97699e6e0351 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2657,12 +2657,6 @@ gboolean nsWindow::OnExposeEvent(cairo_t* cr) { // don't have a compositing window manager, our pixels could be stale. GetLayerManager()->SetNeedsComposite(true); GetLayerManager()->SendInvalidRegion(region.ToUnknownRegion()); - if (WebRenderLayerManager* wrlm = - GetLayerManager()->AsWebRenderLayerManager()) { - if (WebRenderBridgeChild* bridge = wrlm->WrBridge()) { - bridge->SendInvalidateRenderedFrame(); - } - } } RefPtr strongThis(this);