From 427fc1d03cb42af65bba318a08f0b751c7c51a45 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 31 Jul 2017 12:29:18 -0700 Subject: [PATCH] Include visible region changes in the cached invalid region for ContainerLayers. (bug 1381666 part 4, r=mattwoodrow) --- gfx/layers/LayerTreeInvalidation.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gfx/layers/LayerTreeInvalidation.cpp b/gfx/layers/LayerTreeInvalidation.cpp index 3de5968e1f5d..c138a163fcfd 100644 --- a/gfx/layers/LayerTreeInvalidation.cpp +++ b/gfx/layers/LayerTreeInvalidation.cpp @@ -421,10 +421,22 @@ public: } if (container->UseIntermediateSurface()) { - IntRect bounds = invalidateWholeLayer - ? mLayer->GetLocalVisibleRegion().ToUnknownRegion().GetBounds() - : result.GetBounds(); - container->SetInvalidCompositeRect(bounds); + Maybe bounds; + + if (!invalidateWholeLayer) { + bounds = Some(result.GetBounds()); + + // Process changes in the visible region. + IntRegion newVisible = mLayer->GetLocalVisibleRegion().ToUnknownRegion(); + if (!newVisible.IsEqual(mVisibleRegion)) { + newVisible.XorWith(mVisibleRegion); + bounds = bounds->SafeUnion(newVisible.GetBounds()); + } + } + if (!bounds) { + bounds = Some(mLayer->GetLocalVisibleRegion().GetBounds().ToUnknownRect()); + } + container->SetInvalidCompositeRect(bounds.value()); } if (!mLayer->Extend3DContext()) {