From ccec906120d39df409e728130e7f7f4dfa0ab760 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 2 May 2019 22:02:30 +0000 Subject: [PATCH] Bug 1547159 - Composite just the visible rects of ColorLayerComposite on mobile. r=jnicol Differential Revision: https://phabricator.services.mozilla.com/D29456 --HG-- extra : moz-landing-system : lando --- gfx/layers/composite/ColorLayerComposite.cpp | 31 ++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/gfx/layers/composite/ColorLayerComposite.cpp b/gfx/layers/composite/ColorLayerComposite.cpp index b32438344985..1dea139bad13 100644 --- a/gfx/layers/composite/ColorLayerComposite.cpp +++ b/gfx/layers/composite/ColorLayerComposite.cpp @@ -22,19 +22,32 @@ using namespace mozilla::gfx; void ColorLayerComposite::RenderLayer(const gfx::IntRect& aClipRect, const Maybe& aGeometry) { - Rect rect(GetBounds()); - const Matrix4x4& transform = GetEffectiveTransform(); - RenderWithAllMasks(this, mCompositor, aClipRect, - [&](EffectChain& effectChain, const IntRect& clipRect) { - GenEffectChain(effectChain); +#ifdef MOZ_GFX_OPTIMIZE_MOBILE + // On desktop we want to draw a single rectangle to avoid possible + // seams if we're resampling. On mobile we'd prefer to use the accurate + // region for better performance. + LayerIntRegion drawRegion = GetLocalVisibleRegion(); +#else + LayerIntRegion drawRegion = ViewAs(GetBounds()); +#endif - mCompositor->DrawGeometry(rect, clipRect, effectChain, - GetEffectiveOpacity(), - transform, aGeometry); - }); + for (auto iter = drawRegion.RectIter(); !iter.Done(); iter.Next()) { + const LayerIntRect& rect = iter.Get(); + Rect graphicsRect(rect.X(), rect.Y(), rect.Width(), rect.Height()); + RenderWithAllMasks(this, mCompositor, aClipRect, + [&](EffectChain& effectChain, const IntRect& clipRect) { + GenEffectChain(effectChain); + + mCompositor->DrawGeometry( + graphicsRect, clipRect, effectChain, + GetEffectiveOpacity(), transform, aGeometry); + }); + } + + Rect rect(GetBounds()); mCompositor->DrawDiagnostics(DiagnosticFlags::COLOR, rect, aClipRect, transform); }