From 0a52a8db040d1fd186054993f307e0bdc60a0e5b Mon Sep 17 00:00:00 2001 From: sotaro Date: Tue, 13 Apr 2021 03:31:03 +0000 Subject: [PATCH] Bug 1704431 - Handle start compositing only when dirty rect exists r=lsalzman,gfx-reviewers When render_impl is called from update, the device_size is None, and so dirty rect calculation is skipped. Then if RenderCompositorLayersSWGL does not handle start compositing when dirty rect does not exist, we could ignore StartCompositing() from update. Differential Revision: https://phabricator.services.mozilla.com/D111583 --- .../RenderCompositorLayersSWGL.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gfx/webrender_bindings/RenderCompositorLayersSWGL.cpp b/gfx/webrender_bindings/RenderCompositorLayersSWGL.cpp index 1514f5d1b34e..af59637c65a3 100644 --- a/gfx/webrender_bindings/RenderCompositorLayersSWGL.cpp +++ b/gfx/webrender_bindings/RenderCompositorLayersSWGL.cpp @@ -75,21 +75,23 @@ void RenderCompositorLayersSWGL::CancelFrame() { void RenderCompositorLayersSWGL::StartCompositing( const wr::DeviceIntRect* aDirtyRects, size_t aNumDirtyRects, const wr::DeviceIntRect* aOpaqueRects, size_t aNumOpaqueRects) { - if (!mInFrame) { + MOZ_RELEASE_ASSERT(!mCompositingStarted); + + if (!mInFrame || aNumDirtyRects == 0) { return; } + gfx::IntRect bounds(gfx::IntPoint(0, 0), GetBufferSize().ToUnknownSize()); nsIntRegion dirty; - if (aNumDirtyRects) { - for (size_t i = 0; i < aNumDirtyRects; i++) { - const auto& rect = aDirtyRects[i]; - dirty.OrWith(gfx::IntRect(rect.origin.x, rect.origin.y, rect.size.width, - rect.size.height)); - } - dirty.AndWith(bounds); - } else { - dirty = bounds; + + MOZ_RELEASE_ASSERT(aNumDirtyRects > 0); + for (size_t i = 0; i < aNumDirtyRects; i++) { + const auto& rect = aDirtyRects[i]; + dirty.OrWith(gfx::IntRect(rect.origin.x, rect.origin.y, rect.size.width, + rect.size.height)); } + dirty.AndWith(bounds); + nsIntRegion opaque(bounds); opaque.SubOut(mWidget->GetTransparentRegion().ToUnknownRegion()); for (size_t i = 0; i < aNumOpaqueRects; i++) {